fix(auth/user-center): 修复个人登录回跳并兼容旧入口

This commit is contained in:
zhanjunhao
2026-12-01 16:07:31 +08:00
parent 7e89edda5b
commit cd6eae5ed9
5 changed files with 60 additions and 42 deletions
+24 -35
View File
@@ -6,12 +6,7 @@ import {
} from './helpers/miniProgram';
import Loading from './components/common/ui/Loading';
import { CenterRouteLoading } from './components/layout/components/CenterSidebarLoading';
import {
AuthRedirect,
PrivateRoute,
AdminRoute,
RootRoute,
} from './helpers/auth';
import { AuthRedirect, PrivateRoute, RootRoute } from './helpers/auth';
import { PermRoute, ConsoleRoute, ConsoleIndexRoute } from './authz';
import NotFound from './pages/NotFound';
import Forbidden from './pages/Forbidden';
@@ -76,9 +71,6 @@ const Task = lazy(() => import('./pages/Task'));
const ModelPage = lazy(() => import('./pages/Model'));
const Playground = lazy(() => import('./pages/Playground'));
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
const PersonalSetting = lazy(
() => import('./components/settings/PersonalSetting'),
);
const Setup = lazy(() => import('./pages/Setup'));
const Analytics = lazy(() => import('./pages/Analytics'));
const SmartRouter = lazy(() => import('./pages/SmartRouter'));
@@ -145,20 +137,10 @@ const PricingLegacyRedirect = () => {
);
};
// 密钥管理旧路径 /key-management → /user-center/key-management,同样保留 query/hash
// (如创作台 ?from=creation_studio 埋点来源、旧书签与登录回跳带参)
const KeyManagementLegacyRedirect = () => {
const location = useLocation();
return (
<Navigate
to={{
pathname: '/user-center/key-management',
search: location.search,
hash: location.hash,
}}
replace
/>
);
// 用户中心旧地址保留登录回跳、分享链接及书签中的参数。
const UserCenterLegacyRedirect = ({ to }) => {
const { search, hash } = useLocation();
return <Navigate to={{ pathname: to, search, hash }} replace />;
};
function App() {
@@ -726,16 +708,6 @@ function App() {
</ConsoleRoute>
}
/>
<Route
path='/console/personal'
element={
<AdminRoute>
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
<PersonalSetting />
</Suspense>
</AdminRoute>
}
/>
<Route
path='/console/topup'
element={
@@ -820,10 +792,27 @@ function App() {
)
}
/>
{/* 密钥管理归入用户中心路径;旧地址保留为重定向(旧链接、登录回跳、书签) */}
<Route
path='/console/personal'
element={
<PrivateRoute>
<UserCenterLegacyRedirect to='/user-center/settings' />
</PrivateRoute>
}
/>
<Route
path='/user/center'
element={
<PrivateRoute>
<UserCenterLegacyRedirect to='/user-center' />
</PrivateRoute>
}
/>
<Route
path='/key-management'
element={<KeyManagementLegacyRedirect />}
element={
<UserCenterLegacyRedirect to='/user-center/key-management' />
}
/>
<Route
path='/user-center/key-management'