feat 增加mock数据别名
This commit is contained in:
+17
-2
@@ -137,6 +137,11 @@
|
||||
<el-button size="mini" type="primary" @click="openMockFileDialogForCreate">新增 Mock 文件</el-button>
|
||||
</div>
|
||||
<el-table :data="pagedMockFiles" border>
|
||||
<el-table-column label="别名" min-width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.alias || "-" }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="Mock 文件路径" min-width="320">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.filePath }}</span>
|
||||
@@ -266,7 +271,7 @@
|
||||
<el-option
|
||||
v-for="item in mockFiles"
|
||||
:key="item.filePath"
|
||||
:label="item.filePath"
|
||||
:label="item.alias ? item.alias + ' (' + item.filePath + ')' : item.filePath"
|
||||
:value="item.filePath"
|
||||
></el-option>
|
||||
</el-select>
|
||||
@@ -307,10 +312,16 @@
|
||||
width="760px"
|
||||
>
|
||||
<el-form :model="mockFileDialog.form" label-width="180px">
|
||||
<el-form-item label="别名">
|
||||
<el-input
|
||||
v-model="mockFileDialog.form.alias"
|
||||
placeholder="可选:用于展示,支持任意文本"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="Mock 文件路径">
|
||||
<el-input
|
||||
v-model="mockFileDialog.form.filePath"
|
||||
placeholder="mock/new-api.json"
|
||||
placeholder="mock/test123.json(路径仅英文和数字)"
|
||||
:disabled="mockFileDialog.mode === 'edit'"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
@@ -398,6 +409,7 @@
|
||||
mode: "create",
|
||||
form: {
|
||||
filePath: "mock/",
|
||||
alias: "",
|
||||
content: "",
|
||||
},
|
||||
},
|
||||
@@ -548,6 +560,7 @@
|
||||
getDefaultMockFileForm: function () {
|
||||
return {
|
||||
filePath: "mock/",
|
||||
alias: "",
|
||||
content: "",
|
||||
};
|
||||
},
|
||||
@@ -560,6 +573,7 @@
|
||||
this.mockFileDialog.mode = "edit";
|
||||
this.mockFileDialog.form = {
|
||||
filePath: item.filePath || "mock/",
|
||||
alias: String(item.alias || ""),
|
||||
content: String(item.content || ""),
|
||||
};
|
||||
this.mockFileDialog.visible = true;
|
||||
@@ -589,6 +603,7 @@
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
filePath: this.mockFileDialog.form.filePath,
|
||||
alias: this.mockFileDialog.form.alias,
|
||||
content: this.mockFileDialog.form.content,
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user