From 3ce9735cda99cf32232121dc0fe8d3393780bbec Mon Sep 17 00:00:00 2001 From: Yuhang Wu Date: Tue, 25 Aug 2026 09:31:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=B7=B1=E8=89=B2?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=94=AF=E6=8C=81=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=A4=96=E8=A7=82=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增全局深色主题样式变量,适配明暗两种主题 2. 配置naive-ui主题切换,跟随系统或用户设置 3. 修复外观设置页面主题同步逻辑 4. 调整主布局样式,使用css变量适配主题和标题栏高度 --- src/App.vue | 32 ++++++++++++++++++++++++++++++-- src/assets/global.css | 17 +++++++++++++++++ src/layout/MainLayout.vue | 10 +++++++--- src/views/setting/Appearance.vue | 4 ++++ 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 6b44b0f..262c44e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,9 @@ diff --git a/src/assets/global.css b/src/assets/global.css index d84c341..7aec021 100644 --- a/src/assets/global.css +++ b/src/assets/global.css @@ -31,4 +31,21 @@ --set-item-title-size: 14px; --set-item-desc-size: 12px; +} + +/* 深色主题:通过根节点 data-theme="dark" 覆盖同名变量 */ +:root[data-theme="dark"] { + --color-window-bg: #1b1c20; + --color-surface: #26272e; + --color-surface-hover: #30323b; + + --color-text-primary: #f0f1f5; + --color-text-secondary: #9aa0ab; + --color-text-invert: #1d1d1f; + + --color-border: rgba(255, 255, 255, 0.08); + --color-border-hover: rgba(102, 126, 234, 0.5); + --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35); + --shadow-card-hover: 0 10px 28px rgba(0, 0, 0, 0.5); + --shadow-focus: 0 4px 16px rgba(102, 126, 234, 0.3); } \ No newline at end of file diff --git a/src/layout/MainLayout.vue b/src/layout/MainLayout.vue index 92650f0..61c7a3f 100644 --- a/src/layout/MainLayout.vue +++ b/src/layout/MainLayout.vue @@ -23,9 +23,13 @@ const isMacos = navigator.userAgent.includes("Mac OS X") .container { width: 100vw; height: 100vh; - background: rgba(255, 255, 255, 1); + background: var(--color-window-bg); backdrop-filter: blur(20px); - border: 1px solid rgba(255, 255, 255, 0.2); + border: 1px solid var(--color-border); + + :deep(.n-layout) { + background: transparent; + } } .header { @@ -35,6 +39,6 @@ const isMacos = navigator.userAgent.includes("Mac OS X") .content { background: transparent; - height: calc(100vh - 40px); + height: calc(100vh - var(--titlebar-height)); } diff --git a/src/views/setting/Appearance.vue b/src/views/setting/Appearance.vue index b60680b..828a854 100644 --- a/src/views/setting/Appearance.vue +++ b/src/views/setting/Appearance.vue @@ -38,6 +38,10 @@ const settingStore = useSettingStore() const theme = ref(settingStore.appearance.theme) const showShadow = ref(settingStore.appearance.showShadow) +watch(theme, (newVal) => { + settingStore.appearance.theme = newVal +}) + watch(showShadow, (newVal) => { settingStore.appearance.showShadow = newVal getCurrentWindow().setShadow(newVal)