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=灰化 position: null, //市 location: null, //省市区 temperature: null, //温度 weather: null //天气 }), actions: { setIsGray(value : 0 | 1) { this.isGray = value }, setPosition(value : string) { this.position = value }, setLocation(value : string) { this.location = value }, setTemperature(value : number) { this.temperature = value }, setWeather(value : string) { this.weather = value }, }, persist: true, // 启用持久化 }) export default store // 模块统一导出 export * from './user'