jeecgBootUniapp/src/store/index.ts

28 lines
581 B
Vue
Raw Normal View History

2025-04-29 08:37:17 +00:00
import { createPinia, defineStore } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate' // 数据持久化
const store = createPinia()
store.use(
createPersistedState({
storage: {
getItem: uni.getStorageSync,
setItem: uni.setStorageSync,
},
}),
)
export const useAppStore = defineStore('app', {
state: () => ({
isGray: 0 as 0 | 1, // 0=正常1=灰化
}),
actions: {
setIsGray(value : 0 | 1) {
this.isGray = value
},
},
persist: true, // 启用持久化
})
export default store
// 模块统一导出
export * from './user'