Commit 32cd9c1c authored by 张瑶's avatar 张瑶

云平台网关取子站配置

parent 25c2adde
import { Modal, notification } from 'antd';
import { notification } from 'antd';
import { instanceRequest, service, event } from '@wisdom-utils/utils';
import AppService from './service/base';
import notificationService from './service/notification';
import CloudService from './service/cloud';
const { warning } = Modal;
// eslint-disable-next-line no-return-await
instanceRequest.reportCodeError = true;
instanceRequest.transformRequestURL = function(url) {
// url = url.replace(/\/GateWay/, '')
const excludeURL = [
'/PandaCore/GCK/Basis/GateWayConfig',
'/CityInterface/rest/services.svc/GetConfig',
......@@ -20,28 +17,9 @@ instanceRequest.transformRequestURL = function(url) {
if (excludeURL.includes(url)) {
return url.replace(/PandaCore\/GateWay\//, '');
}
// if (
// window.globalConfig &&
// window.globalConfig.hasGateWay &&
// /^\/(cityinterface|CityInterface|Cityinterface|CityServer|PandaInformatization)/.test(
// url,
// )
// ) {
// return /\/CityInterface\/rest\/services.svc\/GetConfig/.test(url)
// ? url
// ? /^\/GateWay/.test(url)
// ? url
// : `/GateWay${url}`
// : `/GateWay${url}`
// : `/GateWay${url}`;
// }
// if(window.globalConfig && window.globalConfig.hasGateWay) {
// return url && /^\/GateWay/.test(url) ? url : `/GateWay${url}`
// }
return url;
};
const codeMessage = {
200: '服务器成功返回请求的数据。',
201: '新建或修改数据成功。',
......@@ -60,7 +38,6 @@ const codeMessage = {
504: '网关超时。',
};
const instance = null;
instanceRequest.setErrorHandler(error => {
const { response } = error;
if (response && response.status) {
......@@ -69,11 +46,7 @@ instanceRequest.setErrorHandler(error => {
if (status === 401) {
event.emit('event:logout');
} else {
// notification.error({
// message: `请求错误 ${status}: ${config.url}`,
// description: errorText,
// });
console.log(errorText);
console.error(errorText);
}
} else if (!response) {
notification.error({
......
......@@ -25,7 +25,6 @@ import SecurityLayout from './SecurityLayout';
import Site from './Site';
const { params } = helpers;
const { getParamsV1 } = params;
// const ArcgisMap = React.lazy(() => import('../pages/map/arcgis'));
// const AMap = React.lazy(() => import('../pages/map/amap'));
......@@ -244,7 +243,9 @@ const transformFloatMenu = (routes, homepage) => {
};
const Layout = props => {
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams('client') ||
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams(
'client',
) ||
sessionStorage.getItem('client') ||
'city'}`;
const menuState = sessionStorage.getItem('menuState') || 'open';
......
......@@ -297,7 +297,7 @@ class Site {
return arr;
}
writeCookie(token, site, onChangeVisible, actionRef) {
writeCookie(token, site, onChangeVisible, actionRef, accessToken) {
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
......@@ -306,6 +306,8 @@ class Site {
path: '/',
});
localStorage.setItem('access_token', accessToken);
const encodeSite = encode(encodeURIComponent(site));
Cookies.set('site', encodeSite, {
expires: date,
......@@ -375,25 +377,55 @@ class Site {
}
beforeChangeCheck(token, site, onChangeVisible, actionRef) {
// eslint-disable-next-line no-undef
appService
.getUserInfo({
token,
subOID: 'subOID',
site,
ignoreSite: true,
})
.then(res => {
if (res && res.code === 0) {
this.writeCookie(token, site, onChangeVisible, actionRef);
} else {
message.warning('企业切换失败,请联系管理员排查问题!');
const userParam = {
token,
subOID: 'subOID',
site,
ignoreSite: true,
};
const gateWayParam = {
_site: site,
};
Promise.all([appService.getUserInfo(userParam), appService.getWateWayConfig(gateWayParam)])
.then(results => {
const res = results[0];
const gatewayRes = results[1];
if (res.code !== 0) {
this.setLoading(false);
message.error('获取用户信息失败');
}
const config = window?.globalConfig;
config.uiwidgets = [];
config.widgets = [];
config.allWidgets = [];
config.userInfo = window?.globalConfig?.transformUserInfo?.(res.data) ?? res.data;
window.globalConfig = config;
// 重置网关配置
// 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 (hasGateWay) {
appService
.authorizationToken({
loginName: config.userInfo?.loginName || '',
type: 'WorkNo',
})
.then(tokenRes => {
const accessToken = tokenRes.data?.access_token ?? null;
localStorage.setItem('access_token', accessToken);
this.writeCookie(token, site, onChangeVisible, actionRef, accessToken);
})
.catch(err => {
this.setLoading(false);
this.writeCookie(token, site, onChangeVisible, actionRef, null);
});
} else {
localStorage.setItem('access_token', null);
this.writeCookie(token, site, onChangeVisible, actionRef, null);
}
})
.catch(e => {
message.warning('企业切换失败,请联系管理员排查问题!');
.catch(err => {
this.setLoading(false);
message.warning('企业切换失败,请联系管理员排查问题!');
});
}
......
import React from 'react';
import classnames from 'classnames';
import styles from './index.less';
import cover from './images/default.png';
import { chunk } from 'lodash-es';
import cover from './images/default.png';
import styles from './index.less';
const assetPath = `${window.location.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles`;
const Card = ({onCardClick, ...props}) => {
const { config } = props;
const Card = ({ onCardClick, ...props }) => {
const { config } = props;
if(config['副标题'].indexOf('\\n') === -1){
config['副标题'] = config['副标题'] + '\\n';
if (config['副标题'].indexOf('\\n') === -1) {
config['副标题'] += '\\n';
}
if(config['系统特点'].indexOf(',') === -1){
config['系统特点'] = config['系统特点'] + ',';
if (config['系统特点'].indexOf(',') === -1) {
config['系统特点'] += ',';
}
return (
<div className={styles.card} onClick={e => onCardClick(e, props)}>
<div className={classnames(styles['card-title'], styles['nowrap-text'])}>
{config && config['标题']}
</div>
<div
key={config && config['标题'] ? config['标题'] : Math.random()}
className={styles.card}
onClick={e => onCardClick(config, props)}
>
<div className={classnames(styles['card-title'], styles['nowrap-text'])}>{config && config['标题']}</div>
<div className={classnames(styles['card-content'])}>
<div className={classnames(styles['card-img'])}>
<img src={config && config['封面图'] ? `${assetPath}?filePath=${config['封面图']}` : cover} />
<img src={config && config['封面图'] ? `${assetPath}?filePath=${config['封面图']}` : cover} alt="" />
{
config && config['系统描述'] ? (
<div className={styles.back}>
{config && config['系统描述']}
</div>
) : null
}
{config && config['系统描述'] ? <div className={styles.back}>{config && config['系统描述']}</div> : null}
</div>
<div className={classnames(styles['card-info'])}>
<div className={classnames(styles['card-desc'])}>
{
config && config['副标题'] && config && config['副标题'].split("\\n").map((item, index) => {
return <div key={index}>{item}</div>
})
}
{config &&
config['副标题'] &&
config['副标题'].split('\\n').map((item, index) => <div key={index}>{item}</div>)}
</div>
<div className={classnames(styles['card-tags'])}>
<div className={classnames(styles['card-list'])}>
{
config && config['系统特点'] && chunk(config['系统特点'].split(',') , 2).map((item, index) => {
return <div key={index} className={classnames(styles['card-list-content'])}>
{
item.map((child, key) => {
return <div className={classnames(styles['card-tag'])}
style={{
height: config['系统特点'].split(',').length <= 6 ? 44 : 40,
lineHeight: config['系统特点'].split(',').length <= 6 ? '44px' : '40px',
marginTop: config['系统特点'].split(',').length <= 8 ? 10 : 0
}} key={key + index}>
<i className={classnames(styles['card-tag-icon'])} />
{child}
</div>
})
}
{config['系统特点'] &&
chunk(config['系统特点'].split(','), 2).map((item, index) => (
<div key={index} className={classnames(styles['card-list-content'])}>
{item.map(child => (
<div
className={classnames(styles['card-tag'])}
style={{
height: config['系统特点'].split(',').length <= 6 ? 44 : 40,
lineHeight: config['系统特点'].split(',').length <= 6 ? '44px' : '40px',
marginTop: config['系统特点'].split(',').length <= 8 ? 10 : 0,
}}
key={child}
>
<i className={classnames(styles['card-tag-icon'])} />
{child}
</div>
))}
</div>
})
}
))}
</div>
</div>
</div>
</div>
......
import React from 'react';
import styles from './index.less';
import Card from './Card';
import classnames from 'classnames';
const Panel = ({ products = [], onCardClick, pageIndex, pageSize }) => {
return (
<div className={classnames(styles.panel)} num={pageIndex == 0 ? products.length : pageSize}>
{ products.map((item, index) => <Card key={index} {...item} onCardClick={onCardClick}/>)}
</div>
);
};
import Card from './Card';
import styles from './index.less';
const Panel = ({ products = [], onCardClick, pageIndex, pageSize }) => (
<div className={classnames(styles.panel)} num={pageIndex === 0 ? products.length : pageSize}>
{products.map((item, index) => (
<Card key={index} {...item} onCardClick={onCardClick} />
))}
</div>
);
export default Panel;
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