Commit 4fc185fd authored by 邓晓峰's avatar 邓晓峰

fix: 修复开启网关后获取全局配置

parent 68952f56
Pipeline #47012 passed with stages
in 8 minutes 49 seconds
......@@ -211,7 +211,7 @@ export const defaultApp = () => {
// createStoreage.set('init_web4', true)
// }
// let homepage = config.homepage.replace('civweb4/', '');
let url = !config.home ? (config.homepage === '' ? `/civbase/civweb4`: `/civbase/civweb4/${config.homepage.replace(/^\//, '').replace(/^civweb4\//, '')}`) : `/civbase/${config.homepage.replace(/^\//, '')}`;
let url = !config.home ? ((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: `/civbase/civweb4/${config.homepage.replace(/^\//, '').replace(/^civweb4\//, '')}`) : `/civbase/${config.homepage.replace(/^\//, '')}`;
/**
* issue 处理监听路由规则
*/
......
......@@ -5,14 +5,14 @@ import { decode, encode } from 'js-base64';
import Cookies from 'js-cookie';
import sha1 from 'sha1';
import { SlideVerify } from '@wisdom-utils/components';
import { appService } from '@/api';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base'
import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import {
SERVICE_APP_LOGIN_MODE,
SERVICE_INTERFACE_SUCCESS_CODE,
WX_REDIRECT_URI,
} from '@/constants';
import { SlideVerify } from '@wisdom-utils/components';
// eslint-disable-next-line no-undef
const Logger = logger('login');
......@@ -41,19 +41,23 @@ class Login {
let { ddCode } = this.globalConfig;
let { loginName } = this.globalConfig;
let { password } = this.globalConfig;
loginName = params.getParams('loginName') ? params.getParams('loginName'): loginName;
loginName = params.getParams('loginName')
? params.getParams('loginName')
: loginName;
const redirect = params.getParams('redirect');
const generateType = params.getParams('generateType');
if(redirect) {
if (redirect) {
this.globalConfig.homepage = redirect;
// this.globalConfig.layout = 'blank';
}
if(generateType) {
if (generateType) {
this.globalConfig.generateType = generateType;
}
self.updateConfig && self.updateConfig(self.globalConfig);
password = params.getParams('password') ? params.getParams('password'): password;
password = params.getParams('password')
? params.getParams('password')
: password;
const loginMode = Cookies.get('loginMode') || null;
if (loginMode && loginMode === 'iotWechat') ddCode = null;
// self.qrcodeLogin(self.globalConfig.qrcodeData.code);
......@@ -65,7 +69,6 @@ class Login {
} else if (ddCode && loginMode === 'qywx') {
self.qywxLoginIn(ddCode);
} else if (!!loginName && !!password) {
self.otherLoginIn(loginName, password);
} else if (
self.globalConfig.qrcodeData &&
......@@ -95,8 +98,7 @@ class Login {
site: this.getLocalSiteBytoken(token),
'request.preventCache': Date.now(),
ignoreSite: true,
})
.then(response => {
}).then(response => {
if (response && !response.errMsg) {
self.globalConfig.userInfo = {};
if (
......@@ -127,7 +129,6 @@ class Login {
});
}
writeLogs() {
if (this.globalConfig.userInfo.UserImge === '') {
// _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png";
......@@ -153,7 +154,7 @@ class Login {
.catch(error => {});
}
if(window.location.host === 'panda-water.com') {
if (window.location.host === 'panda-water.com') {
appService
.loginLogs({
origin: window.location.origin,
......@@ -169,7 +170,6 @@ class Login {
})
.catch(error => {});
}
}
getIndustry(flag, token, getIndustry) {
......@@ -213,35 +213,44 @@ class Login {
'request.preventCache': Date.now(),
})
.then(response => {
const result = response && response.code === SERVICE_INTERFACE_SUCCESS_CODE ? Array.isArray(response.data)? response.data: [] : response;
debugger
const result =
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
? Array.isArray(response.data)
? response.data
: []
: response;
if (result && result.length > 0) {
const config = result.shift();
const homeType = config.productType || 'civweb4';
// 产品类型和首页路径同时有才行
const homepage = homeType && (params.getParams('redirect') || config.homepage) ? homeType + '/' + (params.getParams('redirect') || config.homepage) : '';
const homepage =
homeType && (params.getParams('redirect') || config.homepage)
? `${homeType}/${params.getParams('redirect') || config.homepage}`
: '';
self.globalConfig = Object.assign(self.globalConfig, config, {
theme: self.globalConfig.theme,
menu: self.globalConfig.menu,
style: self.globalConfig.style,
homepage: homepage
homepage: homepage || '',
// mapsettings: config.mapsettings
});
if(self.globalConfig.hasOwnProperty('webConfig')) {
self.globalConfig = {
// eslint-disable-next-line no-prototype-builtins
if (self.globalConfig.hasOwnProperty('webConfig')) {
self.globalConfig = Object.assign(self.globalConfig ,{
// ...self.globalConfig,
...self.globalConfig.webConfig.basicConfig,
...self.globalConfig.webConfig.optionalConfig
}
...self.globalConfig.webConfig.optionalConfig,
});
}
self.updateConfig && self.updateConfig(self.globalConfig);
self.getProjectItems().then((res) => {
self.getProjectItems().then(res => {
window.subSysCfg = {};
self.globalConfig = Object.assign(self.globalConfig, {
mapsettings: res
})
mapsettings: res,
});
result.forEach(item => {
window.subSysCfg[item.client] = item;
});
......@@ -255,7 +264,11 @@ class Login {
// this.events.removeAllListeners('loginSuccess')
// this.events.removeAllListeners('toggleIndustry')
// window.share.event = this.events;
if (self.globalConfig.userInfo && self.globalConfig.userInfo.site &&self.globalConfig.userInfo.site.length > 0) {
if (
self.globalConfig.userInfo &&
self.globalConfig.userInfo.site &&
self.globalConfig.userInfo.site.length > 0
) {
// eslint-disable-next-line no-undef,no-underscore-dangle
getWebSiteConfig(
......@@ -269,7 +282,6 @@ class Login {
)
// eslint-disable-next-line no-shadow
.then(response => {
const resultData =
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
? Array.isArray(response.data)
......@@ -280,7 +292,9 @@ class Login {
const mainConf = resultData.shift();
const mainType = mainConf.productType || 'civweb4';
if (mainConf.homepage)
self.globalConfig.homepage = `${mainType}/${mainConf.homepage}`;
self.globalConfig.homepage = `${mainType}/${
mainConf.homepage
}`;
if (mainConf.bannerLogo)
self.globalConfig.bannerLogo = mainConf.bannerLogo;
if (mainConf.logo) self.globalConfig.logo = mainConf.logo;
......@@ -302,7 +316,6 @@ class Login {
} else {
// loginSuccess
self.updateConfig && self.updateConfig(self.globalConfig);
// console.log("===loginSuccess===")
getIndustry
......@@ -372,7 +385,7 @@ class Login {
url: 'product/webgisPanda/ToggleProject/ToggleProject',
});
}
debugger
debugger;
if (layer.areaName) {
this.globalConfig.mapsettings.areasettings.areaName = layer.areaName;
}
......@@ -430,7 +443,6 @@ class Login {
}
goLogin() {
if (
this.globalConfig.style === 'ios' &&
this.globalConfig.loginTemplate === 'IOSCloud.html'
......@@ -617,14 +629,14 @@ class Login {
expiration: this.globalConfig.expiration, // token过期时间(单位:秒)
client: 'referer',
username: usr,
password: params.getParams('generateType') ? pwd : sha1(pwd).toUpperCase(),
password: params.getParams('generateType')
? pwd
: sha1(pwd).toUpperCase(),
referer: this.globalConfig.client,
skipMenuTest: 1,
generateType: params.getParams('generateType') || ''
generateType: params.getParams('generateType') || '',
})
.then(response => {
// self.globalConfig.layout = 'blank';
if (response && response.token) {
const tk = response.token;
......@@ -642,18 +654,14 @@ class Login {
)
// eslint-disable-next-line no-shadow
.then(response => {
try {
if (response && !response.errMsg) {
self.globalConfig.userInfo = Object.assign(
{},
response,
);
if(response.hasOwnProperty('data')) {
self.globalConfig.userInfo = Object.assign({}, response);
if (response.hasOwnProperty('data')) {
self.globalConfig.userInfo = {
// ... self.globalConfig.userInfo,
...response.data
}
...response.data,
};
}
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
......@@ -666,7 +674,7 @@ class Login {
Cookies.set('token', tk, {
expires: date,
path: '/',
})
});
// self.globalConfig.Industry = industry;
self.isSignIn = true;
......
......@@ -64,7 +64,7 @@ const generRotes = (widgets, parent, level = 0) => {
const path = `/civweb/${guid('web_console')}`;
const subKey = guid('panda');
const alias = DEFAULT_APPLICATION;
const convertURL = transformURL(item.icon.replace(/\s*/g, ''));
const convertURL = item.icon ? transformURL(item.icon.replace(/\s*/g, '')): '';
const icon = (item && item.icon && item.icon !== null &&
isAbsoluteURL(convertURL) ? convertURL: /(\\|\/)/.test(convertURL) ?
window.globalConfig.transformDevAssetsBaseURL(transformURL(item.icon.replace(/\s*/g, ''))): item.icon
......@@ -164,7 +164,7 @@ export const transformWidgets = (widgets) => {
return widgets.map(item => {
const widgets = item.widgets;
const homepage = window.globalConfig.homepage;
const homePageConvertArray = homepage.split("/");
const homePageConvertArray = homepage ? homepage.split("/"): [];
const findIndex = widgets && widgets.findIndex(item => item.label === '系统菜单组');
if(findIndex === -1 && homePageConvertArray[0] !== 'civweb4') {
const index = widgets.findIndex(item => item.label === '首页');
......
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