diff --git a/frontend/src/pages/Chat.tsx b/frontend/src/pages/Chat.tsx index ce354f8..f6434dd 100644 --- a/frontend/src/pages/Chat.tsx +++ b/frontend/src/pages/Chat.tsx @@ -149,8 +149,8 @@ const ChatMessageItem: FC<{ className={classnames( 'flex p-2 rounded-lg overflow-hidden', editing ? 'grow' : '', - messageItem.side === 'left' ? 'bg-gray-200' : 'bg-blue-500', - messageItem.side === 'left' ? 'text-gray-600' : 'text-white' + commonStore.settings.darkMode ? 'bg-neutral-800 border-neutral-600 border-[1px]' : (messageItem.side === 'left' ? 'bg-gray-200' : 'bg-blue-500'), + commonStore.settings.darkMode ? 'text-white' : (messageItem.side === 'left' ? 'text-gray-600' : 'text-white') )} > {!editing ? diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index de0100c..5fc3414 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -81,6 +81,7 @@ async function initConfig() { }).catch(() => { commonStore.setModelConfigs(commonStore.platform !== 'darwin' ? defaultModelConfigs : defaultModelConfigsMac, true); }); + commonStore.setSettings({}, false); // to activate side effects } async function initCache(initUnfinishedModels: boolean) { diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index d7e6cf8..06bce6f 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -259,13 +259,18 @@ class CommonStore { setSettings = (value: Partial, saveConfig: boolean = true) => { this.settings = { ...this.settings, ...value }; - if (this.settings.darkMode) + if (this.settings.darkMode) { WindowSetDarkTheme(); - else + document.documentElement.setAttribute('style', 'color-scheme: dark;'); + } else { WindowSetLightTheme(); + document.documentElement.setAttribute('style', 'color-scheme: light;'); + } - if (this.settings.language) + if (this.settings.language) { i18n.changeLanguage(this.settings.language); + document.documentElement.setAttribute('lang', this.settings.language === 'dev' ? 'en' : this.settings.language); + } if (saveConfig) saveConfigs(); diff --git a/frontend/src/webWails.js b/frontend/src/webWails.js index c311584..acf2ce4 100644 --- a/frontend/src/webWails.js +++ b/frontend/src/webWails.js @@ -127,7 +127,11 @@ if (!window.go) { return '' }) defineApp('ReadJson', async (fileName) => { - return JSON.parse(localStorage.getItem(fileName)) + const data = JSON.parse(localStorage.getItem(fileName)) + if (data) + return data + else + throw new Error('File not found') }) defineApp('SaveJson', async (fileName, data) => { localStorage.setItem(fileName, JSON.stringify(data))