Commit 15916b72 authored by 周宏民's avatar 周宏民

fix: 集成登录跳转前做菜单权限判断,获取子站优化

parent d6a25018
Pipeline #93634 waiting for manual action with stages
......@@ -14,6 +14,7 @@ import axios from 'axios';
import { defaultApp } from '@/micro';
import { useHistory } from '@wisdom-utils/runtime';
import LoadPage from '@/components/LoadPage';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import styles from './index.less';
const IntegratedSwitch = props => {
......@@ -74,13 +75,21 @@ const IntegratedSwitch = props => {
useEffect(() => {
// if (!window?.globalConfig?.userInfo?.OID || (!(window?.globalConfig?.isIntegration > 1) && window?.globalConfig?.Industry !== '集成登录')) return setDataList([]);
if (!window?.globalConfig?.userInfo?.OID || !(window?.globalConfig?.isIntegration >= 1)) return setDataList([]);
let list = localStorage.getItem('integrationData'); //
list = list ? JSON.parse(list) : [];
if (Array.isArray(list) && list?.length) {
setDataList(list || []);
} else {
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window?.globalConfig?.userInfo?.OID ?? null,
isEnable: true,
client:
localStorage.getItem('integrationClient') || sessionStorage.getItem('client') || props?.global?.client || '',
localStorage.getItem('integrationClient') ||
sessionStorage.getItem('client') ||
props?.global?.client ||
'',
})
.then(res => {
setDataList(res?.data || []);
......@@ -88,15 +97,16 @@ const IntegratedSwitch = props => {
.catch(err => {
setDataList([]);
});
}
}, []);
// 子站跳转
// eslint-disable-next-line no-shadow
const handlePage = useCallback((item, loginAction) => {
if (item.subType === '外链') {
setJumpLoading(true);
jumpProgressStart();
startTiming(5);
if (item.subType === '外链') {
// 营收
if (item.paramValue === 'ticket') {
// 获取临时token
......@@ -129,10 +139,27 @@ const IntegratedSwitch = props => {
}
}
} else if (item.subType === '内链') {
const cli = item.appKey;
const token = props.global?.token || Cookies.get('token');
getWebSiteConfig({
identity: token,
client: cli,
}).then(res => {
if (!res?.data?.[0]?.widgets?.length) {
message.error({
duration: 3,
content: '您没有该板块权限,请联系管理员',
});
return;
}
setJumpLoading(true);
jumpProgressStart();
startTiming(5);
if (window.qiankunIsCache) {
store.set('event:dropCache');
}
const cli = item.appKey;
Cookies.set('client', cli, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
......@@ -157,7 +184,11 @@ const IntegratedSwitch = props => {
// props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, item.type);
});
} else {
setJumpLoading(true);
jumpProgressStart();
startTiming(5);
let { url } = item;
if (url?.indexOf('{userId}') >= 0) {
url = url.replace('{userId}', window.globalConfig?.userInfo?.OID);
......@@ -173,6 +204,9 @@ const IntegratedSwitch = props => {
} else {
window.open(res.data?.data, '_blank');
}
} else {
setJumpLoading(false);
jumpProgressEnd();
}
});
}
......@@ -220,7 +254,9 @@ const IntegratedSwitch = props => {
</Tooltip>
</div>
</li>
{dataList.map(item => (
{dataList.map(item => {
if (item.subType === '内链' && item.appKey === props?.global?.client) return null;
return (
<li className={styles.switchPageLi} key={item.name} onClick={event => handlePage(item, loginAction)}>
<div className={styles.switchPageList}>
<Tooltip placement="top" title={item.name}>
......@@ -231,7 +267,8 @@ const IntegratedSwitch = props => {
</Tooltip>
</div>
</li>
))}
);
})}
</ul>
</div>
) : null;
......
......@@ -229,6 +229,7 @@ export function logout(data) {
sessionStorage.setItem('client', integrationClient);
}
localStorage.removeItem('integrationClient');
localStorage.removeItem('integrationData');
localStorage.removeItem('access_token');
localStorage.removeItem('password_token');
localStorage.removeItem('password_pwdRegex');
......
This diff is collapsed.
......@@ -9,6 +9,7 @@ import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
import axios from 'axios';
import { getImageUrl } from '@/utils/utils';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
import { message, Button } from 'antd';
......@@ -100,7 +101,7 @@ const IntegrationNew = props => {
})
.then(res1 => {
const list = res1.data || [];
list.length && localStorage.setItem('integrationData', JSON.stringify(list));
setIntegrationData(list);
});
};
......@@ -175,11 +176,24 @@ const IntegrationNew = props => {
}
};
const toClient = (item, loginA) => {
const toClient = async (item, loginA) => {
const token = props.global?.token || Cookies.get('token');
const cli = item.appKey;
const res = await getWebSiteConfig({
identity: token,
client: cli,
});
if (!res?.data?.[0]?.widgets?.length) {
message.error({
duration: 3,
content: '您没有该板块权限,请联系管理员',
});
return;
}
if (window.qiankunIsCache) {
store.set('event:dropCache');
}
const cli = item.appKey;
Cookies.set('client', cli, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
......
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