| | |
| | | const themeModeOptions = [ |
| | | { label: "亮色模式", value: "light" }, |
| | | { label: "暗色模式", value: "dark" }, |
| | | { label: "定制模式", value: "custom" }, |
| | | { label: "跟随系统", value: "auto" } |
| | | ]; |
| | | |
| | | const defaultTheme: any = localStorage.getItem("arco-theme") || "auto"; |
| | | |
| | | const currentTheme = ref<"light" | "dark">(defaultTheme); |
| | | const currentThemeMode = ref<"light" | "dark" | "auto">(defaultTheme); |
| | | const currentThemeMode = ref<"light" | "dark" | "auto" | "custom">(defaultTheme); |
| | | |
| | | export const useTheme = () => { |
| | | //设置自动主题模式 |
| | |
| | | }; |
| | | |
| | | //设置手动主题模式 |
| | | const setManualTheme = (v: "light" | "dark") => { |
| | | const setManualTheme = (v: "light" | "dark" | "custom") => { |
| | | localStorage.setItem("arco-theme", v); |
| | | currentThemeMode.value = v; |
| | | currentTheme.value = v; |
| | |
| | | darkModeQuery.addListener(setAutoTheme); |
| | | |
| | | //用于处理手动切换主题 |
| | | const handleThemeChange = (v: "light" | "dark" | "auto") => { |
| | | const handleThemeChange = (v: "light" | "dark" | "auto" | "custom") => { |
| | | if (v === "auto") { |
| | | currentThemeMode.value = "auto"; |
| | | setAutoTheme(); |