mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-18 10:40:50 +08:00
feat: centralize config refresh handling and prevent races
This commit is contained in:
@@ -209,7 +209,9 @@ export const configEditorModule = {
|
||||
this.showNotification(i18n.t('config_management.save_success'), 'success');
|
||||
this.updateConfigEditorStatus('success', i18n.t('config_management.status_saved'));
|
||||
this.clearCache();
|
||||
await this.loadAllData(true);
|
||||
if (this.events && typeof this.events.emit === 'function') {
|
||||
this.events.emit('config:refresh-requested', { forceRefresh: true });
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = `${i18n.t('config_management.status_save_failed')}: ${error.message}`;
|
||||
this.updateConfigEditorStatus('error', errorMessage);
|
||||
|
||||
@@ -12,6 +12,11 @@ export const languageModule = {
|
||||
},
|
||||
|
||||
toggleLanguage() {
|
||||
if (this.isLanguageRefreshInProgress) {
|
||||
return;
|
||||
}
|
||||
this.isLanguageRefreshInProgress = true;
|
||||
|
||||
const currentLang = i18n.currentLanguage;
|
||||
const newLang = currentLang === 'zh-CN' ? 'en-US' : 'zh-CN';
|
||||
i18n.setLanguage(newLang);
|
||||
@@ -19,8 +24,13 @@ export const languageModule = {
|
||||
this.updateThemeButtons();
|
||||
this.updateConnectionStatus();
|
||||
|
||||
if (this.isLoggedIn && this.isConnected) {
|
||||
this.loadAllData(true);
|
||||
if (this.isLoggedIn && this.isConnected && this.events && typeof this.events.emit === 'function') {
|
||||
this.events.emit('config:refresh-requested', { forceRefresh: true });
|
||||
}
|
||||
|
||||
// 简单释放锁,避免短时间内的重复触发
|
||||
setTimeout(() => {
|
||||
this.isLanguageRefreshInProgress = false;
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user