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

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

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