import { defineStore } from 'pinia'

export interface UserInfo {
  id: number,
  name: string,
  opmId: number,
  satoken: string
}

// id必填，且需要唯一
const useStore = defineStore('index', {
  state: () => ({
    userInfro: {} as UserInfo,
    token: '',
    isCheckPermission: false,
    loading: false
  }),
  actions: {
    setUserInfo(data: UserInfo) {
      this.userInfro = data
      this.token = data.satoken || ''
    },
    setCheckPermission(data: boolean) {
      this.isCheckPermission = data
    }
  },
  persist: {
    enabled: true // true 表示开启持久化保存
  }
})
export default useStore