/**
 * Pinia 状态管理入口文件
 * 统一管理所有的 store 模块
 */

import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'

// 创建 pinia 实例
const pinia = createPinia()

// 添加持久化插件
pinia.use(
  createPersistedState({
    storage: {
      getItem: (key) => {
        return uni.getStorageSync(key)
      },
      setItem: (key, value) => {
        uni.setStorageSync(key, value)
      },
      removeItem: (key) => {
        uni.removeStorageSync(key)
      }
    }
  })
)

export default pinia

// 导出所有 store 模块
export { useUserStore } from './modules/user'
export { useAppStore } from './modules/app'
export { useFarmingStore } from './modules/farming'
export { useTradingStore } from './modules/trading'
export { useMallStore } from './modules/mall'
export { useFinanceStore } from './modules/finance'
export { useInsuranceStore } from './modules/insurance'