You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7 KiB

  1. // 响应式storage
  2. import { App } from "vue";
  3. import Storage from "responsive-storage";
  4. export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
  5. const configObj = Object.assign(
  6. {
  7. // 国际化 默认中文zh
  8. locale: {
  9. type: Object,
  10. default: Storage.getData(undefined, "locale") ?? {
  11. locale: config.Locale ?? "zh"
  12. }
  13. },
  14. // layout模式以及主题
  15. layout: {
  16. type: Object,
  17. default: Storage.getData(undefined, "layout") ?? {
  18. layout: config.Layout ?? "vertical",
  19. theme: config.Theme ?? "default",
  20. darkMode: config.DarkMode ?? false,
  21. sidebarStatus: config.SidebarStatus ?? true,
  22. epThemeColor: config.EpThemeColor ?? "409EFF"
  23. }
  24. },
  25. configure: {
  26. type: Object,
  27. default: Storage.getData(undefined, "configure") ?? {
  28. grey: config.Grey ?? false,
  29. weak: config.Weak ?? false,
  30. hideTabs: config.HideTabs ?? false,
  31. showLogo: config.ShowLogo ?? true,
  32. showModel: config.ShowModel ?? "smart",
  33. multiTagsCache: config.MultiTagsCache ?? false
  34. }
  35. }
  36. },
  37. config.MultiTagsCache
  38. ? {
  39. // 默认显示首页tag
  40. tags: {
  41. type: Array,
  42. default: Storage.getData(undefined, "tags") ?? [
  43. {
  44. path: "/welcome",
  45. parentPath: "/",
  46. meta: {
  47. title: "menus.hshome",
  48. i18n: true,
  49. icon: "HomeFilled",
  50. showLink: true
  51. }
  52. }
  53. ]
  54. }
  55. }
  56. : {}
  57. );
  58. app.use(Storage, configObj);
  59. };