From 3d1a6f3870ad424e9483739e58b1d7e2e5fad362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=A1=E5=A4=8D=E4=B9=A0?= <2353956224@qq.com> Date: Mon, 9 Mar 2026 16:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=9B=BD=E5=AE=B6=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9C=B0=E5=8C=BA=E5=9B=BD=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/countryStore.js | 6 +++--- src/views/tk/Workbenches.vue | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/stores/countryStore.js b/src/stores/countryStore.js index 2da3c95..713759f 100644 --- a/src/stores/countryStore.js +++ b/src/stores/countryStore.js @@ -151,9 +151,10 @@ export const useCountryStore = defineStore('country', () => { /** * 显示编辑国家的弹窗 * @param {Function} t - 国际化函数 + * @returns {Promise} 确认时 resolve 新的国家名称,取消时 reject */ const showEditCountryDialog = (t) => { - ElMessageBox.prompt( + return ElMessageBox.prompt( t('workbenchesSetup.editCountryPrompt') || t('hostsList.editCountryPrompt') || '请输入国家名称(中文)', t('workbenchesSetup.editCountryTitle') || t('hostsList.editCountryTitle') || '编辑国家', { @@ -170,8 +171,7 @@ export const useCountryStore = defineStore('country', () => { } ).then(({ value }) => { setCountryManually(value, t) - }).catch(() => { - // 用户取消编辑 + return value.trim() // 返回新的国家名称 }) } diff --git a/src/views/tk/Workbenches.vue b/src/views/tk/Workbenches.vue index 094164b..9cb4809 100644 --- a/src/views/tk/Workbenches.vue +++ b/src/views/tk/Workbenches.vue @@ -437,8 +437,16 @@ onMounted(async () => { }) // 编辑国家信息 - 使用共享 store -const editCountry = () => { - countryStore.showEditCountryDialog(t); +const editCountry = async () => { + try { + const newCountry = await countryStore.showEditCountryDialog(t); + // 确认后获取该国家的列表 + if (newCountry) { + fetchCountryList(newCountry); + } + } catch { + // 用户取消编辑 + } }; // 刷新国家信息 - 使用共享 store