entry-client.js
1.57 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
import Vue from 'vue';
import {
ROUTE_CHANGE,
REPORT_YAS,
} from 'store/yoho/types';
import {createApp} from './app';
import {createApi} from 'create-api';
import {Style, Toast, Dialog} from 'cube-ui'; //eslint-disable-line
import Lazy from 'vue-lazyload';
import 'statics/scss/common.scss';
import 'statics/font/iconfont.css';
import 'statics/font/ufofont.css';
const {app, router, store} = createApp();
if (window.__INITIAL_STATE__) {
store.replaceState(window.__INITIAL_STATE__);
}
// Vue.prop('yoho', yoho);
Vue.use(Toast);
Vue.use(Dialog);
Vue.prop('api', createApi());
Vue.use(Lazy, {error: ''});
router.onReady(() => {
router.beforeResolve((to, from, next) => {
const matched = router.getMatchedComponents(to);
store.commit(ROUTE_CHANGE, to);
if (window._hmt) {
window._hmt.push(['_trackPageview', to.fullPath]);
}
store.dispatch(REPORT_YAS, {
params: {
appop: 'YB_H5_PAGE_OPEN_L',
param: {
F_URL: `${location.origin}${to.fullPath}`,
PAGE_URL: `${location.origin}${from.fullPath}`,
PAGE_NAME: from.name
}
}
});
Promise.all(matched.map(({asyncData}) =>
asyncData && asyncData({store, router: to})))
.then(() => {
if (!false || store.state.yoho.visible) {
return next();
} else {
history.pushState({}, '', from.fullPath);
}
})
.catch(e => {
console.error(e);
return next();
});
});
app.$mount('#app');
});
router.onError(e => {
console.error(e);
router.push({name: 'error.500'});
});