main.js
2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import App from './App.vue';
import router from './router';
import store from './store/index';
import Element from 'element-ui'
import '@styles/element-variables.scss'
Vue.use(Element)
import api from '@/api/api'
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 { Button } from 'element-ui';
// Vue.use(Button)
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() {
window.global = {};
let rsaKey1 = localStorage.getItem("rsaKey");
let rsaKeyIndex1 = localStorage.getItem("rsaKeyIndex");
let vhis1 = localStorage.getItem("vhis");
let policies = localStorage.getItem("policies");
try {
policies = policies ? JSON.parse(policies) : null;
} catch (e) {
console.error(e);
}
window.global = {
PK: rsaKey1,
E: rsaKeyIndex1,
vhis: vhis1,
policies: policies,
oneAccountCenterOff: process.env.VUE_APP_ONE_ACCOUNT_CENTER_OFF == "true" ? true : false
};
httpGet({
url: api.config
}).then(res => {
let rsaKey = res.rsaKey;
let rsaKeyIndex = res.rsaKeyIndex;
let vhis = res.vhis;
let policies = res.policies;
if (rsaKey) {
window.global.PK = rsaKey;
localStorage.setItem("rsaKey", rsaKey);
}
if (rsaKeyIndex) {
window.global.E = rsaKeyIndex;
localStorage.setItem("rsaKeyIndex", rsaKeyIndex);
}
if (vhis) {
window.global.vhis = vhis;
localStorage.setItem("vhis", vhis);
}
if (policies) {
window.global.policies = policies;
localStorage.setItem("policies", JSON.stringify(policies));
}
});
}
initQueryConfig();