global.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { defineStore } from "pinia";
  2. import { GlobalState } from "@/stores/interface";
  3. import { DEFAULT_PRIMARY } from "@/config";
  4. import piniaPersistConfig from "@/config/piniaPersist";
  5. import type { ObjToKeyValArray } from "@/typings/global";
  6. export const useGlobalStore = defineStore({
  7. id: "longjoe-global",
  8. // 修改默认值之后,需清除 localStorage 数据
  9. state: (): GlobalState => ({
  10. // 布局模式 (纵向:vertical | 经典:classic | 横向:transverse | 分栏:columns)
  11. layout: "classic",
  12. // element 组件大小
  13. assemblySize: "small",
  14. // 当前系统语言
  15. language: "zh-cn",
  16. // 当前页面是否全屏
  17. maximize: false,
  18. // 主题颜色
  19. primary: DEFAULT_PRIMARY,
  20. // 深色模式
  21. isDark: false,
  22. // 灰色模式
  23. isGrey: false,
  24. // 色弱模式
  25. isWeak: false,
  26. // 侧边栏反转 (目前仅支持 'vertical' 模式)
  27. asideInverted: false,
  28. // 折叠菜单
  29. isCollapse: true,
  30. // 面包屑导航
  31. breadcrumb: false,
  32. // 面包屑导航图标
  33. breadcrumbIcon: false,
  34. // 标签页
  35. tabs: true,
  36. // 标签页图标
  37. tabsIcon: true,
  38. // 页脚
  39. footer: false,
  40. // 切换动画
  41. tabsAnimating: true,
  42. // 自动锁屏时间, 0不设置
  43. autoLockTime: 0,
  44. globalLabelWidth: 120,
  45. globalAlign: "left",
  46. detailBlank: false,
  47. pageSizes: {},
  48. autocomplete: {},
  49. baseMsgTags: [],
  50. //菜单是否纵向展示:0: 横向;1:纵向
  51. menuArrangedVertically: false,
  52. mxFloat: [],
  53. homeLayoutCollapse: false,
  54. noviceTutorial: [],
  55. is408: false,
  56. isSuper: false,
  57. detailtabs: null,
  58. isShowOriginFormulaMattress: false
  59. }),
  60. getters: {
  61. // 按钮权限列表
  62. mxFloatGet: state => state.mxFloat
  63. },
  64. actions: {
  65. // Set GlobalState
  66. setGlobalState(...args: ObjToKeyValArray<any>) {
  67. // setGlobalState(...args: ObjToKeyValArray<GlobalState>) {
  68. args && this.$patch({ [args[0]]: args[1] });
  69. }
  70. },
  71. persist: piniaPersistConfig("longjoe-global")
  72. });