From 75f0cac7bbc55b3778f3e6a2244c4094e65ca32b Mon Sep 17 00:00:00 2001 From: Hu Gang <18768366022@163.com> Date: Tue, 15 Apr 2025 14:23:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E5=BC=80=E5=8F=91=E8=80=85=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/prod/Dockerfile | 2 +- electron/main/common/conf.ts | 2 +- electron/main/common/constants.ts | 8 ++++++++ electron/main/window/create.ts | 7 ++++++- src/store/lang.ts | 2 ++ vite.config.ts | 1 + 6 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 electron/main/common/constants.ts diff --git a/deploy/prod/Dockerfile b/deploy/prod/Dockerfile index a01ebb90..8941a4a2 100644 --- a/deploy/prod/Dockerfile +++ b/deploy/prod/Dockerfile @@ -23,7 +23,7 @@ RUN sed -i 's|repo.openeuler.org|mirrors.nju.edu.cn/openeuler|g' /etc/yum.repos. useradd -m -u 1001 -g eulercopilot -s /sbin/nologin eulercopilot && \ passwd -l eulercopilot -COPY --from=0 /opt/eulerCopilot-web/dist /usr/share/nginx/html +COPY --from=0 /opt/eulerCopilot-web/dist/render /usr/share/nginx/html COPY --from=0 /opt/eulerCopilot-web/public /usr/share/nginx/html COPY --from=0 /opt/eulerCopilot-web/deploy/prod/nginx.conf.tmpl /home/eulercopilot/nginx.conf.tmpl COPY --from=0 /opt/eulerCopilot-web/deploy/prod/start.sh /home/eulercopilot/start.sh diff --git a/electron/main/common/conf.ts b/electron/main/common/conf.ts index 5f4c99ef..d5ce45ff 100644 --- a/electron/main/common/conf.ts +++ b/electron/main/common/conf.ts @@ -14,7 +14,7 @@ import { productObj } from './product'; interface ICacheConf { theme: 'system' | 'light' | 'dark'; - userLocale; + userLocale: string; } export const userDataPath = getUserDataPath(productObj.name); diff --git a/electron/main/common/constants.ts b/electron/main/common/constants.ts new file mode 100644 index 00000000..859ab7b1 --- /dev/null +++ b/electron/main/common/constants.ts @@ -0,0 +1,8 @@ +const THEME_COLOR_MAP = { + 'dark': '#1f2329', + 'light': '#ffffff' +} + +export { + THEME_COLOR_MAP +} \ No newline at end of file diff --git a/electron/main/window/create.ts b/electron/main/window/create.ts index 1f29b725..87c4bf10 100644 --- a/electron/main/window/create.ts +++ b/electron/main/window/create.ts @@ -13,6 +13,7 @@ import { BrowserWindow, app, globalShortcut, ipcMain } from 'electron'; import { options as allWindow } from './options'; import { updateConf } from '../common/conf'; import { isLinux } from '../common/platform'; +import {THEME_COLOR_MAP} from '../common/constants' // 存储所有创建的窗口实例,用于全局访问 const windowInstances: Map = new Map(); @@ -22,12 +23,16 @@ export function createWindow( hash: string, id?: string, ): BrowserWindow { + const theme = process.env['EULERCOPILOT_THEME'] || 'light'; + const backgroundColor = THEME_COLOR_MAP[theme] || '#ffffff'; const win = new BrowserWindow({ ...options, + backgroundColor, webPreferences: { nodeIntegration: true, contextIsolation: false, preload: path.join(__dirname, '../preload/index.js'), + devTools: !app.isPackaged, }, }); @@ -37,7 +42,7 @@ export function createWindow( } if (app.isPackaged) { - win.loadFile(path.join(__dirname, `../index.html`), { hash }); + win.loadFile(path.join(__dirname, `../render/index.html`), { hash }); } else { win.loadURL(`http://localhost:${process.env.PORT}/#${hash}`); } diff --git a/src/store/lang.ts b/src/store/lang.ts index ef1f1796..cde209bc 100644 --- a/src/store/lang.ts +++ b/src/store/lang.ts @@ -23,6 +23,8 @@ export const useLangStore = defineStore('lang', () => { electronProcess.env['EULERCOPILOT_NLS_CONFIG'] && changeLanguage(nlsConfig.userLocale); + } else { + changeLanguage(language.value as 'zh_cn' | 'en'); } }); return { diff --git a/vite.config.ts b/vite.config.ts index 4e3ead95..90e864ce 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -38,6 +38,7 @@ export default ({ mode }): UserConfigExport => { }), ], build: { + outDir: 'dist/render', rollupOptions: { output: { manualChunks(id) { -- Gitee