Commit 7d920eea authored by 周宏民's avatar 周宏民

feat:弥勒集成登录 支持client

parent c5efa399
Pipeline #92457 waiting for manual action with stages
......@@ -188,8 +188,9 @@ export function updatePdCesiumView(data) {
export function logout(data) {
// eslint-disable-next-line no-undef
createStoreage.remove('PANDA_STORE');
const integrationClient = localStorage.getItem('integrationClient');
if (window.globalConfig) {
Cookies.set(window.globalConfig.client, '', {
Cookies.set(integrationClient || window.globalConfig.client, '', {
path: '/',
});
window.globalConfig.token = null;
......@@ -198,6 +199,9 @@ export function logout(data) {
window.globalConfig.baseURI = window.location.origin;
window.globalConfig.hasGateWay = false;
window.globalConfig.userInfo = null;
if (integrationClient) {
window.globalConfig.client = integrationClient;
}
window.qiankunIsCache = null;
window.qiankunStarted = false;
// window.globalConfig.hasGateWay = ;
......@@ -220,6 +224,11 @@ export function logout(data) {
Cookies.set('singleToken', '', {
path: '/',
});
// 如果有集成登录client,则 client 切换成集成登录
if (integrationClient) {
sessionStorage.setItem('client', integrationClient);
}
localStorage.removeItem('integrationClient');
localStorage.removeItem('access_token');
localStorage.removeItem('password_token');
localStorage.removeItem('password_pwdRegex');
......
......@@ -326,6 +326,8 @@ const Layout = props => {
!_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined'
? `&generateType=${generateType}`
: '';
const integrationClient = localStorage.getItem('integrationClient');
if(integrationClient) client = integrationClient
if (!isLogin) {
history.push(`/user/login?client=${client}${generateType}`, { reload: true });
clear();
......@@ -385,11 +387,14 @@ const Layout = props => {
const GetIntegrationConfig = () => {
if (first) {
const integrationClient = localStorage.getItem('integrationClient');
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window.globalConfig.userInfo?.OID ?? null,
isEnable: true,
client: integrationClient || '' // 只有指定client才能获取集成登录信息
})
.then(res => {
setFirst(false);
......
......@@ -33,28 +33,28 @@
"english": "Monitoring Center",
"label": "",
"url": "",
"client": ""
"client": "scada"
},
{
"name": "控漏管控",
"english": "Leakage control",
"label": "",
"url": "",
"client": ""
"client": "DMA"
},
{
"name": "业务中心",
"english": "Business center",
"label": "",
"url": "",
"client": ""
"client": "business"
},
{
"name": "工单中心",
"english": "Ticket center",
"label": "",
"url": "",
"client": ""
"client": "work"
}
],
"标题": "弥勒自来水公司信息化平台",
......
......@@ -36,15 +36,13 @@ const boxHeight = 930;
const IntegrationMile = props => {
const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false);
const history = useHistory();
const globalClient = window?.globalConfig?.client || 'city';
let integrationClient = window?.globalConfig?.client || 'city'; // 集成登录client
const timer2 = useRef(null);
const timer3 = useRef(null);
const timer4 = useRef(null);
const progressRef2 = useRef(0);
const [loginAction, setAction] = useState(() => new LoginAction(props));
const [dataList, setDataList] = useState([]); // 集成登录详情
const [currentType, setCurrentType] = useState('');
const [mClient, setMClient] = useState('');
const { clear } = useAliveController();
......@@ -60,6 +58,8 @@ const IntegrationMile = props => {
scale: 1,
boxHeight: 930,
});
const [integrationData, setIntegrationData] = useState({});
const [linkUrl, setLinkUrl] = useState('');
const [jumpLoading, setJumpLoading] = useState(false);
const [progressValue2, setProgressValue2] = useState(0);
......@@ -103,6 +103,35 @@ const IntegrationMile = props => {
setConfigData(data);
}
});
appService
.GetIntegratedloginSetting({
ignoreSite: true,
})
.then(res => {
const { code, data } = res;
if (data.client) {
integrationClient = data.client;
localStorage.setItem('integrationClient', data.client);
if (integrationClient) {
if (!data.client) return;
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window.globalConfig.userInfo?.OID ?? null,
isEnable: true,
client: data.client || '',
})
.then(res1 => {
const list = res1.data || [];
const obj = {};
list.forEach(d => {
obj[d.name] = true;
});
setIntegrationData(obj);
});
}
}
});
};
const onResize = () => {
if (ref?.current) {
......@@ -193,6 +222,10 @@ const IntegrationMile = props => {
}, time * 1000);
};
const onLink = (item, loginA) => {
if (!integrationData[item.name]) {
message.warning('当前账号没有权限,请联系管理人员配置');
return;
}
const { url, client } = item;
if (!url && !client) return message.warning('未配置功能路径');
if (url) {
......@@ -222,7 +255,6 @@ const IntegrationMile = props => {
sessionStorage.setItem(currentProductNew, 0);
setMClient(client);
const config = props.global;
window.qiankunStarted = false;
if (client) {
config.client = client;
......@@ -231,7 +263,7 @@ const IntegrationMile = props => {
const token = props.global?.token || Cookies.get('token');
if (!token) {
history.push(`/user/login?client=${globalClient}`, { reload: true });
history.push(`/user/login?client=${integrationClient}`, { reload: true });
clear();
props.logout();
} else {
......@@ -280,6 +312,7 @@ const IntegrationMile = props => {
}
}
};
useEffect(() => {
getData();
window.addEventListener('resize', debounce(onResize, 300));
......@@ -299,7 +332,7 @@ const IntegrationMile = props => {
timer4.current = null;
}
timer4.current = setTimeout(() => {
if ($('.CarouselRipples')) {
if ($('.CarouselRipples')?.ripples) {
$('.CarouselRipples').ripples({
resolution: 800,
dropRadius: 20, // px
......@@ -400,17 +433,17 @@ const IntegrationMile = props => {
: null}
</div>
</div>
{linkUrl && showBackBtn ? (
{showBackBtn ? (
<div
className={classNames(styles.iframeExit, 'animate__animated', 'animate__fadeIn')}
onClick={() => setLinkUrl('')}
onClick={() => props.logout()}
>
<div className={styles.iframeBackLeft}>
<img src={arrowLeftImg} alt="返回" />
</div>
<div className={styles.iframeExitIcon}>
<img src={backImg} alt="返回" />
返回
退出
</div>
</div>
) : null}
......@@ -432,6 +465,9 @@ const mapDispatchToProps = dispatch => ({
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
logout() {
dispatch(actionCreators.logout());
},
});
export default connect(
mapStateToProps,
......
......@@ -8,12 +8,12 @@
.iframeExitIcon {
position: absolute;
top: 0;
left: -45px;
right: -45px;
display: flex;
height: 44px;
width: 44px;
background: rgba(28, 94, 180, 0.95);
border-radius: 0 7px 7px 0;
border-radius: 7px 0px 0px 7px;
flex-direction: column;
justify-content: space-around;
align-items: center;
......@@ -30,11 +30,11 @@
.iframeExit:hover {
.iframeExitIcon {
left: 0;
right: 0;
}
.iframeBackLeft {
left: -15px;
right: -15px;
}
}
......@@ -42,11 +42,11 @@
.iframeBackLeft {
position: absolute;
top: 0;
left: 0;
right: 0;
width: 14px;
height: 44px;
background: rgba(28, 94, 180, 0.95);
border-radius: 0 7px 7px 0;
border-radius: 7px 0 0 7px;
display: flex;
align-items: center;
justify-content: center;
......@@ -62,8 +62,8 @@
width: 44px;
height: 44px;
position: absolute;
top: 4px;
left: 0;
top: 50px;
right: 0;
color: #FFF;
cursor: pointer;
user-select: none;
......
......@@ -141,7 +141,7 @@ const IntegratedLogin = props => {
<EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} />
</Tooltip>
{!record.isEnable ? (
<Tooltip title="用">
<Tooltip title="点击启用">
<Popconfirm
placement="left"
title={
......@@ -158,7 +158,7 @@ const IntegratedLogin = props => {
</Popconfirm>
</Tooltip>
) : (
<Tooltip title="用">
<Tooltip title="点击停用">
<Popconfirm
placement="left"
title={
......
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