main.ts 1.2 KB

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