Commit 83c714e2 authored by 崔佳豪's avatar 崔佳豪

fix: 获取网关与获取全局配置互相覆盖引起的异常问题

parent cd7ae4fb
Pipeline #46965 skipped with stages
......@@ -10,7 +10,7 @@ import Login from './pages/user/login/login';
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
export const initGlobalConfig = () => {
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-undef
createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
......@@ -45,92 +45,96 @@ export const initGlobalConfig = () => {
updateTheme('#ff9600');
}
} else {
// eslint-disable-next-line react-hooks/rules-of-hooks
let client = params.getParams('client') || Cookies.get('city')
client = client && client !== 'undefined' ? client : 'city';
appService.getWateWayConfig().then(res => {
const hasGateWay =
res && res.data && isString(res.data) ? JSON.parse(res.data) : res.data;
if (res.code === 0 && res.data === 'true') {
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, {
hasGateWay,
apiGatewayDomain: `${window.location.origin}/PandaCore`,
}),
),
);
!res || !res.data ? false : isString(res.data) ? JSON.parse(res.data) : typeof res.data === 'boolean' ? res.data : false;
// if (res.code === 0 && res.data === 'true') {
// store.dispatch(
// actionCreators.getConfig(
// Object.assign({}, window.globalConfig, {
// hasGateWay,
// apiGatewayDomain: `${window.location.origin}/PandaCore`,
// }),
// ),
// );
// }
return {
hasGateWay,
apiGatewayDomain: `${window.location.origin}/PandaCore`,
}
});
// eslint-disable-next-line react-hooks/rules-of-hooks
let client = params.getParams('client') || Cookies.get('city')
client = client && client !== 'undefined' ? client : 'city';
appService
.queryConfig({
client: client || 'city',
ignoreSite: true,
})
.then(res => {
if (res) {
store.dispatch(actionCreators.getConfig(Object.assign({})));
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
}),
),
);
//Cookies.set('city', params.getParams('client'))
if (data.loginTemplate === '新春 - 智联.html') {
updateTheme('#ff9600');
}
// eslint-disable-next-line no-new
if (getToken()) {
}).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
new Login(
{
global: Object.assign({}, data, {
token: getToken(),
}),
// 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,
);
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
global: Object.assign({}, data, {
token: getToken(),
}),
// 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,
);
}
// eslint-disable-next-line no-shadow
}
// eslint-disable-next-line no-shadow
}
return res;
})
// eslint-disable-next-line no-shadow
.then(res => {
// eslint-disable-next-line no-use-before-define
// initSensorType();
// eslint-disable-next-line no-use-before-define
// initIsMock();
render({ appContent: '', loading: true });
})
.catch(error => {
console.log(error);
store.dispatch(actionCreators.getConfigError(error));
});
return res;
})
// eslint-disable-next-line no-shadow
.then(res => {
// eslint-disable-next-line no-use-before-define
// initSensorType();
// eslint-disable-next-line no-use-before-define
// initIsMock();
render({ appContent: '', loading: true });
})
.catch(error => {
console.log(error);
store.dispatch(actionCreators.getConfigError(error));
});
});
}
};
\ No newline at end of file
......@@ -27,10 +27,7 @@ class SecurityLayout extends React.Component {
// const queryString = stringify({
// redirect: window.location.href,
// });
if (
_.isNull(global.token) ||
(global.hasGateWay && _.isNull(global.access_token))
) {
if (!Cookies.get('token')) {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || Cookies.get('city');
client =
......
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