main.js 1.6 KB
import VConsole from "vconsole";
// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
// import 'core-js/stable'
// import 'regenerator-runtime/runtime'
import Vue from "vue";
import { cfg, fetchConfig } from "@/config";
import { utils } from "@/config/utils.config.js";
import { vant } from "@/config/vant.config.js";
import { ssoApi } from "./api/index.js";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import { bus, store as local, tools, util } from "./utils";
import "@/assets/css/index.scss";
import "@/assets/icons";
import "./utils/util";
import "@/components";
// import mixin from './mixins/index'
vant(Vue);
utils(Vue);
Vue.prototype.api = ssoApi;
Vue.prototype.bus = bus;
Vue.prototype.tools = tools;
Vue.prototype.local = local;
Vue.prototype.to = function (name, params) {
	if (name === -1) {
		router.go(-1);
		return;
	}
	router.push({ name, params });
};
// 移动端适配 rem
// import 'lib-flexible/flexible.js'

Vue.config.productionTip = false;
const isMock = ["prod", "production"].includes(process.env.NODE_ENV);
fetchConfig(!isMock).then((res) => {
	// 从配置服务器获取动态配置
	// 设置 js中可以访问 $cdn
	Vue.use(cfg);
	window.$fetchConfig = res;
	if (res.vconsole)
		new VConsole();
	/** 登录过期 重新登录 */
	window.reLogin = () => {
		util.removeLocalStorage("ww_userInfo");
		util.clearSessionId();
		store.dispatch("navigation"); // 暂时不管登录过期
	};
	window.vm = new Vue({
		el: "#app",
		router,
		store,
		render: h => h(App),
	});
});