Authored by yyq

init client

... ... @@ -15,6 +15,8 @@ import OrderPromotionList from 'components/order-promotion-list';
import Bind from 'components/bind';
import sdk from 'yoho-activity-sdk';
import { initClient } from 'utils/init-client';
import 'statics/scss/common.scss';
import 'statics/font/iconfont.css';
import 'statics/font/ufofont.css';
... ... @@ -45,6 +47,7 @@ Vue.use(OrderCouponList);
Vue.use(OrderPromotionList);
Vue.use(Bind);
initClient(store);
yoho.auth = async(loginUrl) => {
let user = await sdk.getUser();
... ...
import Vue from 'vue';
const setWindowSize = (store) => {
const { clientWidth, clientHeight } = document.body;
store.commit('SET_WINDOW_SIZE', { clientWidth, clientHeight });
};
const initClient = (store) => {
setWindowSize(store);
window.onresize = () => {
setWindowSize(store);
};
let supportsPassive = false;
try {
const opts = Object.defineProperty({}, 'passive', {
get() {
supportsPassive = true;
return true;
}
});
window.addEventListener('test', null, opts);
} catch (e) { } //eslint-disable-line
store.commit('SET_SUPPORT_PASSIVE', { supportsPassive });
let img = new Image();
img.onload = () => {
if (img.width > 0 && img.height > 0) {
store.commit('SET_SUPPORT_WEBP', { supportWebp: true });
}
};
img.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
Vue.$sdk.getUser().then(user => {
if (user && user.uid) {
store.commit('SET_LOGIN_INFO', user);
}
});
};
export {
initClient
};
... ...