import { createApp } from 'vue' import App from './App.vue' import router from '../router/index' import { postMessage, promisefiyPostMessage } from '@/helpers/native-message' import 'normalize.css' import 'vant/lib/index.css' import '../styles/index.less' import { state } from '@/state' import { browser, setAuth } from '@/helpers/utils' const app = createApp(App) // 获取token promisefiyPostMessage({ api: 'getToken' }).then((res: any) => { console.log(res, 'res') const content = res.content if (content?.accessToken) { setAuth(content.tokenType + ' ' + content.accessToken) } }) postMessage( { api: 'getVersion' }, (res: any) => { state.version = res.content.version console.log(res, 'version') } ) // import Vconsole from 'vconsole' // const vconsole = new Vconsole() const paymentType = (window as any).paymentType // 浏览器设置 if (browser().isTeacher || paymentType === 'TEACHER') { state.platformType = 'TEACHER' } else if (browser().isStudent || paymentType === 'STUDENT') { state.platformType = 'STUDENT' } else if (browser().isSchool || paymentType === 'SCHOOL') { state.platformType = 'SCHOOL' } else { state.platformType = 'SCHOOL' } if (state.platformType === 'TEACHER') { state.platformApi = '/api-teacher' } if (state.platformType === 'STUDENT') { state.platformApi = '/api-student' } else { state.platformApi = '/api-school' } app.use(router) app.mount('#app')