main.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. import vConsole from 'vconsole'
  11. new vConsole()
  12. const app = createApp(App)
  13. postMessage(
  14. {
  15. api: 'getVersion'
  16. },
  17. (res: any) => {
  18. state.version = res.content.version
  19. console.log(res, 'version')
  20. }
  21. )
  22. // import Vconsole from 'vconsole'
  23. // const vconsole = new Vconsole()
  24. const paymentType = (window as any).paymentType // 浏览器设置
  25. if (browser().isTeacher || paymentType === 'TEACHER') {
  26. state.platformType = 'TEACHER'
  27. } else if (browser().isStudent || paymentType === 'STUDENT') {
  28. state.platformType = 'STUDENT'
  29. } else if (browser().isSchool || paymentType === 'SCHOOL') {
  30. state.platformType = 'SCHOOL'
  31. } else {
  32. state.platformType = 'SCHOOL'
  33. }
  34. if (state.platformType === 'TEACHER') {
  35. state.platformApi = '/api-teacher'
  36. }
  37. if (state.platformType === 'STUDENT') {
  38. state.platformApi = '/api-student'
  39. } else {
  40. state.platformApi = '/api-school'
  41. }
  42. app.use(router)
  43. app.mount('#app')