编辑国家 获取地区国家
This commit is contained in:
@@ -151,9 +151,10 @@ export const useCountryStore = defineStore('country', () => {
|
|||||||
/**
|
/**
|
||||||
* 显示编辑国家的弹窗
|
* 显示编辑国家的弹窗
|
||||||
* @param {Function} t - 国际化函数
|
* @param {Function} t - 国际化函数
|
||||||
|
* @returns {Promise} 确认时 resolve 新的国家名称,取消时 reject
|
||||||
*/
|
*/
|
||||||
const showEditCountryDialog = (t) => {
|
const showEditCountryDialog = (t) => {
|
||||||
ElMessageBox.prompt(
|
return ElMessageBox.prompt(
|
||||||
t('workbenchesSetup.editCountryPrompt') || t('hostsList.editCountryPrompt') || '请输入国家名称(中文)',
|
t('workbenchesSetup.editCountryPrompt') || t('hostsList.editCountryPrompt') || '请输入国家名称(中文)',
|
||||||
t('workbenchesSetup.editCountryTitle') || t('hostsList.editCountryTitle') || '编辑国家',
|
t('workbenchesSetup.editCountryTitle') || t('hostsList.editCountryTitle') || '编辑国家',
|
||||||
{
|
{
|
||||||
@@ -170,8 +171,7 @@ export const useCountryStore = defineStore('country', () => {
|
|||||||
}
|
}
|
||||||
).then(({ value }) => {
|
).then(({ value }) => {
|
||||||
setCountryManually(value, t)
|
setCountryManually(value, t)
|
||||||
}).catch(() => {
|
return value.trim() // 返回新的国家名称
|
||||||
// 用户取消编辑
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -437,8 +437,16 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 编辑国家信息 - 使用共享 store
|
// 编辑国家信息 - 使用共享 store
|
||||||
const editCountry = () => {
|
const editCountry = async () => {
|
||||||
countryStore.showEditCountryDialog(t);
|
try {
|
||||||
|
const newCountry = await countryStore.showEditCountryDialog(t);
|
||||||
|
// 确认后获取该国家的列表
|
||||||
|
if (newCountry) {
|
||||||
|
fetchCountryList(newCountry);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 用户取消编辑
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 刷新国家信息 - 使用共享 store
|
// 刷新国家信息 - 使用共享 store
|
||||||
|
|||||||
Reference in New Issue
Block a user