diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index 6ee631177f..8310c10ff6 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -85,9 +85,7 @@ methods: { init() { - this.result = this.$get("/project/listAll", response => { - this.projects = response.data; - }) + let projectId; if (this.id) { this.create = false; this.getTest(this.id); @@ -97,7 +95,14 @@ if (this.$refs.config) { this.$refs.config.reset(); } + // 仅创建时获取选择的项目 + projectId = this.$store.state.common.projectId; } + this.result = this.$get("/project/listAll", response => { + this.projects = response.data; + // 等待项目列表加载完 + if (projectId) this.test.projectId = projectId; + }) }, getTest(id) { this.result = this.$get("/api/get/" + id, response => { diff --git a/frontend/src/business/components/api/test/ApiTestList.vue b/frontend/src/business/components/api/test/ApiTestList.vue index e3cb18c6aa..8a042bef3c 100644 --- a/frontend/src/business/components/api/test/ApiTestList.vue +++ b/frontend/src/business/components/api/test/ApiTestList.vue @@ -148,6 +148,9 @@ }, init() { this.projectId = this.$route.params.projectId; + if (this.projectId && this.projectId !== "all") { + this.$store.commit('setProjectId', this.projectId); + } this.search(); }, filter(value, row) { diff --git a/frontend/src/business/store.js b/frontend/src/business/store.js index 65b6847806..eb11bb79ce 100644 --- a/frontend/src/business/store.js +++ b/frontend/src/business/store.js @@ -3,6 +3,17 @@ import Vuex from 'vuex' Vue.use(Vuex); +const Common = { + state: { + projectId: "" + }, + mutations: { + setProjectId(state, projectId) { + state.projectId = projectId; + } + } +} + const API = { state: { test: {} @@ -14,13 +25,12 @@ const API = { clearTest(state) { state.test = {}; } - }, - actions: {}, - getters: {} + } } export default new Vuex.Store({ modules: { - api: API + api: API, + common: Common } }) diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 74c3a8e4f3..0b70465466 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -4,6 +4,7 @@ export default { 'organization': 'Organization', 'setting': 'Setting', 'project': 'Project', + current_project: 'Current Project', 'name': 'Name', 'description': 'Description', 'clear': 'Clear', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index cc3d490d2d..977c36a7bf 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -4,6 +4,7 @@ export default { 'organization': '组织', 'setting': '设置', 'project': '项目', + current_project: '当前项目', 'name': '名称', 'description': '描述', 'clear': '清空', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 2ff1e2058e..db7a0fb7c4 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -4,6 +4,7 @@ export default { 'organization': '組織', 'setting': '設置', 'project': '項目', + current_project: '當前項目', 'name': '名稱', 'description': '描述', 'clear': '清空',