From 467cb238468ebbf938121c5ce56fd7f501ff550a Mon Sep 17 00:00:00 2001 From: Red-Asuka Date: Mon, 25 Nov 2024 15:57:53 +0800 Subject: [PATCH] feat(theme): add support for night theme in Element Plus and streamline settings UI --- apps/desktop/electron.vite.config.ts | 10 +++++ apps/web/components.d.ts | 2 - apps/web/vite.config.ts | 10 +++++ packages/ui/src/components/SettingsView.vue | 49 ++++----------------- packages/ui/src/stores/useSettingsStore.ts | 6 +-- packages/ui/src/styles/variable.scss | 19 ++++---- 6 files changed, 42 insertions(+), 54 deletions(-) diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts index 6a9bc75fa..360a55bd9 100644 --- a/apps/desktop/electron.vite.config.ts +++ b/apps/desktop/electron.vite.config.ts @@ -78,6 +78,16 @@ export default defineConfig({ custom: FileSystemIconLoader('../../packages/ui/src/assets/icons'), }, }), + { + name: 'element-plus-night-theme', + transform(code, id) { + if (id.endsWith('packages/ui/src/styles/index.scss')) { + const nightThemeCode = code.replace(/html\.dark/g, 'html.night') + return `${code}\n${nightThemeCode}` + } + return code + }, + }, ], css: { preprocessorOptions: { diff --git a/apps/web/components.d.ts b/apps/web/components.d.ts index 1cb8d54af..4e094ce5e 100644 --- a/apps/web/components.d.ts +++ b/apps/web/components.d.ts @@ -21,7 +21,6 @@ declare module 'vue' { ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] ElContainer: typeof import('element-plus/es')['ElContainer'] ElDivider: typeof import('element-plus/es')['ElDivider'] - ElIcon: typeof import('element-plus/es')['ElIcon'] ElIconDelete: typeof import('@element-plus/icons-vue')['Delete'] ElIconPrinter: typeof import('@element-plus/icons-vue')['Printer'] ElIconUpload: typeof import('@element-plus/icons-vue')['Upload'] @@ -34,7 +33,6 @@ declare module 'vue' { ElSelect: typeof import('element-plus/es')['ElSelect'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] - Help: typeof import('./../../packages/ui/src/components/Help.vue')['default'] HelpView: typeof import('./../../packages/ui/src/components/HelpView.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index ae2fb2550..32a46442c 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -64,6 +64,16 @@ export default defineConfig({ custom: FileSystemIconLoader('../../packages/ui/src/assets/icons'), }, }), + { + name: 'element-plus-night-theme', + transform(code, id) { + if (id.endsWith('packages/ui/src/styles/index.scss')) { + const nightThemeCode = code.replace(/html\.dark/g, 'html.night') + return `${code}\n${nightThemeCode}` + } + return code + }, + }, ], resolve: { alias: { diff --git a/packages/ui/src/components/SettingsView.vue b/packages/ui/src/components/SettingsView.vue index b6348354d..dbf713799 100644 --- a/packages/ui/src/components/SettingsView.vue +++ b/packages/ui/src/components/SettingsView.vue @@ -102,11 +102,7 @@ const AImodelsOptions = [ - + @@ -117,7 +113,6 @@ const AImodelsOptions = [ @@ -127,11 +122,7 @@ const AImodelsOptions = [ - + @@ -142,7 +133,7 @@ const AImodelsOptions = [ @@ -152,11 +143,7 @@ const AImodelsOptions = [ - + @@ -189,7 +176,6 @@ const AImodelsOptions = [ @@ -199,11 +185,7 @@ const AImodelsOptions = [ - + @@ -235,7 +217,6 @@ const AImodelsOptions = [