main.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. setToastDefaultOptions({ duration: 3000 });
  16. // 获取token
  17. promisefiyPostMessage({ api: 'getToken' }).then((res: any) => {
  18. const content = res.content;
  19. if (content?.accessToken) {
  20. storage.set(ACCESS_TOKEN, content.tokenType + ' ' + content.accessToken);
  21. }
  22. });
  23. // 导航栏高度
  24. postMessage({ api: 'getNavHeight' }, (res: any) => {
  25. const { content } = res as any;
  26. const dpi = content.dpi || 2;
  27. if (content.navHeight) {
  28. const navHeight = content.navHeight / dpi;
  29. console.log(navHeight, 'navHeight');
  30. state.navBarHeight = navHeight;
  31. }
  32. });
  33. // import Vconsole from 'vconsole';
  34. // const vconsole = new Vconsole();
  35. const app = createApp(App);
  36. app.use(Lazyload);
  37. // store plugin: pinia
  38. setupStore(app);
  39. dayjs.locale('zh-ch');
  40. app.use(router);
  41. app.mount('#app');