Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
83c714e2
Commit
83c714e2
authored
3 years ago
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 获取网关与获取全局配置互相覆盖引起的异常问题
parent
cd7ae4fb
Pipeline
#46965
skipped with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
86 deletions
+88
-86
initConfig.js
src/initConfig.js
+87
-82
SecurityLayout.js
src/layouts/SecurityLayout.js
+1
-4
No files found.
src/initConfig.js
View file @
83c714e2
...
...
@@ -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
This diff is collapsed.
Click to expand it.
src/layouts/SecurityLayout.js
View file @
83c714e2
...
...
@@ -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
=
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment