feat: 国际化功能基础实现

This commit is contained in:
alger
2025-01-23 11:02:55 +08:00
parent 599b0251af
commit 174428b386
14 changed files with 189 additions and 17 deletions

View File

@@ -2,6 +2,7 @@ import { electronApp, optimizer } from '@electron-toolkit/utils';
import { app, ipcMain, nativeImage } from 'electron';
import { join } from 'path';
import i18n from '../i18n/main';
import { loadLyricWindow } from './lyric';
import { initializeConfig } from './modules/config';
import { initializeFileManager } from './modules/fileManager';
@@ -95,6 +96,13 @@ if (!isSingleInstance) {
registerShortcuts(mainWindow);
});
// 监听语言切换
ipcMain.on('change-language', (_, locale) => {
i18n.global.locale = locale;
// 通知所有窗口语言已更改
mainWindow?.webContents.send('language-changed', locale);
});
// 所有窗口关闭时的处理
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {

View File

@@ -23,6 +23,7 @@ type SetConfig = {
musicQuality: string;
fontFamily: string;
fontScope: 'global' | 'lyric';
language: string;
};
interface StoreType {
set: SetConfig;

View File

@@ -18,5 +18,6 @@
"fontFamily": "system-ui",
"fontScope": "global",
"autoPlay": false,
"downloadPath": ""
"downloadPath": "",
"language": "zh-CN"
}