store.ts 1.1 KB

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