feat: 实现已确认的登录、采集和任务导出
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
export type ThemeChoice = "system" | "dark" | "light";
|
||||
|
||||
const STORAGE_KEY = "decom-theme";
|
||||
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
export const themeChoice = ref<ThemeChoice>(stored === "dark" || stored === "light" || stored === "system" ? stored : "system");
|
||||
const systemDark = ref(media.matches);
|
||||
|
||||
media.addEventListener("change", () => {
|
||||
systemDark.value = media.matches;
|
||||
});
|
||||
|
||||
export const isDark = computed(() => {
|
||||
if (themeChoice.value === "dark") return true;
|
||||
if (themeChoice.value === "light") return false;
|
||||
return systemDark.value;
|
||||
});
|
||||
|
||||
export function setThemeChoice(choice: ThemeChoice) {
|
||||
themeChoice.value = choice;
|
||||
localStorage.setItem(STORAGE_KEY, choice);
|
||||
}
|
||||
Reference in New Issue
Block a user