main.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. import router from '../router/index'
  4. import { postMessage } from '@/helpers/native-message'
  5. import 'normalize.css'
  6. import 'vant/lib/index.css'
  7. import '../styles/index.less'
  8. import { state } from '@/state'
  9. import { browser } from '@/helpers/utils'
  10. const app = createApp(App)
  11. postMessage(
  12. {
  13. api: 'getVersion'
  14. },
  15. (res: any) => {
  16. state.version = res.content.version
  17. console.log(res, 'version')
  18. }
  19. )
  20. // import Vconsole from 'vconsole'
  21. // const vconsole = new Vconsole()
  22. const paymentType = (window as any).paymentType // 浏览器设置
  23. if (browser().isTeacher || paymentType === 'TEACHER') {
  24. state.platformType = 'TEACHER'
  25. } else if (browser().isStudent || paymentType === 'STUDENT') {
  26. state.platformType = 'STUDENT'
  27. } else if (browser().isSchool || paymentType === 'SCHOOL') {
  28. state.platformType = 'SCHOOL'
  29. } else {
  30. state.platformType = 'SCHOOL'
  31. }
  32. if (state.platformType === 'TEACHER') {
  33. state.platformApi = '/api-teacher'
  34. }
  35. if (state.platformType === 'STUDENT') {
  36. state.platformApi = '/api-student'
  37. } else {
  38. state.platformApi = '/api-school'
  39. }
  40. app.use(router)
  41. app.mount('#app')