...
|
...
|
@@ -3,11 +3,34 @@ import cookie from 'yoho-cookie'; |
|
|
import yoho from 'common/yoho';
|
|
|
import version from 'utils/version';
|
|
|
|
|
|
export default store => {
|
|
|
const setStatusBar = (width, height, store) => {
|
|
|
const statusBar = {
|
|
|
statusBarStatus: false,
|
|
|
statusBarHeight: 0,
|
|
|
};
|
|
|
|
|
|
// 仅支持ios
|
|
|
if (yoho.isYohoBuy && yoho.isiOS) {
|
|
|
statusBar.statusBarHeight = (height / width) > 2.1 ? 44 : 22;
|
|
|
|
|
|
store && store.commit('SET_STATUS_BAR_HEIGHT', {
|
|
|
height: statusBar.statusBarHeight
|
|
|
});
|
|
|
|
|
|
if (version(cookie.get('app_version'),' 6.9.2') >= 0) {
|
|
|
statusBar.statusBarStatus = true;
|
|
|
store && store.commit('SET_STATUS_BAR_STATUS', {status: true});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return statusBar;
|
|
|
};
|
|
|
|
|
|
const initClient = (store) => {
|
|
|
window.onresize = () => {
|
|
|
const {clientWidth, clientHeight} = document.body;
|
|
|
store.commit('SET_WINDOW_SIZE', {clientWidth, clientHeight});
|
|
|
setStatusBar(clientWidth, clientHeight);
|
|
|
setStatusBar(clientWidth, clientHeight, store);
|
|
|
};
|
|
|
const {clientWidth, clientHeight} = document.body;
|
|
|
|
...
|
...
|
@@ -34,20 +57,7 @@ export default store => { |
|
|
}
|
|
|
});
|
|
|
|
|
|
function setStatusBar(width, height) {
|
|
|
// 仅支持ios
|
|
|
if (yoho.isYohoBuy && yoho.isiOS) {
|
|
|
store.commit('SET_STATUS_BAR_HEIGHT', {
|
|
|
height: (height / width) > 2.1 ? 44 : 22
|
|
|
});
|
|
|
|
|
|
if (version(cookie.get('app_version'),' 6.9.2') >= 0) {
|
|
|
store.commit('SET_STATUS_BAR_STATUS', {status: true});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
setStatusBar(clientWidth, clientHeight);
|
|
|
setStatusBar(clientWidth, clientHeight, store);
|
|
|
|
|
|
if (/yoho/i.test(navigator.userAgent) && /supportWebp/i.test(navigator.userAgent)) {
|
|
|
store.commit('SET_SUPPORT_WEBP', {supportWebp: true});
|
...
|
...
|
@@ -74,3 +84,24 @@ export default store => { |
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getYohoState = () => {
|
|
|
const {clientWidth, clientHeight} = document.body;
|
|
|
|
|
|
return {
|
|
|
context: {
|
|
|
env: {
|
|
|
isApp: yoho.isApp,
|
|
|
isiOS: yoho.isiOS,
|
|
|
isAndroid: yoho.isAndroid,
|
|
|
isYohoBuy: yoho.isYohoBuy
|
|
|
}
|
|
|
},
|
|
|
window: setStatusBar(clientWidth, clientHeight)
|
|
|
}
|
|
|
};
|
|
|
|
|
|
export {
|
|
|
initClient,
|
|
|
getYohoState
|
|
|
}; |
...
|
...
|
|