fix(auth/user-center): 修复个人登录回跳并兼容旧入口
This commit is contained in:
+11
-1
@@ -1,6 +1,6 @@
|
|||||||
# 变更记录(CHANGELOG)
|
# 变更记录(CHANGELOG)
|
||||||
|
|
||||||
> 状态:有效(持续追加) · 更新:2026-11-30 · 版本:v3.17
|
> 状态:有效(持续追加) · 更新:2026-12-01 · 版本:v3.18
|
||||||
|
|
||||||
对现状仍有影响的功能与修复记录,按日期倒序。改造、迁移、优化等一次性过程不在此记录。
|
对现状仍有影响的功能与修复记录,按日期倒序。改造、迁移、优化等一次性过程不在此记录。
|
||||||
|
|
||||||
@@ -8,6 +8,16 @@
|
|||||||
|
|
||||||
**记录规则**:每条写“范围、变更、影响、回滚、关联”五项;回滚优先 `git revert <提交>`,提交含多项改动时按文件还原(`git checkout <提交>^ -- <文件>`),不整仓 reset。本文不作为规则依据。
|
**记录规则**:每条写“范围、变更、影响、回滚、关联”五项;回滚优先 `git revert <提交>`,提交含多项改动时按文件还原(`git checkout <提交>^ -- <文件>`),不整仓 reset。本文不作为规则依据。
|
||||||
|
|
||||||
|
## 2026-12-01
|
||||||
|
|
||||||
|
### 修复个人登录回跳旧版用户中心地址
|
||||||
|
|
||||||
|
- **范围** 个人登录回跳、旧版用户中心入口与个人设置。
|
||||||
|
- **变更** 第三方账号绑定成功或回调缺少授权码时统一返回 `/user/center`,由该入口在登录后进入用户中心首个可见页面。`/console/personal` 保留为旧个人设置链接,登录后转到 `/user-center/settings`。旧链接跳转保留查询参数和片段标识。
|
||||||
|
- **影响** 个人账号可从旧链接进入用户中心,页面可见性继续由用户中心配置决定,控制台管理页面继续使用原有权限守卫。
|
||||||
|
- **回滚** 按差异还原 `src/App.jsx`、`src/pages/UserCenter/index.jsx`、`src/components/auth/OAuth2Callback.jsx` 和本条目。
|
||||||
|
- **关联** `docs/ui/USER_CENTER_SPEC.md` 第 1 节。
|
||||||
|
|
||||||
## 2026-11-30
|
## 2026-11-30
|
||||||
|
|
||||||
### 权限重构验收手册移除 E2、T 账号验收项
|
### 权限重构验收手册移除 E2、T 账号验收项
|
||||||
|
|||||||
+24
-35
@@ -6,12 +6,7 @@ import {
|
|||||||
} from './helpers/miniProgram';
|
} from './helpers/miniProgram';
|
||||||
import Loading from './components/common/ui/Loading';
|
import Loading from './components/common/ui/Loading';
|
||||||
import { CenterRouteLoading } from './components/layout/components/CenterSidebarLoading';
|
import { CenterRouteLoading } from './components/layout/components/CenterSidebarLoading';
|
||||||
import {
|
import { AuthRedirect, PrivateRoute, RootRoute } from './helpers/auth';
|
||||||
AuthRedirect,
|
|
||||||
PrivateRoute,
|
|
||||||
AdminRoute,
|
|
||||||
RootRoute,
|
|
||||||
} from './helpers/auth';
|
|
||||||
import { PermRoute, ConsoleRoute, ConsoleIndexRoute } from './authz';
|
import { PermRoute, ConsoleRoute, ConsoleIndexRoute } from './authz';
|
||||||
import NotFound from './pages/NotFound';
|
import NotFound from './pages/NotFound';
|
||||||
import Forbidden from './pages/Forbidden';
|
import Forbidden from './pages/Forbidden';
|
||||||
@@ -76,9 +71,6 @@ const Task = lazy(() => import('./pages/Task'));
|
|||||||
const ModelPage = lazy(() => import('./pages/Model'));
|
const ModelPage = lazy(() => import('./pages/Model'));
|
||||||
const Playground = lazy(() => import('./pages/Playground'));
|
const Playground = lazy(() => import('./pages/Playground'));
|
||||||
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
|
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
|
||||||
const PersonalSetting = lazy(
|
|
||||||
() => import('./components/settings/PersonalSetting'),
|
|
||||||
);
|
|
||||||
const Setup = lazy(() => import('./pages/Setup'));
|
const Setup = lazy(() => import('./pages/Setup'));
|
||||||
const Analytics = lazy(() => import('./pages/Analytics'));
|
const Analytics = lazy(() => import('./pages/Analytics'));
|
||||||
const SmartRouter = lazy(() => import('./pages/SmartRouter'));
|
const SmartRouter = lazy(() => import('./pages/SmartRouter'));
|
||||||
@@ -145,20 +137,10 @@ const PricingLegacyRedirect = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 密钥管理旧路径 /key-management → /user-center/key-management,同样保留 query/hash
|
// 用户中心旧地址保留登录回跳、分享链接及书签中的参数。
|
||||||
// (如创作台 ?from=creation_studio 埋点来源、旧书签与登录回跳带参)
|
const UserCenterLegacyRedirect = ({ to }) => {
|
||||||
const KeyManagementLegacyRedirect = () => {
|
const { search, hash } = useLocation();
|
||||||
const location = useLocation();
|
return <Navigate to={{ pathname: to, search, hash }} replace />;
|
||||||
return (
|
|
||||||
<Navigate
|
|
||||||
to={{
|
|
||||||
pathname: '/user-center/key-management',
|
|
||||||
search: location.search,
|
|
||||||
hash: location.hash,
|
|
||||||
}}
|
|
||||||
replace
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -726,16 +708,6 @@ function App() {
|
|||||||
</ConsoleRoute>
|
</ConsoleRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
|
||||||
path='/console/personal'
|
|
||||||
element={
|
|
||||||
<AdminRoute>
|
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
|
||||||
<PersonalSetting />
|
|
||||||
</Suspense>
|
|
||||||
</AdminRoute>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route
|
<Route
|
||||||
path='/console/topup'
|
path='/console/topup'
|
||||||
element={
|
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
|
<Route
|
||||||
path='/key-management'
|
path='/key-management'
|
||||||
element={<KeyManagementLegacyRedirect />}
|
element={
|
||||||
|
<UserCenterLegacyRedirect to='/user-center/key-management' />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/user-center/key-management'
|
path='/user-center/key-management'
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const OAuth2Callback = (props) => {
|
|||||||
|
|
||||||
if (message === 'bind') {
|
if (message === 'bind') {
|
||||||
showSuccess(t('绑定成功!'));
|
showSuccess(t('绑定成功!'));
|
||||||
navigate('/console/personal');
|
navigate('/user/center', { replace: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ const OAuth2Callback = (props) => {
|
|||||||
// 参数缺失直接返回
|
// 参数缺失直接返回
|
||||||
if (!code) {
|
if (!code) {
|
||||||
showError(t('未获取到授权码'));
|
showError(t('未获取到授权码'));
|
||||||
navigate('/console/personal');
|
navigate('/user/center', { replace: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,8 +137,9 @@ const UserCenter = ({ keyManagementMode = false }) => {
|
|||||||
userGroup,
|
userGroup,
|
||||||
firstRoute,
|
firstRoute,
|
||||||
} = useUserCenterRoutes();
|
} = useUserCenterRoutes();
|
||||||
|
const { pathname, search, hash } = useLocation();
|
||||||
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
|
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
|
||||||
const ucRoute = useLocation().pathname.split('/')[2] || 'dashboard';
|
const ucRoute = pathname.split('/')[2] || 'dashboard';
|
||||||
|
|
||||||
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
||||||
const { visible: hasMarquee } = useMarquee();
|
const { visible: hasMarquee } = useMarquee();
|
||||||
@@ -177,7 +178,12 @@ const UserCenter = ({ keyManagementMode = false }) => {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route
|
||||||
path='/'
|
path='/'
|
||||||
element={<Navigate to={firstVisibleRoute} replace />}
|
element={
|
||||||
|
<Navigate
|
||||||
|
to={{ pathname: firstVisibleRoute, search, hash }}
|
||||||
|
replace
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='dashboard'
|
path='dashboard'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const StatusContext = {};
|
|||||||
const UserContext = {};
|
const UserContext = {};
|
||||||
let config;
|
let config;
|
||||||
let userGroup = 'default';
|
let userGroup = 'default';
|
||||||
|
let location = { pathname: '/user-center/service-dashboard' };
|
||||||
const mocks = {
|
const mocks = {
|
||||||
react: {
|
react: {
|
||||||
...React,
|
...React,
|
||||||
@@ -24,7 +25,7 @@ const mocks = {
|
|||||||
Route: 'route',
|
Route: 'route',
|
||||||
Navigate: 'navigate',
|
Navigate: 'navigate',
|
||||||
Link: 'link',
|
Link: 'link',
|
||||||
useLocation: () => ({ pathname: '/user-center/service-dashboard' }),
|
useLocation: () => location,
|
||||||
useNavigate: () => () => {},
|
useNavigate: () => () => {},
|
||||||
},
|
},
|
||||||
'react-i18next': { useTranslation: () => ({ t: (value) => value }) },
|
'react-i18next': { useTranslation: () => ({ t: (value) => value }) },
|
||||||
@@ -151,6 +152,11 @@ for (const [name, userCenter, group, visible] of [
|
|||||||
}
|
}
|
||||||
|
|
||||||
test('service dashboard can be the only enabled default route without a redirect loop', () => {
|
test('service dashboard can be the only enabled default route without a redirect loop', () => {
|
||||||
|
location = {
|
||||||
|
pathname: '/user-center',
|
||||||
|
search: '?from=bookmark',
|
||||||
|
hash: '#top',
|
||||||
|
};
|
||||||
config = JSON.stringify({
|
config = JSON.stringify({
|
||||||
userCenter: {
|
userCenter: {
|
||||||
...Object.fromEntries(
|
...Object.fromEntries(
|
||||||
@@ -164,7 +170,14 @@ test('service dashboard can be the only enabled default route without a redirect
|
|||||||
});
|
});
|
||||||
const nodes = descendants(UserCenter({}));
|
const nodes = descendants(UserCenter({}));
|
||||||
const route = nodes.find((node) => node.props.path === '/');
|
const route = nodes.find((node) => node.props.path === '/');
|
||||||
assert.equal(route.props.element.props.to, '/user-center/service-dashboard');
|
assert.deepEqual(
|
||||||
|
{ ...route.props.element.props.to },
|
||||||
|
{
|
||||||
|
pathname: '/user-center/service-dashboard',
|
||||||
|
search: location.search,
|
||||||
|
hash: location.hash,
|
||||||
|
},
|
||||||
|
);
|
||||||
const service = nodes.find((node) => node.props.path === 'service-dashboard');
|
const service = nodes.find((node) => node.props.path === 'service-dashboard');
|
||||||
assert.ok(
|
assert.ok(
|
||||||
descendants(service.props.element).some(
|
descendants(service.props.element).some(
|
||||||
|
|||||||
Reference in New Issue
Block a user