feat: 后台语言包合并默认中文、日夜主题切换、官方侧栏收缩、追溯码分组与批量
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'auto';
|
||||
const KEY = 'artveris_theme';
|
||||
|
||||
const media = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
const systemDark = ref(media.matches);
|
||||
media.addEventListener('change', (e) => (systemDark.value = e.matches));
|
||||
|
||||
const mode = ref<ThemeMode>((localStorage.getItem(KEY) as ThemeMode) || 'light');
|
||||
|
||||
const isDark = computed(() => mode.value === 'dark' || (mode.value === 'auto' && systemDark.value));
|
||||
|
||||
function setMode(m: ThemeMode): void {
|
||||
mode.value = m;
|
||||
localStorage.setItem(KEY, m);
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
return { mode, isDark, setMode };
|
||||
}
|
||||
Reference in New Issue
Block a user