store.js 1.1 KB

12345678910111213141516171819202122232425
  1. import { writable } from 'svelte/store';
  2. export const isShowNavStore = writable(false);
  3. // 文档 theme 模式,dark、light、auto。
  4. export const themeStore = writable(localStorage.getItem('theme') || 'auto');
  5. // 系统 theme 模式,dark、light
  6. export const sysThemeStore = writable(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
  7. // 当前 theme 模式,dark、light
  8. const currentTheme =
  9. (localStorage.getItem('theme') || 'auto') === 'auto'
  10. ? window.matchMedia('(prefers-color-scheme: dark)').matches
  11. ? 'dark'
  12. : 'light'
  13. : localStorage.getItem('theme') || 'auto';
  14. export const currentThemeStore = writable(currentTheme);
  15. // 是否开启cmdK
  16. export const isCmdKStore = writable(false);
  17. // 是否显示赞赏
  18. export const isShowFundStore = writable(false);
  19. // 当前主题色
  20. export const currentColorStore = writable(localStorage.getItem('theme_color') || 'STDF');
  21. // 显示主题色选择器
  22. export const showThemeSwitchStore = writable(false);
  23. // 宽屏显示还是窄屏显示
  24. export const isWideScreenStore = writable(localStorage.getItem('isFull') && localStorage.getItem('isFull') === 'full');