shuishen
2025-10-11 3fc27febccd04e2fcffbd2cdd16d2daafd0b3ca3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { createPinia } from "pinia"
// pinia 持久化插件
import { createPersistedState } from "pinia-plugin-persistedstate"
 
// 导入子模块
import useAppStore from "./modules/app"
import useUserStore from "./modules/user"
import useMapStore from "./modules/map"
 
// 安装pinia状态管理插件
function setupStore (app) {
  const store = createPinia()
 
  const piniaPersist = createPersistedState({
    storage: {
      getItem: uni.getStorageSync,
      setItem: uni.setStorageSync
    }
  })
  store.use(piniaPersist)
 
  app.use(store)
}
 
// 导出模块
export { useAppStore, useUserStore, useMapStore }
export default setupStore