fix: append search parameters to navigation paths for legacy route compatibility

This commit is contained in:
Zeke Zhang 2025-03-06 17:22:51 +08:00
parent 1abd11d0a1
commit f2bbb406e6
2 changed files with 5 additions and 6 deletions

View File

@ -11,7 +11,7 @@ import { EllipsisOutlined } from '@ant-design/icons';
import ProLayout, { RouteContext, RouteContextType } from '@ant-design/pro-layout';
import { HeaderViewProps } from '@ant-design/pro-layout/es/components/Header';
import { css } from '@emotion/css';
import { ConfigProvider, Popover, Tooltip } from 'antd';
import { Popover, Tooltip } from 'antd';
import React, { createContext, FC, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import ReactDOM from 'react-dom';
import { Link, Navigate, Outlet, useLocation } from 'react-router-dom';
@ -29,13 +29,12 @@ import {
RemoteSchemaTemplateManagerProvider,
SortableItem,
useDesignable,
useGlobalTheme,
useMenuDragEnd,
useParseURLAndParams,
useRequest,
useSchemaInitializerRender,
useSystemSettings,
useToken,
useToken
} from '../../../';
import {
CurrentPageUidProvider,
@ -72,7 +71,7 @@ const AllAccessDesktopRoutesContext = createContext<{
refresh: () => void;
}>({
allAccessRoutes: emptyArray,
refresh: () => {},
refresh: () => { },
});
AllAccessDesktopRoutesContext.displayName = 'AllAccessDesktopRoutesContext';
@ -636,7 +635,7 @@ const LegacyRouteCompat: FC = (props) => {
const location = useLocationNoUpdate();
if (route) {
return <Navigate to={location.pathname.replace(currentPageUid, route.schemaUid)} />;
return <Navigate to={location.pathname.replace(currentPageUid, route.schemaUid) + location.search} />;
}
return <>{props.children}</>;

View File

@ -215,7 +215,7 @@ const InternalPageContent = (props: PageContentProps) => {
// 兼容旧版本的 tab 路径
const oldTab = currentRoute?.children?.find((tabRoute) => tabRoute.tabSchemaName === activeKey);
if (oldTab) {
navigate(location.pathname.replace(activeKey, oldTab.schemaUid));
navigate(location.pathname.replace(activeKey, oldTab.schemaUid) + location.search);
return null;
}