fix(ui): 彻底修复深浅色主题切换及内部页面样式
- 恢复 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:
+10
-24
@@ -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'}`,
|
||||
|
||||
Reference in New Issue
Block a user