main.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { createApp } from 'vue';
  2. import App from './App';
  3. import router from './router/index';
  4. import dayjs from 'dayjs';
  5. import 'dayjs/locale/zh-cn';
  6. import 'vant/lib/index.css';
  7. import './component-ui/index.less';
  8. import './styles/index.less';
  9. import { promisefiyPostMessage, postMessage } from './helpers/native-message';
  10. import { state } from './state';
  11. import { storage } from '@/helpers/storage';
  12. import { ACCESS_TOKEN } from '@/store/mutation-types';
  13. import { setupStore } from './store';
  14. import { Lazyload, setToastDefaultOptions } from 'vant';
  15. import useErrorLog from './hooks/useErrorLog';
  16. setToastDefaultOptions({ duration: 3000 });
  17. // import 'mobile-drag-drop/default.css';
  18. // import { polyfill } from 'mobile-drag-drop';
  19. // // 可选引入滚动行为的脚本
  20. // import { scrollBehaviourDragImageTranslateOverride } from 'mobile-drag-drop/scroll-behaviour';
  21. // // 可选的配置项
  22. // const options = {
  23. // // 使用这个选项以应用滚动行为
  24. // dragImageTranslateOverride: scrollBehaviourDragImageTranslateOverride
  25. // };
  26. // // 初始化polyfill
  27. // polyfill(options);
  28. // 获取token
  29. promisefiyPostMessage({ api: 'getToken' }).then((res: any) => {
  30. const content = res.content;
  31. if (content?.accessToken) {
  32. storage.set(ACCESS_TOKEN, content.tokenType + ' ' + content.accessToken);
  33. }
  34. });
  35. // 导航栏高度
  36. postMessage({ api: 'getNavHeight' }, (res: any) => {
  37. const { content } = res as any;
  38. const dpi = content.dpi || 2;
  39. if (content.navHeight) {
  40. const navHeight = content.navHeight / dpi;
  41. console.log(navHeight, 'navHeight');
  42. state.navBarHeight = navHeight;
  43. }
  44. });
  45. // import Vconsole from 'vconsole';
  46. // const vconsole = new Vconsole();
  47. const app = createApp(App);
  48. app.use(Lazyload);
  49. // store plugin: pinia
  50. setupStore(app);
  51. dayjs.locale('zh-ch');
  52. app.use(router);
  53. // 监听错误信息
  54. const errorLog = useErrorLog();
  55. errorLog.startListenErrorLog();
  56. app.mount('#app');