responsive.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // layout模式以及主题
  11. layout: Storage.getData("layout", nameSpace) ?? {
  12. // layout: config.Layout ?? "vertical",
  13. layout: config.Layout ?? "mix",
  14. theme: config.Theme ?? "light",
  15. darkMode: config.DarkMode ?? false,
  16. sidebarStatus: config.SidebarStatus ?? true,
  17. epThemeColor: config.EpThemeColor ?? "#409EFF",
  18. themeColor: config.Theme ?? "light", // 主题色(对应项目配置中的主题色,与theme不同的是它不会受到浅色、深色整体风格切换的影响,只会在手动点击主题色时改变)
  19. overallStyle: config.OverallStyle ?? "light" // 整体风格(浅色:light、深色:dark、自动:system)
  20. },
  21. // 项目配置-界面显示
  22. configure: Storage.getData("configure", nameSpace) ?? {
  23. grey: config.Grey ?? false,
  24. weak: config.Weak ?? false,
  25. hideTabs: config.HideTabs ?? false,
  26. hideFooter: config.HideFooter ?? true,
  27. showLogo: config.ShowLogo ?? true,
  28. showModel: config.ShowModel ?? "smart",
  29. multiTagsCache: config.MultiTagsCache ?? false,
  30. stretch: config.Stretch ?? false
  31. }
  32. },
  33. config.MultiTagsCache
  34. ? {
  35. // 默认显示顶级菜单tag
  36. tags: Storage.getData("tags", nameSpace) ?? routerArrays
  37. }
  38. : {}
  39. );
  40. app.use(Storage, { nameSpace, memory: configObj });
  41. };