main.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { createApp } from 'vue';
  2. import App from './App.vue';
  3. import './registerServiceWorker';
  4. import router from './router';
  5. import store from './store';
  6. import Vant from 'vant';
  7. import { ConfigProvider } from 'vant';
  8. import 'vant/lib/index.css';
  9. import './styles/app.less';
  10. import './styles/font.less';
  11. import http from './plugins/http';
  12. import colors from './plugins/colors';
  13. // import ElementUI from 'element-ui';
  14. // import 'element-ui/lib/theme-chalk/index.css';
  15. import PageTitle from './components/PageTitle';
  16. import LikeButton from './components/LikeButton.vue';
  17. import Driver from './components/Driver.vue';
  18. import common from './mixins/common';
  19. import VueClipboard from 'vue-clipboard2';
  20. import queryString from 'query-string';
  21. import PageBar from './components/PageBar';
  22. import eruda from 'eruda';
  23. import { Toast, Lazyload } from 'vant';
  24. Toast.setDefaultOptions('loading', {
  25. duration: 0
  26. });
  27. let showConsole = localStorage.getItem('showConsole');
  28. if (showConsole && parseInt(showConsole) > new Date().getTime()) {
  29. eruda.init();
  30. }
  31. store.commit('setFirstUrl', location.href);
  32. import ImgContent from './components/ImgContent.vue';
  33. createApp(App)
  34. .use(Vant)
  35. .use(Lazyload)
  36. .use(http)
  37. .use(colors)
  38. // .use(ElementUI)
  39. .use(ConfigProvider)
  40. .use(VueClipboard)
  41. .mixin(common)
  42. .component('page-title', PageTitle)
  43. .component('like-button', LikeButton)
  44. .component('driver', Driver)
  45. .component('van-image', ImgContent)
  46. .component('page-bar', PageBar)
  47. .use(store)
  48. .use(router)
  49. .mount('#app');
  50. let query = queryString.parse(location.search);
  51. //if (query.code) {
  52. // http.http.post('/user/code2openId', {
  53. // code: query.code
  54. // }).then(res => {
  55. // localStorage.setItem('openId', res);
  56. // });
  57. //} else {
  58. // if (/micromessenger/i.test(navigator.userAgent) && !/localhost|(192\.168)/i.test(location.host)) {
  59. // document.location.replace('https://nft.9space.vip/wx/redirect?redirectUrl=' + location.href);
  60. // }
  61. //}
  62. if (query.invitor) {
  63. store.commit('setInvitor', query.invitor);
  64. }
  65. if (query.inviteCode) {
  66. store.commit('setInviteCode', query.inviteCode);
  67. }
  68. if (window.cordova) {
  69. document.addEventListener(
  70. 'deviceready',
  71. function () {
  72. window.codePush.sync(
  73. function (syncStatus) {
  74. switch (syncStatus) {
  75. // Result (final) statuses
  76. case SyncStatus.UPDATE_INSTALLED:
  77. console.log(
  78. 'The update was installed successfully. For InstallMode.ON_NEXT_RESTART, the changes will be visible after application restart. '
  79. );
  80. break;
  81. case SyncStatus.UP_TO_DATE:
  82. console.log('The application is up to date.');
  83. break;
  84. case SyncStatus.UPDATE_IGNORED:
  85. console.log('The user decided not to install the optional update.');
  86. break;
  87. case SyncStatus.ERROR:
  88. console.log('An error occured while checking for updates');
  89. break;
  90. // Intermediate (non final) statuses
  91. case SyncStatus.CHECKING_FOR_UPDATE:
  92. console.log('Checking for update.');
  93. break;
  94. case SyncStatus.AWAITING_USER_ACTION:
  95. console.log('Alerting user.');
  96. break;
  97. case SyncStatus.DOWNLOADING_PACKAGE:
  98. console.log('Downloading package.');
  99. break;
  100. case SyncStatus.INSTALLING_UPDATE:
  101. console.log('Installing update');
  102. break;
  103. }
  104. },
  105. {
  106. installMode: InstallMode.IMMEDIATE,
  107. updateDialog: false
  108. },
  109. function (downloadProgress) {
  110. console.log(
  111. 'Downloading ' +
  112. downloadProgress.receivedBytes +
  113. ' of ' +
  114. downloadProgress.totalBytes +
  115. ' bytes.'
  116. );
  117. }
  118. );
  119. },
  120. false
  121. );
  122. }