adopt CYBER neon-dark theme tokens
Replace the Pure Ink light/dark/comic theme system with the CYBER single-theme dark palette from the reviewed prototype: OKLCH surfaces, one neon-cyan accent, and monospace-first typography. Arco components were reading colors from arco.css because no ConfigProvider was mounted, so the theme values in arco-theme.ts never took effect. Bridge CYBER into Arco through its --color-* variables in global.scss instead, and align arco-theme.ts to match. Brightness and style switches are gone: useTheme now pins dark, the comic font faces and locale keys are removed, and ThemeSwitch.vue is deleted along with its sidebar slot and display setting.
This commit is contained in:
@@ -1,91 +1,28 @@
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
export type BrightnessMode = 'light' | 'dark' | 'system'
|
||||
export type ThemeStyle = 'ink' | 'comic'
|
||||
// CYBER 是单色暗色主题:亮度与风格切换器已移除(comic 与 light 主题不再提供)。
|
||||
// 这里保留 isDark 以兼容 App.vue / JourneyView 里的 :class 绑定,值恒为 true。
|
||||
const isDark = ref(true)
|
||||
|
||||
const BRIGHTNESS_KEY = 'hermes_brightness'
|
||||
const STYLE_KEY = 'hermes_style'
|
||||
export type BrightnessMode = 'dark'
|
||||
|
||||
const brightness = ref<BrightnessMode>(
|
||||
(localStorage.getItem(BRIGHTNESS_KEY) as BrightnessMode) || 'system',
|
||||
)
|
||||
const brightness = ref<BrightnessMode>('dark')
|
||||
|
||||
const style = ref<ThemeStyle>(
|
||||
(localStorage.getItem(STYLE_KEY) as ThemeStyle) || 'ink',
|
||||
)
|
||||
|
||||
const isDark = ref(false)
|
||||
const isComic = ref(false)
|
||||
|
||||
function resolveDark(b: BrightnessMode): boolean {
|
||||
if (b === 'system') {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
}
|
||||
return b === 'dark'
|
||||
}
|
||||
|
||||
function applyClasses() {
|
||||
const dark = resolveDark(brightness.value)
|
||||
isDark.value = dark
|
||||
isComic.value = style.value === 'comic'
|
||||
document.documentElement.classList.toggle('dark', dark)
|
||||
document.documentElement.classList.toggle('comic', isComic.value)
|
||||
// Arco Design dark theme mechanism (Phase 005)
|
||||
document.documentElement.setAttribute('arco-theme', dark ? 'dark' : 'light')
|
||||
}
|
||||
|
||||
// Initial
|
||||
applyClasses()
|
||||
|
||||
// Listen for system preference changes
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
||||
if (brightness.value === 'system') {
|
||||
applyClasses()
|
||||
}
|
||||
})
|
||||
|
||||
// Persist & apply on change
|
||||
watch(brightness, (b) => {
|
||||
localStorage.setItem(BRIGHTNESS_KEY, b)
|
||||
applyClasses()
|
||||
})
|
||||
|
||||
watch(style, (s) => {
|
||||
localStorage.setItem(STYLE_KEY, s)
|
||||
applyClasses()
|
||||
})
|
||||
// 固定应用暗色:Arco 的 token 通过 arco-theme 属性切换,项目的令牌写在 :root。
|
||||
document.documentElement.setAttribute('arco-theme', 'dark')
|
||||
|
||||
export function useTheme() {
|
||||
const themeName = computed(() => {
|
||||
const b = isDark.value ? 'dark' : 'light'
|
||||
return isComic.value ? `comic-${b}` : b
|
||||
})
|
||||
const themeName = computed(() => 'dark')
|
||||
|
||||
function setBrightness(b: BrightnessMode) {
|
||||
brightness.value = b
|
||||
}
|
||||
|
||||
function setStyle(s: ThemeStyle) {
|
||||
style.value = s
|
||||
}
|
||||
|
||||
function toggleBrightness() {
|
||||
brightness.value = isDark.value ? 'light' : 'dark'
|
||||
}
|
||||
|
||||
function toggleStyle() {
|
||||
style.value = isComic.value ? 'ink' : 'comic'
|
||||
function setBrightness(_b: BrightnessMode) {
|
||||
// 单主题:忽略任何切换请求。
|
||||
brightness.value = 'dark'
|
||||
}
|
||||
|
||||
return {
|
||||
brightness,
|
||||
style,
|
||||
isDark,
|
||||
isComic,
|
||||
themeName,
|
||||
setBrightness,
|
||||
setStyle,
|
||||
toggleBrightness,
|
||||
toggleStyle,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user