28 lines
581 B
Vue
28 lines
581 B
Vue
![]() |
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'
|