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

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

parent cd7ae4fb
Pipeline #46965 skipped with stages
...@@ -45,23 +45,27 @@ export const initGlobalConfig = () => { ...@@ -45,23 +45,27 @@ export const initGlobalConfig = () => {
updateTheme('#ff9600'); updateTheme('#ff9600');
} }
} else { } 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 => { appService.getWateWayConfig().then(res => {
const hasGateWay = const hasGateWay =
res && res.data && isString(res.data) ? JSON.parse(res.data) : res.data; !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') { // if (res.code === 0 && res.data === 'true') {
store.dispatch( // store.dispatch(
actionCreators.getConfig( // actionCreators.getConfig(
Object.assign({}, window.globalConfig, { // Object.assign({}, window.globalConfig, {
// hasGateWay,
// apiGatewayDomain: `${window.location.origin}/PandaCore`,
// }),
// ),
// );
// }
return {
hasGateWay, hasGateWay,
apiGatewayDomain: `${window.location.origin}/PandaCore`, apiGatewayDomain: `${window.location.origin}/PandaCore`,
}),
),
);
} }
}); }).then((gateWayConfig) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
let client = params.getParams('client') || Cookies.get('city')
client = client && client !== 'undefined' ? client : 'city';
appService appService
.queryConfig({ .queryConfig({
client: client || 'city', client: client || 'city',
...@@ -69,8 +73,6 @@ export const initGlobalConfig = () => { ...@@ -69,8 +73,6 @@ export const initGlobalConfig = () => {
}) })
.then(res => { .then(res => {
if (res) { if (res) {
store.dispatch(actionCreators.getConfig(Object.assign({})));
const data = res; const data = res;
if (!data.client) { if (!data.client) {
data.client = client; data.client = client;
...@@ -82,7 +84,7 @@ export const initGlobalConfig = () => { ...@@ -82,7 +84,7 @@ export const initGlobalConfig = () => {
token: '', token: '',
access_token: '', access_token: '',
userInfo: null userInfo: null
}), }, gateWayConfig),
), ),
); );
...@@ -132,5 +134,7 @@ export const initGlobalConfig = () => { ...@@ -132,5 +134,7 @@ export const initGlobalConfig = () => {
console.log(error); console.log(error);
store.dispatch(actionCreators.getConfigError(error)); store.dispatch(actionCreators.getConfigError(error));
}); });
});
} }
}; };
\ No newline at end of file
...@@ -27,10 +27,7 @@ class SecurityLayout extends React.Component { ...@@ -27,10 +27,7 @@ class SecurityLayout extends React.Component {
// const queryString = stringify({ // const queryString = stringify({
// redirect: window.location.href, // redirect: window.location.href,
// }); // });
if ( if (!Cookies.get('token')) {
_.isNull(global.token) ||
(global.hasGateWay && _.isNull(global.access_token))
) {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0); this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || Cookies.get('city'); let client = global.client || Cookies.get('city');
client = 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