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.MODE === 'development' ? '/api' : '/'

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

const goto =
  import.meta.env.MODE === 'development' ? 'https://test.4dkankan.com/' : '/'
export const registerLink = `${goto}?lang=${gotoLang}#${
  import.meta.env.VITE_REGISTER
}`
console.log(import.meta)
export const forgetLink = `${goto}?lang=${gotoLang}#${
  import.meta.env.VITE_FORGET
}`
export const userInfoLink = `${goto}?lang=${gotoLang}#${
  import.meta.env.VITE_USER_INFO
}`

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

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