main.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import Vue from "vue";
  2. import App from "./App.vue";
  3. import router from "./router";
  4. import store from "./store";
  5. import animate from "animate.css";
  6. import schema from "async-validator";
  7. import dialog from "./utils/dialog";
  8. import $scroll from "@utils/loading";
  9. import cookie from "@utils/store/cookie";
  10. import "@assets/iconfont/iconfont";
  11. import "@assets/iconfont/iconfont.css";
  12. import "@assets/js/media_750";
  13. import "vue-ydui/dist/ydui.base.css";
  14. import "@assets/css/base.css";
  15. import "@assets/css/reset.css";
  16. import "@assets/css/style.css";
  17. import { isWeixin, parseQuery } from "@utils";
  18. Vue.use(animate);
  19. Vue.config.productionTip = false;
  20. Vue.config.devtools = process.env.NODE_ENV !== "production";
  21. Vue.prototype.$validator = function(rule) {
  22. return new schema(rule);
  23. };
  24. Vue.prototype.$scroll = $scroll;
  25. Vue.prototype.$dialog = dialog;
  26. const CACHE_KEY = "clear_0.0.1";
  27. if (!cookie.has(CACHE_KEY)) {
  28. cookie.clearAll();
  29. cookie.set(CACHE_KEY, 1);
  30. }
  31. let cookieName = "VCONSOLE";
  32. let query = parseQuery();
  33. let urlSpread = query["spread"];
  34. let vconsole = query[cookieName.toLowerCase()];
  35. let md5Crmeb = "b14d1e9baeced9bb7525ab19ee35f2d2"; //CRMEB MD5 加密开启vconsole模式
  36. let md5UnCrmeb = "3dca2162c4e101b7656793a1af20295c"; //UN_CREMB MD5 加密关闭vconsole模式
  37. if (urlSpread !== undefined) {
  38. var spread = cookie.get("spread");
  39. urlSpread = parseInt(urlSpread);
  40. if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
  41. cookie.set("spread", urlSpread || 0);
  42. } else if (spread === 0 || typeof spread !== "number") {
  43. cookie.set("spread", urlSpread || 0);
  44. }
  45. }
  46. const _isWechat = isWeixin();
  47. if (vconsole !== undefined) {
  48. if (vconsole === md5UnCrmeb && cookie.has(cookieName))
  49. cookie.remove(cookieName);
  50. } else vconsole = cookie.get(cookieName);
  51. if (vconsole !== undefined && vconsole === md5Crmeb) {
  52. cookie.set(cookieName, md5Crmeb, 3600);
  53. const module = () => import("vconsole");
  54. module().then(Module => {
  55. new Module.default();
  56. });
  57. }
  58. if (_isWechat) {
  59. const module = () => import("@libs/wechat");
  60. module().then(Module => {
  61. Module.default().then(() => Module.oAuth());
  62. });
  63. }
  64. const $vm = new Vue({
  65. router,
  66. store,
  67. render: h => h(App)
  68. });
  69. setTimeout(() => {
  70. $vm.$mount("#app");
  71. }, 300);