responsive.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // 响应式storage
  2. import type { App } from "vue";
  3. import Storage from "responsive-storage";
  4. import { routerArrays } from "@/layout/types";
  5. import { responsiveStorageNameSpace } from "@/config";
  6. export const injectResponsiveStorage = (app: App, config: PlatformConfigs) => {
  7. const nameSpace = responsiveStorageNameSpace();
  8. const configObj = Object.assign(
  9. {
  10. // 国际化 默认中文zh
  11. locale: Storage.getData("locale", nameSpace) ?? {
  12. locale: config.Locale ?? "zh"
  13. },
  14. // layout模式以及主题
  15. layout: Storage.getData("layout", nameSpace) ?? {
  16. layout: config.Layout ?? "vertical",
  17. theme: config.Theme ?? "light",
  18. darkMode: config.DarkMode ?? false,
  19. sidebarStatus: config.SidebarStatus ?? true,
  20. epThemeColor: config.EpThemeColor ?? "#409EFF",
  21. themeColor: config.Theme ?? "light", // 主题色(对应系统配置中的主题色,与theme不同的是它不会受到浅色、深色整体风格切换的影响,只会在手动点击主题色时改变)
  22. overallStyle: config.OverallStyle ?? "light" // 整体风格(浅色:light、深色:dark、自动:system)
  23. },
  24. // 系统配置-界面显示
  25. configure: Storage.getData("configure", nameSpace) ?? {
  26. grey: config.Grey ?? false,
  27. weak: config.Weak ?? false,
  28. hideTabs: config.HideTabs ?? false,
  29. hideFooter: config.HideFooter ?? true,
  30. showLogo: config.ShowLogo ?? true,
  31. showModel: config.ShowModel ?? "smart",
  32. multiTagsCache: config.MultiTagsCache ?? false,
  33. stretch: config.Stretch ?? false
  34. }
  35. },
  36. config.MultiTagsCache
  37. ? {
  38. // 默认显示顶级菜单tag
  39. tags: Storage.getData("tags", nameSpace) ?? routerArrays
  40. }
  41. : {}
  42. );
  43. app.use(Storage, { nameSpace, memory: configObj });
  44. };