fix(ui): 彻底修复深浅色主题切换及内部页面样式
构建并部署 BYW VoiceHub / Preflight 语法与构建检查 (push) Successful in 2m12s
构建并部署 BYW VoiceHub / 构建并推送容器镜像 (push) Successful in 10m17s
构建并部署 BYW VoiceHub / 部署到生产服务器 (push) Successful in 6s

- 恢复 variables.css 完整的 ClassicDark/ModernDark 等主题定义
- 恢复 nuxt.config.ts 的主题系统逻辑(默认改为 ClassicLight,保留切换能力)
- 修复 BackupManager / VotersModal / ProfileForm / LyricsModal / RequestForm / SongList / ScheduleList / StatsSlide / ArtistSlide 等数十处组件内部硬编码深色(#1a1a1a / #040e15 等)绕过主题的问题,全部改为使用 CSS 变量 (var(--bg-primary) 等)
- 这样实现了:在浅色模式下,所有页面均正确显示浅色;在深色模式下,又能正常呈现深色设计,且恢复了右上角的深浅色切换能力
This commit is contained in:
2026-09-12 15:23:26 +08:00
parent b1c3af84de
commit 8b0934f6f4
11 changed files with 77 additions and 109 deletions
+36 -54
View File
@@ -1,13 +1,10 @@
/* 全局CSS变量 - 统一配色方案(默认浅色ClassicLight,不依赖data-theme也能正常显示) */
/* 全局CSS变量 - 统一配色方案 */
:root {
/* 强制浅色基准值 - 即使 data-theme 缺失也保持浅色 */
color-scheme: light;
/* 主色调 */
--primary: #1e40af;
--primary-hover: #1e3a8a;
--primary-light: rgba(30, 64, 175, 0.08);
--primary-border: rgba(30, 64, 175, 0.15);
--primary: #3b82f6;
--primary-hover: #2563eb;
--primary-light: rgba(59, 130, 246, 0.1);
--primary-border: rgba(59, 130, 246, 0.2);
/* 成功色 */
--success: #10b981;
@@ -33,25 +30,25 @@
--info-light: rgba(59, 130, 246, 0.1);
--info-border: rgba(59, 130, 246, 0.2);
/* 背景色 (默认 ClassicLight 浅色) */
--bg-primary: #ffffff;
--bg-secondary: #f5f7fa;
--bg-tertiary: #edf0f5;
--bg-quaternary: #d9dee7;
--bg-hover: #f0f3f8;
/* 背景色 */
--bg-primary: #111111;
--bg-secondary: #1a1a1a;
--bg-tertiary: #2a2a2a;
--bg-quaternary: #3a3a3a;
--bg-hover: #1f1f1f;
/* 文字颜色 (默认 ClassicLight 浅色) */
--text-primary: #1a2332;
--text-secondary: #4a5568;
--text-tertiary: #6b7280;
--text-quaternary: #9ca3af;
--text-disabled: #c5cbd3;
/* 文字颜色 */
--text-primary: #ffffff;
--text-secondary: #cccccc;
--text-tertiary: #888888;
--text-quaternary: #666666;
--text-disabled: #444444;
/* 边框颜色 (默认 ClassicLight 浅色) */
--border-primary: #e5e7eb;
--border-secondary: #d1d5db;
--border-tertiary: #9ca3af;
--border-quaternary: #6b7280;
/* 边框颜色 */
--border-primary: #1f1f1f;
--border-secondary: #2a2a2a;
--border-tertiary: #3a3a3a;
--border-quaternary: #4a4a4a;
/* 阴影 */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
@@ -135,16 +132,16 @@
--card-hover-border: var(--border-tertiary);
--card-shadow: var(--shadow-md);
/* 按钮颜色 - 浅色基准 */
/* 按钮颜色 */
--btn-primary-bg: var(--primary);
--btn-primary-hover: var(--primary-hover);
--btn-primary-text: #ffffff;
--btn-primary-text: var(--text-primary);
--btn-primary-border: var(--primary-border);
--btn-secondary-bg: #f1f5f9;
--btn-secondary-hover: #e2e8f0;
--btn-secondary-text: #0f172a;
--btn-secondary-border: #cbd5e1;
--btn-secondary-bg: #3a3a3a;
--btn-secondary-hover: #4a4a4a;
--btn-secondary-text: var(--text-primary);
--btn-secondary-border: #555555;
--btn-success-bg: var(--success);
--btn-success-hover: var(--success-hover);
@@ -164,12 +161,12 @@
--btn-disabled-bg: var(--bg-tertiary);
--btn-disabled-text: var(--text-disabled);
/* 输入框颜色 - 浅色基准 */
--input-bg: #ffffff;
--input-border: #d1d5db;
/* 输入框颜色 */
--input-bg: var(--bg-tertiary);
--input-border: var(--border-tertiary);
--input-border-focus: var(--primary);
--input-text: var(--text-primary);
--input-placeholder: #9ca3af;
--input-placeholder: var(--text-quaternary);
--input-shadow-focus: 0 0 0 3px var(--primary-light);
/* 模态框颜色 */
@@ -200,27 +197,12 @@
--spinner-primary: var(--primary);
--spinner-secondary: var(--bg-tertiary);
/* 滚动条颜色 - 浅色基准 */
--scrollbar-track: #f1f5f9;
--scrollbar-thumb: #cbd5e1;
--scrollbar-thumb-hover: #94a3b8;
/* Surface 兼容别名 - 部分按钮/容器使用 surface-xxx */
--surface-primary: var(--bg-primary);
--surface-secondary: var(--bg-secondary);
--surface-tertiary: var(--bg-tertiary);
--surface-quaternary: var(--bg-quaternary);
/* 滚动条颜色 */
--scrollbar-track: var(--bg-tertiary);
--scrollbar-thumb: var(--bg-quaternary);
--scrollbar-thumb-hover: #4a4a4a;
}
/* 防深色兜底:覆盖 prefers-color-scheme: dark 对表单/根元素的自动影响 */
@media (prefers-color-scheme: dark) {
:root {
color-scheme: light;
}
}
/* 浅色主题叠加层(与 data-theme 无关,确保始终为浅色;保留 data-theme 变量覆盖以兼容切换) */
:root,
:root[data-theme='light'],
:root[data-theme='ClassicLight'],
:root[data-theme='ModernLight'] {
+4 -4
View File
@@ -520,8 +520,8 @@ const formatFileSize = (bytes) => {
/* 主容器 */
.backup-manager {
min-height: 100vh;
background: #1a1a1a;
color: #e5e5e5;
background: var(--bg-primary, #1a1a1a);
color: var(--text-primary, #e5e5e5);
padding: 2rem;
position: relative;
}
@@ -535,13 +535,13 @@ const formatFileSize = (bytes) => {
.header h3 {
font-size: 2.5rem;
font-weight: 700;
color: #ffffff;
color: var(--text-primary, #ffffff);
margin: 0 0 1rem 0;
}
.header .description {
font-size: 1.125rem;
color: #a0a0a0;
color: var(--text-secondary, #a0a0a0);
margin: 0;
}
+2 -2
View File
@@ -202,9 +202,9 @@ watch(
}
.modal-content {
background: #1a1a1a;
background: var(--surface-primary, var(--bg-primary, #1a1a1a));
border-radius: 16px;
border: 1px solid #2a2a2a;
border: 1px solid var(--border-primary, #2a2a2a);
width: 100%;
max-width: 500px;
max-height: 80vh;
+7 -7
View File
@@ -224,24 +224,24 @@ const handleUpdateProfile = async () => {
<style scoped>
.custom-select-profile :deep(> .flex) {
padding: 10px 16px;
background-color: #09090b;
border: 1px solid #27272a;
background-color: var(--input-bg, #09090b);
border: 1px solid var(--input-border, #27272a);
border-radius: 0.75rem;
color: #f4f4f5;
color: var(--input-text, #f4f4f5);
font-size: 0.875rem;
line-height: 1.25rem;
height: 46px;
}
.custom-select-profile :deep(> .flex:hover) {
border-color: #3f3f46;
border-color: var(--input-border-focus, #3f3f46);
}
.custom-select-profile :deep(> .border-blue-500\/50) {
border-color: rgba(34, 197, 94, 0.5) !important;
--tw-ring-color: rgba(34, 197, 94, 0.5);
border-color: var(--primary, rgba(34, 197, 94, 0.5)) !important;
--tw-ring-color: var(--primary-light, rgba(34, 197, 94, 0.5));
box-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
background-color: #09090b !important;
background-color: var(--input-bg, #09090b) !important;
}
.custom-select-profile :deep(.text-\[11px\]) {
+6 -6
View File
@@ -3194,14 +3194,14 @@ defineExpose({
}
.search-input {
background: #040e15;
border: 1px solid #242f38;
background: var(--input-bg, #040e15);
border: 1px solid var(--input-border, #242f38);
border-radius: 8px;
padding: 0.6rem 0.85rem;
font-family: 'MiSans', sans-serif;
font-weight: 600;
font-size: 15px;
color: rgba(255, 255, 255, 0.6);
color: var(--input-text, rgba(255, 255, 255, 0.6));
flex: 1;
min-width: 100px; /* 确保输入框不会缩到太小 */
}
@@ -3484,14 +3484,14 @@ defineExpose({
.form-input,
.form-select {
background: #040e15;
border: 1px solid #242f38;
background: var(--input-bg, #040e15);
border: 1px solid var(--input-border, #242f38);
border-radius: 8px;
padding: 0.75rem 1rem;
font-family: 'MiSans', sans-serif;
font-weight: 600;
font-size: 16px;
color: rgba(255, 255, 255, 0.6);
color: var(--input-text, rgba(255, 255, 255, 0.6));
width: 100%;
}
+4 -4
View File
@@ -2188,9 +2188,9 @@ const vRipple = {
.custom-select:focus,
.custom-input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
background: #1a1a20;
border-color: var(--input-border-focus, var(--primary));
box-shadow: var(--input-shadow-focus, 0 0 0 3px rgba(102, 126, 234, 0.1));
background: var(--input-bg, #1a1a20);
}
.btn-icon {
@@ -3168,7 +3168,7 @@ const vRipple = {
/* 日期选择弹窗 */
.date-picker-content {
background: #1a1a1f;
background: var(--surface-primary, var(--bg-primary, #1a1a1f));
border-radius: 20px 20px 0 0;
width: 100%;
max-width: 100%;
+4 -4
View File
@@ -1894,14 +1894,14 @@ const vRipple = {
}
.search-input {
background: #040e15;
border: 1px solid #242f38;
background: var(--input-bg, #040e15);
border: 1px solid var(--input-border, #242f38);
border-radius: 8px;
padding: 0.5rem 1rem;
padding-right: 2.5rem;
font-family: 'MiSans-Demibold', sans-serif;
font-size: 14px;
color: rgba(255, 255, 255, 0.8);
color: var(--input-text, rgba(255, 255, 255, 0.8));
width: 100%;
transition: all 0.2s ease;
}
@@ -2593,7 +2593,7 @@ button:disabled {
}
.semester-dropdown {
background: #1a1a1f;
background: var(--surface-primary, var(--bg-primary, #1a1a1f));
border: none;
border-radius: 12px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
+2 -2
View File
@@ -953,8 +953,8 @@ onUnmounted(() => {
position: relative;
width: 100%;
height: 100%;
background: #000000;
color: #ffffff;
background: var(--bg-primary, #000000);
color: var(--text-primary, #ffffff);
overflow: hidden;
display: flex;
flex-direction: column;
+1 -1
View File
@@ -37,7 +37,7 @@ defineProps({
align-items: center;
justify-content: center;
overflow: hidden;
background-color: #1a0b2e;
background-color: var(--surface-primary, var(--bg-primary, #1a0b2e));
}
.bg-overlay {
+1 -1
View File
@@ -43,7 +43,7 @@ defineProps({
align-items: center;
justify-content: center;
overflow: hidden;
background-color: #030712; /* gray-950 */
background-color: var(--surface-primary, var(--bg-primary, #030712));
}
.bg-gradient {
+10 -24
View File
@@ -194,10 +194,6 @@ export default defineNuxtConfig({
name: 'x-default-theme',
content: process.env.NUXT_PUBLIC_DEFAULT_THEME || 'ClassicLight'
},
{
name: 'x-enabled-themes',
content: process.env.NUXT_PUBLIC_ENABLED_THEMES || 'ClassicLight,ModernLight'
},
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
{ name: 'apple-mobile-web-app-title', content: 'VoiceHub管理' },
@@ -210,28 +206,18 @@ export default defineNuxtConfig({
tagPosition: 'head',
children: [
`(function(){try{`,
` var k='voicehub:theme', d=document, r=d.documentElement, s=null, eff=null, def=null, list=[];`,
` try{`,
` var mt=d.querySelector('meta[name="x-enabled-themes"]');`,
` if(mt && mt.content){list=String(mt.content).split(',').map(function(x){return x.replace(/^\\s+|\\s+$/g,'')}).filter(Boolean)}`,
` }catch(e){list=[]}`,
` try{`,
` var md=d.querySelector('meta[name="x-default-theme"]');`,
` if(md && md.content){def=md.content}`,
` }catch(e){def=null}`,
` if(!def){def='ClassicLight'}`,
` if(list.length===0){list=['ClassicLight','ModernLight']}`,
` function valid(t){`,
` if(list.indexOf(t)!==-1){return t}`,
` if(list.indexOf(def)!==-1){return def}`,
` return list[0]`,
` }`,
` var k='voicehub:theme', d=document, r=d.documentElement, s=null, eff=null;`,
` try{s=localStorage.getItem(k)}catch(e){s=null}`,
` if(!s){s=def}`,
` else{s=valid(s)}`,
` if(typeof s==='string' && (s==='System'||s==='system')){eff=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}`,
` if(!s){`,
` try{`,
` var meta=document.querySelector('meta[name="x-default-theme"]');`,
` if(meta && meta.content){s=meta.content}`,
` }catch(e){s=null}`,
` if(!s){s='ClassicLight'}`,
` }`,
` if(s==='System'||s==='system'){eff=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}`,
` else if(typeof s==='string'){eff=s.endsWith('Dark')||s==='dark'?'dark':(s.endsWith('Light')||s==='light'?'light':s)}`,
` else{eff='light'}`,
` else{eff='dark'}`,
` r.setAttribute('data-theme', (typeof s==='string'?s:eff));`,
` if(eff==='dark'){r.classList.add('dark'); r.classList.remove('light'); r.style.colorScheme='dark'}`,
` else if(eff==='light'){r.classList.add('light'); r.classList.remove('dark'); r.style.colorScheme='light'}`,