Files
pqs-9100_client/frontend/src/stores/modules/global.ts

55 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-08-22 11:27:06 +08:00
import { defineStore } from "pinia";
import { GlobalState } from "@/stores/interface";
import { DEFAULT_PRIMARY } from "@/config";
import piniaPersistConfig from "@/stores/helper/persist";
import {GLOBAL_STORE_KEY} from "@/stores/constant";
export const useGlobalStore = defineStore({
id: GLOBAL_STORE_KEY,
// 修改默认值之后,需清除 localStorage 数据
state: (): GlobalState => ({
// 布局模式 (纵向vertical | 经典classic | 横向transverse | 分栏columns)
layout: "transverse",
// element 组件大小
assemblySize: "default",
// 当前系统语言
language: null,
// 当前页面是否全屏
maximize: false,
// 主题颜色
primary: DEFAULT_PRIMARY,
// 深色模式
isDark: false,
// 灰色模式
isGrey: false,
// 色弱模式
isWeak: false,
// 侧边栏反转
asideInverted: false,
// 头部反转
headerInverted: false,
// 折叠菜单
isCollapse: false,
// 菜单手风琴
accordion: true,
// 面包屑导航
breadcrumb: true,
// 面包屑导航图标
breadcrumbIcon: true,
// 标签页
tabs: true,
// 标签页图标
tabsIcon: true,
// 页脚
footer: false
}),
getters: {},
actions: {
// Set GlobalState
setGlobalState(...args: ObjToKeyValArray<GlobalState>) {
this.$patch({ [args[0]]: args[1] });
}
},
persist: piniaPersistConfig(GLOBAL_STORE_KEY)
});