zb-admin/src/store/modules/setting.ts

82 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-08-31 03:02:49 +00:00
import {defineStore} from 'pinia'
import {PRIMARY_COLOR} from "../../config";
export const useSettingStore = defineStore({
// id: 必须的,在所有 Store 中唯一
id:'settingState',
// state: 返回对象的函数
state: ()=>({
// menu 是否收缩
isCollapse:true,
//
withoutAnimation:false,
device: 'desktop',
// 刷新当前页
isReload:true,
// 主题设置
themeConfig:{
// 显示设置
showSetting:false,
2023-02-27 06:20:39 +00:00
// 菜单展示模式 默认 vertical horizontal / vertical /columns
2023-02-27 09:44:14 +00:00
mode: 'vertical',
2022-08-31 03:02:49 +00:00
// tagsView 是否展示 默认展示
showTag:true,
// 页脚
footer: true,
// 深色模式 切换暗黑模式
isDark: false,
// 显示侧边栏Logo
showLogo:true,
// 主题颜色
primary:PRIMARY_COLOR,
// element组件大小
2022-09-13 13:18:36 +00:00
globalComSize:'default',
// 是否只保持一个子菜单的展开
uniqueOpened:true,
// 固定header
fixedHeader:true,
// 灰色模式
gray:false,
// 色弱模式
weak:false
2022-08-31 03:02:49 +00:00
},
}),
getters: {},
// 可以同步 也可以异步
actions:{
// 设置主题
setThemeConfig({key, val}){
this.themeConfig[key] = val
},
// 切换 Collapse
setCollapse(value){
this.isCollapse = value
this.withoutAnimation = false
},
// 关闭侧边栏
closeSideBar({withoutAnimation}){
this.isCollapse = false
this.withoutAnimation = withoutAnimation
},
toggleDevice(device){
this.device = device
},
// 刷新
setReload(){
this.isReload = false
setTimeout(()=>{
this.isReload = true
},50)
}
},
// 这部分数据不需要存储
// persist: {
// // 本地存储的名称
// key: "settingState",
// //保存的位置
// storage: window.localStorage,//localstorage
// },
})