main.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { createApp } from 'vue'
  2. import router from './router'
  3. import App from './App.vue'
  4. import 'lib-flexible/flexible'
  5. // import Bugsnag from '@bugsnag/js'
  6. // import BugsnagPluginVue from '@bugsnag/plugin-vue'
  7. import detaistate from '/src/pages/detail/state'
  8. import appstate, { IAuthKey } from './state'
  9. import 'vant/lib/index.css'
  10. import './app.less'
  11. import './base.css'
  12. import './index.css'
  13. import { setTongjiTag } from '/src/helpers/utils'
  14. // Bugsnag.start({
  15. // apiKey: 'c19866301f731dce31111f3915dc2a0b',
  16. // plugins: [new BugsnagPluginVue()]
  17. // })
  18. // const bugsnagVue: any = Bugsnag.getPlugin('vue')
  19. router.beforeEach((to, from, next) => {
  20. const title: string = (to.meta as any).title || '管乐迷'
  21. if (title) {
  22. document.title = title
  23. }
  24. next()
  25. })
  26. createApp(App)
  27. // .use(bugsnagVue)
  28. .use(router)
  29. .mixin({
  30. methods: {
  31. authBefore(key: IAuthKey, cb: () => void) {
  32. if (appstate.modular[key]) {
  33. return () => {
  34. setTongjiTag(['_trackEvent', '云练习', '操作', appstate.modularDetail[key]?.name])
  35. cb()
  36. }
  37. } else {
  38. return () => {
  39. setTongjiTag(['_trackEvent', '云练习', '提示无权限', appstate.modularDetail[key]?.name])
  40. detaistate.feeShow = true
  41. appstate.openKey = key
  42. }
  43. }
  44. },
  45. },
  46. })
  47. .mount('#app')