main.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { createApp } from 'vue'
  2. import App from './App'
  3. import router from '../router/index'
  4. import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
  5. import Vue3Lottie from 'vue3-lottie'
  6. import 'vue3-lottie/dist/style.css'
  7. import 'normalize.css'
  8. import 'vant/lib/index.css'
  9. import '../styles/index.less'
  10. import { state } from '@/state'
  11. import { browser, setAuth } from '@/helpers/utils'
  12. const app = createApp(App).use(Vue3Lottie)
  13. // 将selects全局混入当前vue实例中
  14. // import activeButtonIcon from '@/common/images/icon_check.png';
  15. // import inactiveButtonIcon from '@/common/images/icon_default.png';
  16. // app.mixin({
  17. // data() {
  18. // return {
  19. // activeButtonIcon: activeButtonIcon,
  20. // inactiveButtonIcon: inactiveButtonIcon,
  21. // };
  22. // }
  23. // });
  24. // 获取token
  25. promisefiyPostMessage({ api: 'getToken' }).then((res: any) => {
  26. const content = res.content
  27. if (content?.accessToken) {
  28. setAuth(content.tokenType + ' ' + content.accessToken)
  29. }
  30. })
  31. postMessage(
  32. {
  33. api: 'getVersion'
  34. },
  35. (res: any) => {
  36. state.version = res.content.version
  37. console.log(res, 'version')
  38. }
  39. )
  40. // import Vconsole from 'vconsole'
  41. // const vconsole = new Vconsole()
  42. const paymentType = (window as any).paymentType // 浏览器设置
  43. if (browser().isTeacher || paymentType === 'TEACHER') {
  44. state.platformType = 'TEACHER'
  45. } else if (browser().isStudent || paymentType === 'STUDENT') {
  46. state.platformType = 'STUDENT'
  47. } else if (browser().isSchool || paymentType === 'SCHOOL') {
  48. state.platformType = 'SCHOOL'
  49. } else {
  50. state.platformType = 'TEACHER'
  51. }
  52. if (state.platformType === 'TEACHER') {
  53. state.platformApi = '/api-teacher'
  54. } else if (state.platformType === 'SCHOOL') {
  55. state.platformApi = '/api-school'
  56. } else {
  57. state.platformApi = '/api-student'
  58. }
  59. app.use(router)
  60. app.mount('#app')