Commit 292a96ce authored by 杨思琦's avatar 杨思琦

fix: 云模式首次登录取网关配置

parent 1c79d81f
Pipeline #74746 passed with stages
......@@ -292,6 +292,9 @@ class Login {
const self = this;
// eslint-disable-next-line no-undef
// 获取网站配置的同时,预先获取到mqtt配置,注册进子应用
const gateWayParam = {
_site: this?.globalConfig?.userInfo?.site ?? '',
};
Promise.allSettled([
noticeService.getMqttSiteCode({ 'request.preventCache': Date.now() }),
getWebSiteConfig({
......@@ -299,6 +302,7 @@ class Login {
token,
'request.preventCache': Date.now(),
}),
appService.getWateWayConfig(gateWayParam),
])
.then(results => {
const promise = results[0];
......@@ -363,8 +367,14 @@ class Login {
? response.data
: []
: response;
const gatewayRes = results[2]?.value ?? {};
// 重置网关配置
// eslint-disable-next-line prettier/prettier, no-undef
const hasGateWay = !gatewayRes || !gatewayRes.data ? false : _.isString(gatewayRes.data) ? JSON.parse(gatewayRes.data) : (typeof gatewayRes.data === 'boolean' ? gatewayRes.data : false);
if (result && result.length > 0) {
const config = result.shift();
config.hasGateWay = hasGateWay;
config.apiGatewayDomain = `${window.location.origin}${hasGateWay ? '/PandaCore/GateWay' : ''}`;
const homeType = config.productType || 'civweb4';
// 产品类型和首页路径同时有才行
// eslint-disable-next-line prettier/prettier
......@@ -382,7 +392,27 @@ class Login {
products: self.globalConfig.products,
// mapsettings: config.mapsettings
});
self.updateConfig && self.updateConfig(self.globalConfig);
if (hasGateWay) {
appService
.authorizationToken({
loginName: self.globalConfig.userInfo?.loginName || '',
type: 'WorkNo',
})
.then(tokenRes => {
if (tokenRes.code === 0) {
self.globalConfig.access_token = tokenRes.data?.access_token ?? '';
localStorage.setItem('access_token', self.globalConfig.access_token);
}
self.updateConfig(self.globalConfig);
})
.catch(err => {
self.updateConfig(self.globalConfig);
});
} else {
self.globalConfig.access_token = null;
localStorage.setItem('access_token', self.globalConfig.access_token);
self.updateConfig(self.globalConfig);
}
self.getProjectItems().then(res => {
window.subSysCfg = {};
self.globalConfig = Object.assign(self.globalConfig, {
......
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