export interface TabBarItem {
  code: string // 通常用于路由标识或权限码
  icon: string
  show: boolean // 控制是否展示该导航项，用于keepalive
  text: string
}

export interface IUser {
  avatar?: string
  id: string
  login_timers: number
  real_name: string
}

export interface UserState {
  agreePrivacy: boolean
  /** 当前显示的 tabBar */
  curTabBar: string
  /**
   * 是否显示引导页，显示过一次后就不再显示
   */
  isInstall: boolean
  lang: string
  tabBar: TabBarItem[]
  theme: string
  token: string
  user: User
  userActions: string[]
}

export interface ILogin {
  account: string
  password: string
}

export interface LoginData {
  account: string
  entName: string
  id: string
  imgUrl: string
  name: string
  positionName: string
}

export class LoginRes implements LoginData {
  account: string
  entName: string
  id: string
  imgUrl: string
  name: string
  positionName: string

  constructor(json: LoginData) {
    this.id = json.id
    this.account = json.account
    this.entName = json.entName
    this.imgUrl = json.imgUrl
    this.positionName = json.positionName
  }
}

export interface Roles {
  roleId: string
  roleName: string
}

export class User implements IUser {
  avatar?: string
  id: string
  login_timers: number
  real_name: string

  constructor(data: Partial<IUser> = {}) {
    this.id = data.id
    this.avatar = data.avatar
    this.login_timers = data.login_timers
    this.real_name = data.real_name
  }
}
