Commit 77b109b9 authored by 皮倩雯's avatar 皮倩雯

fix: '集成登录嵌入web5'

parent d1717ac2
Pipeline #77711 passed with stages
......@@ -39,6 +39,8 @@ export const API = {
GET_JIANGXI_MANAGE: '/PandaWorkFlow/WorkFlow/JiangXiManage/Login', // 江西登录接口
GET_YANSHI_AUTHORITY: '/PandaCore/GCK/Demonstrate/GetYanshiAuthority', // 获取当前用户开始演示模式的所有菜单ID
IS_OPEN_YANSHI: '/PandaCore/GCK/Demonstrate/IsOpenYanshi', // 获取是否开启演示模式服务
GET_WEB_CONFIG: '/PandaOMS/OMS/GetIntegratedLoginbyName',
GET_WEB_TICKET: '/PandaOMS/OMS/GetTicketByToken',
};
const services = {
......@@ -201,6 +203,16 @@ const services = {
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
getIntegratedLoginbyName: {
url: API.GET_WEB_CONFIG,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
getTicketByToken: {
url: API.GET_WEB_TICKET,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
};
export const searchAutoCity = keywords => {
......
/* eslint-disable no-lonely-if */
import React, { useEffect, useRef, useState } from 'react';
import Iframe from 'react-iframe';
import { appService } from '@/api';
import Empty from '@wisdom-components/empty';
import axios from 'axios';
import { Spin, notification } from 'antd';
import styles from './index.less';
const IntegratedLogin = props => {
const { sysName } = props.params;
const [linkUrl, setLinkUrl] = useState('');
const [loading, setLoading] = useState(false);
const getTicket = () => {
appService.getTicketByToken({ token: window.globalConfig.token }).then(res => {
if (res.code === 0) {
return res.data;
}
});
};
// 外网通不通判断
const ping = () => {
fetch('https://www.google.com')
.then(response => {
if (response.ok) {
return true;
}
return false;
})
.catch(error => false);
};
const getUrlParam = url => {
let arrObj = url.split('?');
const params = Object.create(null);
if (arrObj.length > 1) {
arrObj = arrObj[1].split('&');
arrObj.forEach(item => {
item = item.split('=');
params[item[0]] = item[1];
});
}
return params;
};
const getSiteConfig = () => {
let ticket = '';
setLoading(true);
appService.getIntegratedLoginbyName({ sysName }).then(res => {
if (res.code === 0) {
if (res.data.AccountParam[0].value === 1) {
ticket = getTicket();
}
const parma = res.data.AccountParam[0].value === 1 ? ticket : window.globalConfig.token;
if (res.data.siteType === 1) {
// 集成SaaS平台
const userId = window.globalConfig.userInfo.OID;
axios({
method: 'get',
url: `${window.location.origin}${res.data.serviceUrl}?userId=${userId}`,
}).then(resData => {
const url = resData.data.data;
if (res.data.target === 1) {
window.open(url);
} else {
setLinkUrl(url);
}
});
} else {
// 第三方接入
const pingState = ping;
let url = '';
// 外网通
if (pingState) {
if (res.data.InternetAddress) {
url = res.data.InternetAddress;
} else {
url = res.data.IntranetAddress;
}
} else {
if (res.data.IntranetAddress) {
url = res.data.IntranetAddress;
} else {
this.$message.error('请配置内网地址');
url = res.data.InternetAddress;
return;
}
}
if (url) {
const params = getUrlParam(url);
if (JSON.stringify(params) === '{}') {
url = `${url}?${res.data.AccountParam[0].key}=${parma}`;
} else {
url = `${url}&${res.data.AccountParam[0].key}=${parma}`;
}
}
if (res.data.target === 1) {
window.open(url);
} else {
setLinkUrl(url);
}
}
setLoading(false);
} else {
setLoading(false);
notification.error({
message: '提交失败',
description: res.message,
});
}
});
};
useEffect(() => {
getSiteConfig();
}, [getSiteConfig]);
return (
<div className={styles.IntegratedLogin}>
{linkUrl !== '' ? (
<Iframe
url={linkUrl}
width="100%"
height="100%"
display="block"
position="relative"
styles={{ border: 'none' }}
/>
) : (
<Spin Spin={loading} tip="加载中..." style={{ width: '100%', height: '100%', marginTop: '300px' }} />
)}
</div>
);
};
export default IntegratedLogin;
......@@ -8,7 +8,6 @@
border: none;
}
.oper-wrap {
top: 0;
right: 0;
......@@ -19,13 +18,13 @@
.oper-btn {
cursor: pointer;
color: #FFF;
color: #fff;
position: absolute;
top: 10px;
right: 15px;
transition: right ease-in-out 0.8s;
}
.btn-fullscreen_exit {
display: block;
width: 1.2rem;
......@@ -40,5 +39,8 @@
}
}
}
}
\ No newline at end of file
}
.IntegratedLogin {
width: 100%;
height: 100%;
}
......@@ -13,6 +13,7 @@ import Login from '../pages/user/login';
import NoSecret from '../pages/user/login/noSecret';
import Notifications from '../pages/system/notifications';
import TabIframe from '../pages/system/iframe/TabWidget';
import IntegratedLogin from '../pages/system/iframe/IntegratedLogin';
import PrevieView from '../pages/system/previews/preview';
export const dyRoutes = (routes, layout, theme) => {
......@@ -100,6 +101,9 @@ export const dyRoutes = (routes, layout, theme) => {
if (/system\/previews\/preview/.test(path)) {
return <PrevieView {...routeConfig} />;
}
if (/system\/iframe\/integratedLogin/.test(path)) {
return <IntegratedLogin {...routeConfig} />;
}
},
},
],
......
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