Commit 06123bde authored by 周宏民's avatar 周宏民

pref: 弥勒集成登录支持client

parent fc04c78b
Pipeline #92150 waiting for manual action with stages
...@@ -467,7 +467,7 @@ class Login { ...@@ -467,7 +467,7 @@ class Login {
} }
getYanshiAuthority(self, getIndustry) { getYanshiAuthority(self, getIndustry) {
self.updateConfig && self.updateConfig(self.globalConfig); // self.updateConfig && self.updateConfig(self.globalConfig);
if (self.globalConfig.widgets.length === 0) { if (self.globalConfig.widgets.length === 0) {
self.events.emit('loginError', '当前账号未配置菜单'); self.events.emit('loginError', '当前账号未配置菜单');
self.handleLoginError(); self.handleLoginError();
......
...@@ -4,49 +4,57 @@ ...@@ -4,49 +4,57 @@
"name": "领导驾驶舱", "name": "领导驾驶舱",
"english": "Leadership cockpit", "english": "Leadership cockpit",
"label": "", "label": "",
"url": "" "url": "",
"client": "BI"
}, },
{ {
"name": "营业收费", "name": "营业收费",
"english": "Operating fees", "english": "Operating fees",
"label": "", "label": "",
"url": "" "url": "",
"client": ""
}, },
{ {
"name": "OA办公", "name": "OA办公",
"english": "OA office", "english": "OA office",
"label": "", "label": "",
"url": "" "url": "",
"client": "water"
}, },
{ {
"name": "资产管理", "name": "资产管理",
"english": "Asset management", "english": "Asset management",
"label": "", "label": "",
"url": "" "url": "",
"client": "property"
}, },
{ {
"name": "在线监测", "name": "在线监测",
"english": "Monitoring Center", "english": "Monitoring Center",
"label": "", "label": "",
"url": "" "url": "",
"client": ""
}, },
{ {
"name": "控漏管控", "name": "控漏管控",
"english": "Leakage control", "english": "Leakage control",
"label": "", "label": "",
"url": "" "url": "",
"client": ""
}, },
{ {
"name": "业务中心", "name": "业务中心",
"english": "Business center", "english": "Business center",
"label": "", "label": "",
"url": "" "url": "",
"client": ""
}, },
{ {
"name": "工单中心", "name": "工单中心",
"english": "Ticket center", "english": "Ticket center",
"label": "", "label": "",
"url": "" "url": "",
"client": ""
} }
], ],
"标题": "弥勒自来水公司信息化平台", "标题": "弥勒自来水公司信息化平台",
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
* @Date: 2024-08-26 18:34:42 * @Date: 2024-08-26 18:34:42
*/ */
import { appService } from '@/api'; import { appService } from '@/api';
import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { log, params, encipher } from '@wisdom-utils/utils/lib/helpers';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons'; import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
import { message, Button } from 'antd'; import { message, Button } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
...@@ -13,8 +18,13 @@ import backImg from '@/assets/images/demonstration/返回.png'; ...@@ -13,8 +18,13 @@ import backImg from '@/assets/images/demonstration/返回.png';
import arrowLeftImg from '@/assets/images/demonstration/左箭头.png'; import arrowLeftImg from '@/assets/images/demonstration/左箭头.png';
import LoadPage from '@/components/LoadPage'; import LoadPage from '@/components/LoadPage';
import $ from 'jquery'; import $ from 'jquery';
import { connect } from 'react-redux'; import { SERVICE_INTERFACE_SUCCESS_CODE } from '@/constants';
import { useHistory, useAliveController } from '@wisdom-utils/runtime';
import { store } from '@wisdom-utils/utils';
import Cookies from 'js-cookie';
import LoginAction from '@/pages/bootpage/demonstration/components/login';
import { defaultApp } from '@/micro';
import useFullScreen from '../../demonstration/components/useFullScreen'; import useFullScreen from '../../demonstration/components/useFullScreen';
import defaultConfig from './data.json'; import defaultConfig from './data.json';
import styles from './index.less'; import styles from './index.less';
...@@ -25,10 +35,19 @@ const boxHeight = 930; ...@@ -25,10 +35,19 @@ const boxHeight = 930;
const IntegrationMile = props => { const IntegrationMile = props => {
const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false); const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false);
const history = useHistory();
const globalClient = window?.globalConfig?.client || 'city';
const timer2 = useRef(null); const timer2 = useRef(null);
const timer3 = useRef(null); const timer3 = useRef(null);
const timer4 = useRef(null); const timer4 = useRef(null);
const progressRef2 = useRef(0); 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();
// 退出 // 退出
const exit = () => { const exit = () => {
if (isFullscreen) { if (isFullscreen) {
...@@ -173,8 +192,10 @@ const IntegrationMile = props => { ...@@ -173,8 +192,10 @@ const IntegrationMile = props => {
timer2.current = null; timer2.current = null;
}, time * 1000); }, time * 1000);
}; };
const onLink = url => { const onLink = (item, loginA) => {
if (!url) return message.warning('未配置功能路径'); const { url, client } = item;
if (!url && !client) return message.warning('未配置功能路径');
if (url) {
setJumpLoading(true); setJumpLoading(true);
jumpProgressStart(); jumpProgressStart();
...@@ -184,6 +205,80 @@ const IntegrationMile = props => { ...@@ -184,6 +205,80 @@ const IntegrationMile = props => {
time = 4; time = 4;
} }
startTiming(time); startTiming(time);
}
if (client) {
if (window.qiankunIsCache) {
store.set('event:dropCache');
}
Cookies.set('client', client, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', client);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${window.globalConfig
?.client ?? 'city'}`;
sessionStorage.removeItem(currentProduct);
const currentProductNew = `__global__recent_productIndex__micro_${window.location.hostname}_${client || 'city'}`;
sessionStorage.setItem(currentProductNew, 0);
setMClient(client);
const config = props.global;
window.qiankunStarted = false;
if (client) {
config.client = client;
}
const token = props.global?.token || Cookies.get('token');
if (!token) {
history.push(`/user/login?client=${globalClient}`, { reload: true });
clear();
props.logout();
} else {
setJumpLoading(true);
jumpProgressStart();
startTiming(15);
getWebSiteConfig({
identity: token,
client,
})
.then(res => {
const data = res.data?.[0] || {};
config.uiwidgets = data.uiwidgets || [];
config.widgets = data.widgets || [];
config.allWidgets = data.widgets || [];
const homeType = config.productType || 'civweb4';
const homepage = params.getParams('homepage')
? params.getParams('homepage')
: homeType && data.homepage
? `${homeType}/${params.getParams('homepage') || data.homepage}`
: '';
config.homepage = homepage;
config.hideFeedback =
data.afterSales && typeof data.afterSales === 'string'
? data.afterSales.split(',').includes(`${props.global?.userInfo?.OID}`)
: false;
config.IsOpenTransitionPage = data.IsOpenTransitionPage || false;
config.openAnnouncement = data.openAnnouncement;
config.announcementContent = data.announcementContent;
if (!config.widgets.length) {
message.error({
duration: 3,
content: '当前账号未配置菜单',
});
setJumpLoading(false);
jumpProgressEnd();
return;
}
loginAction.updateConfig && loginAction.updateConfig(config);
loginAction && loginAction.getIndustry(true, token);
})
.catch(err => {
setJumpLoading(false);
jumpProgressEnd();
});
}
}
}; };
useEffect(() => { useEffect(() => {
getData(); getData();
...@@ -221,6 +316,29 @@ const IntegrationMile = props => { ...@@ -221,6 +316,29 @@ const IntegrationMile = props => {
} }
}; };
}, [linkUrl]); }, [linkUrl]);
useEffect(() => {
const handleToggleIndustry = event => {
setJumpLoading(false);
jumpProgressEnd();
props.updateCurrentIndex && props.updateCurrentIndex(0);
props.history.push(`/?client=${mClient || props.global.client}`);
defaultApp();
};
const handleError = () => {
setJumpLoading(false);
jumpProgressEnd();
};
loginAction.events.on('loginSuccess', handleToggleIndustry);
loginAction.events.on('loginError', handleError);
return () => {
loginAction && loginAction.events && loginAction.events.removeListener('loginSuccess', handleToggleIndustry);
loginAction && loginAction.events && loginAction.events.removeListener('loginError', handleError);
};
}, [loginAction.events, props, mClient]);
return ( return (
<div className={classNames(styles.integrationMile, 'integrationMile')} ref={ref}> <div className={classNames(styles.integrationMile, 'integrationMile')} ref={ref}>
{jumpLoading ? ( {jumpLoading ? (
...@@ -269,7 +387,7 @@ const IntegrationMile = props => { ...@@ -269,7 +387,7 @@ const IntegrationMile = props => {
{configData?.listData {configData?.listData
? configData?.listData.map(item => ( ? configData?.listData.map(item => (
<div <div
onClick={() => onLink(item.url)} onClick={() => onLink(item, loginAction)}
className={styles.IY_item} className={styles.IY_item}
key={item.name} key={item.name}
type={item.name} type={item.name}
...@@ -304,4 +422,18 @@ const IntegrationMile = props => { ...@@ -304,4 +422,18 @@ const IntegrationMile = props => {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
}); });
export default connect(mapStateToProps)(IntegrationMile); const mapDispatchToProps = dispatch => ({
updateConfig(config) {
dispatch(actionCreators.getConfig(config));
},
createContext(data) {
dispatch(actionCreators.createContext(data));
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(IntegrationMile);
...@@ -105,6 +105,9 @@ ...@@ -105,6 +105,9 @@
.integrationMile_icon { .integrationMile_icon {
margin-right: 20px; margin-right: 20px;
img{
max-height: 60px;
}
} }
......
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