main.js 2.04 KB
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import App from './App.vue';
import router from './router';
import store from './store/index';

import {
	httpGet,
	httpPost
} from '@/api/fetch-api.js';

import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)

// vant
import {
	Collapse,
	CollapseItem,
	Icon
} from 'vant';
Vue.use(Collapse).use(CollapseItem);
Vue.use(Icon);

import Mock from './mock'
Mock.bootstrap();

// 视频
import VueVideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
Vue.use(VueVideoPlayer)

// import 'amfe-flexible';
Vue.config.productionTip = false

// Purecss
// import Purecss from 'purecss'
// Vue.use(Purecss);

// 国际化
Vue.use(VueI18n)
const i18n = new VueI18n({
	locale: localStorage.getItem("lang") || 'tc', // 语言标识
	messages: {
		'tc': require('@/common/lang/tc'), // 繁体语言包
		'zh': require('@/common/lang/zh'), // 简体语言包
		'en': require('@/common/lang/en'), // 英文语言包
	}
})

let vueInstance = new Vue({
	i18n,
	router,
	store,
	render: h => h(App),
	mounted: () => {
		document.dispatchEvent(new Event('render-event'));
	},
	data: {
		eventBus: new Vue(),
		queryConfigData: null, // 1.放内存
		// queryConfigData: localStorage.getItem("queryConfig") || null, // 2.放localStorage
	}
}).$mount('#app');
// window.vueInstance = vueInstance; // 实在不满足需要,可以把vue实例挂载到windows上

/**
 * 初始化请求配置
 * 根据需要看放内存还是放localStorage
 *
 * 具体方法访问方法见 首页index.js mounted方法
 * 具体方法访问方法见 首页index.js mounted方法
 * 具体方法访问方法见 首页index.js mounted方法
 */
function initQueryConfig() {

	/**
	 * 请求配置 httpGet/httpPost已引入
	 * 这里先setTimeout 模拟
	 */
	setTimeout(() => {
		let configResult = {
			a:123
		}
		vueInstance.queryConfigData = configResult; // 放内存
		// localStorage.setItem("queryConfig",JSON.stringify(configResult)); // 放localStorage
	}, 1000);
}
initQueryConfig();