mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-18 10:40:50 +08:00
refactor(app): modularize UI and usage logic
This commit is contained in:
26
src/modules/language.js
Normal file
26
src/modules/language.js
Normal file
@@ -0,0 +1,26 @@
|
||||
export const languageModule = {
|
||||
setupLanguageSwitcher() {
|
||||
const loginToggle = document.getElementById('language-toggle');
|
||||
const mainToggle = document.getElementById('language-toggle-main');
|
||||
|
||||
if (loginToggle) {
|
||||
loginToggle.addEventListener('click', () => this.toggleLanguage());
|
||||
}
|
||||
if (mainToggle) {
|
||||
mainToggle.addEventListener('click', () => this.toggleLanguage());
|
||||
}
|
||||
},
|
||||
|
||||
toggleLanguage() {
|
||||
const currentLang = i18n.currentLanguage;
|
||||
const newLang = currentLang === 'zh-CN' ? 'en-US' : 'zh-CN';
|
||||
i18n.setLanguage(newLang);
|
||||
|
||||
this.updateThemeButtons();
|
||||
this.updateConnectionStatus();
|
||||
|
||||
if (this.isLoggedIn && this.isConnected) {
|
||||
this.loadAllData(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user