import { getToken } from '@/api'
import { lang, langNameEum } from '@/lang'
import { strToParams } from '@/shared'

export type Params = {
  token?: string
}

export const params = strToParams(location.search) as Params
export const baseURL = import.meta.env.DEV ? '/api' : '/'

export const gotoLang = lang === langNameEum.zh ? 'zh' : 'en'

const goto = import.meta.env.DEV ? 'https://test.4dkankan.com/' : '/'
export const registerLink = `${goto}?lang=${gotoLang}#/login/register`
export const forgetLink = `${goto}?lang=${gotoLang}#/login/forget`
export const userInfoLink = `${goto}?lang=${gotoLang}#/information`

export let projectManage = `${goto}smarts/smart-viewer.html?lang=${lang}`

setTimeout(() => {
  if (import.meta.env.DEV) {
    projectManage = `${projectManage}&token=${getToken()}`
  }
}, 1000)
