fix(接口测试): 修复接口环境显示变量问题

--bug=1034069 --user=王孝刚 【接口测试】api、case、场景自定义请求通过后置脚本设置环境变量-执行成功第一次查看环境变量未显示 https://www.tapd.cn/55049933/s/1448742
This commit is contained in:
wxg0103 2023-12-27 15:47:06 +08:00 committed by Craftsman
parent 08347de201
commit 7ab9c9d628
1 changed files with 238 additions and 236 deletions

View File

@ -32,7 +32,8 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="exportApi">{{ <el-dropdown-item command="exportApi">{{
$t("envrionment.export_variable_tip") $t("envrionment.export_variable_tip")
}}</el-dropdown-item> }}
</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -331,7 +332,7 @@ export default {
watch: { watch: {
items: { items: {
handler(v) { handler(v) {
this.sortParameters(); this.initData(v);
}, },
immediate: true, immediate: true,
deep: true, deep: true,
@ -768,23 +769,24 @@ export default {
handleExportCommand(command) { handleExportCommand(command) {
this.exportJSON(); this.exportJSON();
}, },
}, initData(v) {
created() { if (v.length === 0) {
if (this.items.length === 0) { v.push(new KeyValue({enable: true, scope: "api"}));
this.items.push(new KeyValue({ enable: true, scope: "api" }));
} else { } else {
// api // api
forEach(this.items, (item) => { forEach(v, (item) => {
delete item.hidden; delete item.hidden;
if (!item.scope) { if (!item.scope) {
this.$set(item, "scope", "api"); this.$set(item, "scope", "api");
} }
}); });
this.allData = this.items; this.allData = v;
this.sortParameters(); this.sortParameters();
this.queryPage(); this.queryPage();
} }
}
}, },
}; };
</script> </script>