Commit e013e05f authored by 崔佳豪's avatar 崔佳豪

perf: 兼容网关服务失败

parent e7a52fa6
Pipeline #48421 passed with stages
in 2 minutes 26 seconds
......@@ -49,6 +49,77 @@ export const initGlobalConfig = () => {
// }
let client = params.getParams('client') || Cookies.get('city');
client = client && client !== 'undefined' ? client : 'city';
const queryConfig = (gateWayConfig = {}) => {
appService
.queryConfig({
client: client || 'city',
ignoreSite: true,
})
.then(res => {
if (res) {
const data = res;
if (!data.client) {
data.client = client;
}
// Cookies.set('city', data.client);
store.dispatch(
actionCreators.getConfig(
Object.assign(
{},
data,
{
token: '',
access_token: '',
userInfo: null,
},
gateWayConfig,
),
),
);
// Cookies.set('city', params.getParams('client'))
if (data.loginTemplate === '新春 - 智联.html') {
updateTheme('#ff9600');
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
global: Object.assign({}, data,
{
token: getToken(),
},
gateWayConfig,
),
// eslint-disable-next-line no-shadow
updateConfig: data => store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() &&
window.globalConfig &&
window.globalConfig.token)) &&
initMicroApps(loader, store);
})();
},
true,
);
}
}
return res;
})
.then(res => {
render({ appContent: '', loading: true });
})
.catch(error => {
store.dispatch(actionCreators.getConfigError(error));
});
}
appService
.getWateWayConfig({
ignoreSite: true,
......@@ -62,73 +133,9 @@ export const initGlobalConfig = () => {
};
})
.then(gateWayConfig => {
appService
.queryConfig({
client: client || 'city',
ignoreSite: true,
})
.then(res => {
if (res) {
const data = res;
if (!data.client) {
data.client = client;
}
// Cookies.set('city', data.client);
store.dispatch(
actionCreators.getConfig(
Object.assign(
{},
data,
{
token: '',
access_token: '',
userInfo: null,
},
gateWayConfig,
),
),
);
// Cookies.set('city', params.getParams('client'))
if (data.loginTemplate === '新春 - 智联.html') {
updateTheme('#ff9600');
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
global: Object.assign({}, data,
{
token: getToken(),
},
gateWayConfig,
),
// eslint-disable-next-line no-shadow
updateConfig: data => store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() &&
window.globalConfig &&
window.globalConfig.token)) &&
initMicroApps(loader, store);
})();
},
true,
);
}
}
return res;
})
.then(res => {
render({ appContent: '', loading: true });
})
.catch(error => {
store.dispatch(actionCreators.getConfigError(error));
});
queryConfig(gateWayConfig);
})
.catch(err => {
queryConfig();
});
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment