import { reactive } from 'vue'

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

export const state = reactive({
  user: {
    status: 'init' as status,
    data: {} as any
  },
  platformType: '' as 'STUDENT' | 'TEACHER',
  version: '', // 版本号 例如: 1.0.0
  ossUploadUrl: 'https://ks3-cn-beijing.ksyuncs.com/',
  musicCertStatus: false as boolean, // 是否音乐认证
  openLiveStatus: false as boolean // 是否开通直播
})

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
}
