import { defineStore } from 'pinia';

export const modalStore = defineStore({
  id: 'modal',
  state: () => ({
    auth: '', // 授权弹框 login|resetPassword|changeMobile|changePassword|changeUsername
    lastTimer: {
      // 短信验证码计时器，为了防止刷新请求做了持久化
      smsRegister: 0,
      smsLogin: 0,
      changeMobile: 0,
      resetPassword: 0,
      changePassword: 0,
    }
  }),
  persist: {
    // enabled: true,
    // strategies: [
    //   {
    //     key: 'modal-store',
    //     paths: ['lastTimer', 'advHistory'],
    //   },
    // ],
    storage: {
      setItem(key, value) {
        uni.setStorageSync(key, value)
      },
      getItem(key) {
        return uni.getStorageSync(key)
      },
    },
  },
});