Commit 54f969e0 authored by 周宏民's avatar 周宏民

pref: 集成登录支持 站内跳转到指定功能

parent a1fc4dec
Pipeline #93673 passed with stages
...@@ -15,6 +15,7 @@ import { defaultApp } from '@/micro'; ...@@ -15,6 +15,7 @@ import { defaultApp } from '@/micro';
import { useHistory } from '@wisdom-utils/runtime'; import { useHistory } from '@wisdom-utils/runtime';
import LoadPage from '@/components/LoadPage'; import LoadPage from '@/components/LoadPage';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base'; import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { goToPath } from '@/utils/utils';
import styles from './index.less'; import styles from './index.less';
const IntegratedSwitch = props => { const IntegratedSwitch = props => {
...@@ -26,6 +27,7 @@ const IntegratedSwitch = props => { ...@@ -26,6 +27,7 @@ const IntegratedSwitch = props => {
const [dataList, setDataList] = useState([]); const [dataList, setDataList] = useState([]);
const [client, setClient] = useState(''); const [client, setClient] = useState('');
const clientRef = useRef(props.global.client); const clientRef = useRef(props.global.client);
const clientInfo = useRef({}); // 跳转子站信息
const [jumpLoading, setJumpLoading] = useState(false); const [jumpLoading, setJumpLoading] = useState(false);
const [progressValue, setProgressValue] = useState(0); const [progressValue, setProgressValue] = useState(0);
...@@ -139,7 +141,13 @@ const IntegratedSwitch = props => { ...@@ -139,7 +141,13 @@ const IntegratedSwitch = props => {
} }
} }
} else if (item.subType === '内链') { } else if (item.subType === '内链') {
const cli = item.appKey; const cli = item.client;
if (item.client === props.global.client) {
if (item.url) {
goToPath(clientInfo.current?.url);
return;
}
}
const token = props.global?.token || Cookies.get('token'); const token = props.global?.token || Cookies.get('token');
getWebSiteConfig({ getWebSiteConfig({
identity: token, identity: token,
...@@ -245,6 +253,9 @@ const IntegratedSwitch = props => { ...@@ -245,6 +253,9 @@ const IntegratedSwitch = props => {
<li <li
className={styles.switchPageLi} className={styles.switchPageLi}
onClick={() => { onClick={() => {
const integrationClient = localStorage.getItem('integrationClient');
sessionStorage.setItem('client', integrationClient);
localStorage.removeItem('integrationClient');
history.push('/industry'); history.push('/industry');
}} }}
> >
...@@ -254,21 +265,18 @@ const IntegratedSwitch = props => { ...@@ -254,21 +265,18 @@ const IntegratedSwitch = props => {
</Tooltip> </Tooltip>
</div> </div>
</li> </li>
{dataList.map(item => { {dataList.map(item => (
if (item.subType === '内链' && item.appKey === props?.global?.client) return null; <li className={styles.switchPageLi} key={item.name} onClick={event => handlePage(item, loginAction)}>
return ( <div className={styles.switchPageList}>
<li className={styles.switchPageLi} key={item.name} onClick={event => handlePage(item, loginAction)}> <Tooltip placement="top" title={item.name}>
<div className={styles.switchPageList}> <img
<Tooltip placement="top" title={item.name}> src={`${window.location.origin}/${item.icon ? item.icon : 'center/images/科技风/二供.png'}`}
<img alt=""
src={`${window.location.origin}/${item.icon ? item.icon : 'center/images/科技风/二供.png'}`} />
alt="" </Tooltip>
/> </div>
</Tooltip> </li>
</div> ))}
</li>
);
})}
</ul> </ul>
</div> </div>
) : null; ) : null;
......
...@@ -8,7 +8,7 @@ import { appService } from '@/api'; ...@@ -8,7 +8,7 @@ import { appService } from '@/api';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
import axios from 'axios'; import axios from 'axios';
import { getImageUrl } from '@/utils/utils'; import { getImageUrl, goToPath } from '@/utils/utils';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base'; import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons'; import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
...@@ -41,6 +41,7 @@ const IntegrationNew = props => { ...@@ -41,6 +41,7 @@ const IntegrationNew = props => {
const timer3 = useRef(null); const timer3 = useRef(null);
const timer4 = useRef(null); const timer4 = useRef(null);
const clientRef = useRef(props.global.client); const clientRef = useRef(props.global.client);
const clientInfo = useRef({}); // 跳转子站信息
const progressRef2 = useRef(0); const progressRef2 = useRef(0);
const loadingTime = integratedConfig?.loadingTime || 5; const loadingTime = integratedConfig?.loadingTime || 5;
const [loginAction, setAction] = useState(() => new LoginAction(props)); const [loginAction, setAction] = useState(() => new LoginAction(props));
...@@ -192,6 +193,7 @@ const IntegrationNew = props => { ...@@ -192,6 +193,7 @@ const IntegrationNew = props => {
}); });
return; return;
} }
clientInfo.current = item;
if (window.qiankunIsCache) { if (window.qiankunIsCache) {
store.set('event:dropCache'); store.set('event:dropCache');
} }
...@@ -343,9 +345,13 @@ const IntegrationNew = props => { ...@@ -343,9 +345,13 @@ const IntegrationNew = props => {
setJumpLoading(false); setJumpLoading(false);
jumpProgressEnd(); jumpProgressEnd();
window.jumpLoadingProgress = 0; window.jumpLoadingProgress = 0;
props.history.push(`/?client=${clientRef.current || props.global.client}`); if (clientInfo.current?.url && clientInfo.current.subType === '内链') {
props.updateCurrentIndex && props.updateCurrentIndex(0); goToPath(clientInfo.current?.url);
defaultApp(); } else {
props.history.push(`/?client=${clientRef.current || props.global.client}`);
props.updateCurrentIndex && props.updateCurrentIndex(0);
defaultApp();
}
}; };
const handleError = () => { const handleError = () => {
......
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import pathRegexp from 'path-to-regexp'; import pathRegexp from 'path-to-regexp';
import { parse } from 'querystring'; import { parse } from 'querystring';
import { cloneDeep } from 'lodash';
import pkg from '../../package.json'; import pkg from '../../package.json';
/* eslint no-useless-escape:0 import/prefer-default-export:0 */ /* eslint no-useless-escape:0 import/prefer-default-export:0 */
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
...@@ -107,3 +109,51 @@ export const getImageUrl = path => { ...@@ -107,3 +109,51 @@ export const getImageUrl = path => {
return `/PandaOMS/OMS/FileCenter/DownLoadFiles?module=图库&filePath=${encodeURIComponent(path)}`; return `/PandaOMS/OMS/FileCenter/DownLoadFiles?module=图库&filePath=${encodeURIComponent(path)}`;
}; };
/**
* 跳转到指定页面
* @param {*} path 功能地址
*/
export const goToPath = (path, data, widgetId, mode) => {
const routes = window.globalConfig?.allWidgets || [];
let info = null;
const target = path.substr(0, 1) === '/' ? path.slice(1) : path;
function urlSearch(arr) {
arr.forEach(a => {
if (a.url) {
if (a.url.indexOf(target) > -1 && (!widgetId || a.url.indexOf(widgetId) > -1)) {
// 跳转到指定板块功能
if (mode) {
if (a.widgetId && a.widgetId.split('_').includes(mode)) {
info = cloneDeep(a);
}
} else {
info = cloneDeep(a);
}
}
}
if (a.widgets) {
urlSearch(a.widgets);
}
});
}
urlSearch(routes);
if (!info) return info;
info.url = info.url.substr(0, 1) === '/' ? info.url : `/${info.url}`;
let url = `/civbase/${info.product}${info.url}`;
const arr = url.split('|');
let params = {};
url = arr[0];
if (arr[1]) {
url += encodeURI(`|${arr[1]}`);
const arrObj = arr[1].split('&');
arrObj.forEach(item => {
const temp = item.split('=');
params[temp[0]] = temp[1];
});
}
params = { ...params, ...data };
params.widget = widgetId || params.widget;
console.log(params, url);
window.history.pushState(params, '', url);
};
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