main.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { createApp } from 'vue'
  2. import App from './App'
  3. import router from '../router/index'
  4. // import { postMessage } from '@/helpers/native-message'
  5. import 'vant/lib/index.css'
  6. import 'normalize.css'
  7. import Vue3Lottie from 'vue3-lottie'
  8. import 'vue3-lottie/dist/style.css'
  9. import '../styles/index.less'
  10. import { promisefiyPostMessage } from '@/helpers/native-message'
  11. import { setAuth } from './music-group/layout/utils'
  12. import { browser } from '@/helpers/utils'
  13. import { state } from '@/state'
  14. // 获取token
  15. promisefiyPostMessage({ api: 'getToken' }).then((res: any) => {
  16. console.log(res, 'res')
  17. const content = res.content
  18. if (content?.accessToken) {
  19. setAuth(content.tokenType + ' ' + content.accessToken)
  20. }
  21. })
  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 = 'STUDENT'
  31. }
  32. if (state.platformType === 'TEACHER') {
  33. state.platformApi = '/api-teacher'
  34. } else if (state.platformType === 'SCHOOL') {
  35. state.platformApi = '/api-school'
  36. } else if (state.platformType === 'STUDENT') {
  37. state.platformApi = '/api-student'
  38. } else {
  39. state.platformApi = '/api-student'
  40. }
  41. // import Vconsole from 'vconsole'
  42. // const vconsole = new Vconsole()
  43. const app = createApp(App).use(Vue3Lottie)
  44. app.use(router)
  45. app.mount('#app')