import { defineStore } from 'pinia';
import { piniaPersistConfig } from '../config';

export interface AuthStore {
  id: number;
  username: string;
  avatar: string;
  name: string;
  phone: string;

  /**
   * token
   */
  token: string;
  /**
   * openid
   */
  openid: string;
}


export const useAuthStore = defineStore('dejin-user', {
  state: (): AuthStore => ({
    id: 0,
    username: '',
    avatar: '',
    name: '',
    phone: '',
    token: '',
    openid: '',
  }),
  actions: {
    setId(v: number) {
      this.id = v;
    },
    setUsername(v: string) {
      this.username = v;
    },
    setAvatar(v: string) {
      this.avatar = v;
    },
    setName(v: string) {
      this.name = v;
    },
    setPhone(v: string) {
      this.phone = v;
    },
    setToken(v: string) {
      this.token = v;
    },
    setOpenid(v: string) {
      this.openid = v;
    },

  },
  persist: piniaPersistConfig('dejin-user'),
});
