Commit 45ee5344 authored by 周宏民's avatar 周宏民

fix: 修改跳转子站指定功能时,有时不成功的bug

parent 658fdcd6
Pipeline #93716 passed with stages
......@@ -15,7 +15,7 @@ import { defaultApp } from '@/micro';
import { useHistory } from '@wisdom-utils/runtime';
import LoadPage from '@/components/LoadPage';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { goToPath } from '@/utils/utils';
import { goToPath, searchUrl } from '@/utils/utils';
import styles from './index.less';
const IntegratedSwitch = props => {
......@@ -105,6 +105,10 @@ const IntegratedSwitch = props => {
// 子站跳转
// eslint-disable-next-line no-shadow
const handlePage = useCallback((item, loginAction) => {
if (window.clientInfo) {
window.clientInfo = null;
}
if (item.subType === '外链') {
setJumpLoading(true);
jumpProgressStart();
......@@ -181,6 +185,7 @@ const IntegratedSwitch = props => {
setClient(cli);
clientRef.current = cli;
window.clientInfo = item;
const config = props.global;
config.uiwidgets = [];
config.widgets = [];
......@@ -224,9 +229,19 @@ const IntegratedSwitch = props => {
const handleToggleIndustry = event => {
setJumpLoading(false);
jumpProgressEnd();
let url = '';
const { pathname } = window.location;
if (window.clientInfo?.url && window.clientInfo.subType === '内链') {
if (pathname.indexOf('/civbase/thirdParty') === -1) {
// 上一个也是站内跳转,则可直接用 BasicLayout 里的跳转
return;
}
// 上个子站不是站外链接,可直接用跳转
url = searchUrl(window.clientInfo.url);
}
history.push(`/?client=${clientRef.current || props.global.client || ''}`);
props.updateCurrentIndex(0);
defaultApp();
defaultApp(url);
};
const handleError = () => {
setJumpLoading(false);
......
......@@ -33,14 +33,17 @@
border-radius: 14px;
overflow: hidden;
height: 8px;
width: 80px;
// width: 80px;
width: auto;
background: rgba(94, 121, 143, .65);
transition: height .5s ease;
transition: width .3s ease, height .3s ease;
margin: 0 0 6px 0;
transition-delay: 0.5s;
&:hover {
height: 50px;
width: auto;
transition-delay: 0s;
.switchPageLi {
display: flex;
......@@ -50,13 +53,17 @@
.switchPageLi {
padding: 10px;
display: none;
// display: none;
display: flex;
height: 100%;
overflow: hidden;
opacity: 0.8;
transition: all .3s ease;
transition-delay: 0.5s;
&:hover {
opacity: 1;
transition-delay: 0s;
}
}
......
......@@ -31,6 +31,7 @@ import { defaultApp } from '@/micro';
import { appService } from '@/api';
import LoginAction from '@/pages/user/login/login';
import IntegratedSwitch from '@/components/IntegratedSwitch';
import { searchUrl } from '@/utils/utils';
import Loading from '../components/Loading';
import { waterMark } from '../utils/mark';
import layoutStyles from './BasicLayout.less';
......@@ -428,9 +429,16 @@ const Layout = props => {
const handleToggleIndustry = event => {
setVisible(false);
setIntegrationLoading(false);
let url = '';
if (window.clientInfo?.url && window.clientInfo.subType === '内链') {
url = searchUrl(window.clientInfo.url);
}
props.history.push(`/?client=${window.globalConfig.client}`);
props.updateCurrentIndex(0);
defaultApp();
defaultApp(url);
if(window.clientInfo){
window.clientInfo = null
}
};
if (window?.globalConfig?.isIntegration >= 1) {
......
......@@ -8,7 +8,7 @@ import { appService } from '@/api';
import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
import axios from 'axios';
import { getImageUrl, goToPath } from '@/utils/utils';
import { getImageUrl, searchUrl } from '@/utils/utils';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
......@@ -234,7 +234,9 @@ const IntegrationNew = props => {
return;
}
const { url, client } = item;
if (window.clientInfo) {
window.clientInfo = null;
}
if (item.subType === '内链' && client) {
toClient(item, loginA);
} else {
......@@ -345,14 +347,14 @@ const IntegrationNew = props => {
setJumpLoading(false);
jumpProgressEnd();
window.jumpLoadingProgress = 0;
let url = '';
if (window.clientInfo?.url && window.clientInfo.subType === '内链') {
goToPath(window.clientInfo?.url);
url = searchUrl(window.clientInfo.url);
window.clientInfo = null;
} else {
props.history.push(`/?client=${clientRef.current || props.global.client}`);
props.updateCurrentIndex && props.updateCurrentIndex(0);
defaultApp();
}
props.history.push(`/?client=${clientRef.current || props.global.client}`);
props.updateCurrentIndex && props.updateCurrentIndex(0);
defaultApp(url);
};
const handleError = () => {
......
......@@ -3,7 +3,7 @@ import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
import { message, Button } from 'antd';
import classNames from 'classnames';
import { debounce } from 'lodash';
import { getImageUrl, goToPath } from '@/utils/utils';
import { getImageUrl, goToPath, searchUrl } from '@/utils/utils';
import React, { useRef, useEffect, useState, useMemo } from 'react';
import backImg from '@/assets/images/demonstration/返回.png';
......@@ -232,6 +232,9 @@ const IntegrationQinzhou = props => {
};
const onLink = (item, loginA) => {
if (!item) return;
if (window.clientInfo) {
window.clientInfo = null;
}
const token = props.global?.token || Cookies.get('token');
if (!token) {
history.push(`/user/login?client=${integrationClient}`, { reload: true });
......@@ -282,14 +285,14 @@ const IntegrationQinzhou = props => {
setJumpLoading(false);
jumpProgressEnd();
window.jumpLoadingProgress = 0;
let url = '';
if (window.clientInfo?.url && window.clientInfo.subType === '内链') {
goToPath(window.clientInfo?.url);
url = searchUrl(window.clientInfo.url);
window.clientInfo = null;
} else {
props.history.push(`/?client=${clientRef.current || props.global.client}`);
props.updateCurrentIndex && props.updateCurrentIndex(0);
defaultApp();
}
props.history.push(`/?client=${clientRef.current || props.global.client}`);
props.updateCurrentIndex && props.updateCurrentIndex(0);
defaultApp(url);
};
const handleError = () => {
setJumpLoading(false);
......
......@@ -158,3 +158,31 @@ export const goToPath = (path, data, widgetId, mode) => {
console.log(params, url);
window.history.pushState(params, '', url);
};
/**
* 查找功能的跳转地址
* @param {*} path 功能地址
*/
export const searchUrl = path => {
const routes = window.globalConfig?.widgets || [];
let url = '';
if (!path || !routes.length) return url;
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) {
url = a.url.substr(0, 1) === '/' ? a.url : `/${a.url}`;
url = `/civbase/${a.product}${url}`;
}
}
if (a.widgets) {
urlSearch(a.widgets);
}
});
}
urlSearch(routes);
if (!url) return url;
return 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