import { reactive } from 'vue'
import { setAuth } from './helpers/utils'

type status = 'init' | 'login' | 'logout' | 'error'

export const state = reactive({
  user: {
    status: 'init' as status,
    data: {} as any
  },
  platformType: '' as 'STUDENT' | 'TEACHER',
  platformApi: '/api-student' as '/api-student' | '/api-teacher',
  version: '', // 版本号 例如: 1.0.0
  ossUploadUrl: 'https://ks3-cn-beijing.ksyuncs.com/'
})

export const setLoginInit = () => {
  state.user.status = 'init'
  state.user.data = null
}

export const setLogin = (data: any) => {
  state.user.status = 'login'
  state.user.data = data
}

export const setLogout = () => {
  state.user.status = 'logout'
  state.user.data = null
}

export const setLoginError = () => {
  state.user.status = 'error'
  state.user.data = null
}
