fix(layout): 修复顶栏连点和头像菜单抖动,统一三中心侧栏加载态
This commit is contained in:
+11
-1
@@ -1,6 +1,6 @@
|
|||||||
# 变更记录(CHANGELOG)
|
# 变更记录(CHANGELOG)
|
||||||
|
|
||||||
> 状态:有效(持续追加) · 更新:2026-11-26 · 版本:v3.14
|
> 状态:有效(持续追加) · 更新:2026-11-27 · 版本:v3.15
|
||||||
|
|
||||||
对现状仍有影响的功能与修复记录,按日期倒序。改造、迁移、优化等一次性过程不在此记录。
|
对现状仍有影响的功能与修复记录,按日期倒序。改造、迁移、优化等一次性过程不在此记录。
|
||||||
|
|
||||||
@@ -8,6 +8,16 @@
|
|||||||
|
|
||||||
**记录规则**:每条写“范围、变更、影响、回滚、关联”五项;回滚优先 `git revert <提交>`,提交含多项改动时按文件还原(`git checkout <提交>^ -- <文件>`),不整仓 reset。本文不作为规则依据。
|
**记录规则**:每条写“范围、变更、影响、回滚、关联”五项;回滚优先 `git revert <提交>`,提交含多项改动时按文件还原(`git checkout <提交>^ -- <文件>`),不整仓 reset。本文不作为规则依据。
|
||||||
|
|
||||||
|
## 2026-11-27
|
||||||
|
|
||||||
|
### 修复顶栏连点、侧栏加载和头像菜单交互
|
||||||
|
|
||||||
|
- **范围** 全站主导航、用户中心、控制台、企业中心和顶栏头像菜单。
|
||||||
|
- **变更** 当前目标跳过重复导航,快速切换保留最新目标。三个中心复用侧栏加载占位。头像菜单统一处理悬停、点击和关闭。
|
||||||
|
- **影响** 侧栏加载前后保持对应的宽度和底部位置,已在默认目标页时连点顶栏不再产生路由变更。
|
||||||
|
- **回滚** 恢复本次变更涉及的主导航、侧栏加载和头像菜单文件。
|
||||||
|
- **关联** 全站 UI 基线第 4 节。
|
||||||
|
|
||||||
## 2026-11-26
|
## 2026-11-26
|
||||||
|
|
||||||
### 统一智能路由的判定模型文案
|
### 统一智能路由的判定模型文案
|
||||||
|
|||||||
+9
-5
@@ -5,6 +5,7 @@ import {
|
|||||||
isMiniProgramWebView,
|
isMiniProgramWebView,
|
||||||
} 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 {
|
import {
|
||||||
AuthRedirect,
|
AuthRedirect,
|
||||||
PrivateRoute,
|
PrivateRoute,
|
||||||
@@ -829,14 +830,17 @@ function App() {
|
|||||||
moduleAuthConfig.keyManagement ? (
|
moduleAuthConfig.keyManagement ? (
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={<Loading></Loading>}
|
fallback={<CenterRouteLoading />}
|
||||||
key={location.pathname}
|
key={location.pathname}
|
||||||
>
|
>
|
||||||
<UserCenter keyManagementMode />
|
<UserCenter keyManagementMode />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
) : (
|
) : (
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
<Suspense
|
||||||
|
fallback={<CenterRouteLoading />}
|
||||||
|
key={location.pathname}
|
||||||
|
>
|
||||||
<UserCenter keyManagementMode />
|
<UserCenter keyManagementMode />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
@@ -847,12 +851,12 @@ function App() {
|
|||||||
element={
|
element={
|
||||||
moduleAuthConfig.userCenter ? (
|
moduleAuthConfig.userCenter ? (
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
<Suspense fallback={<Loading></Loading>}>
|
<Suspense fallback={<CenterRouteLoading />}>
|
||||||
<UserCenter />
|
<UserCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
) : (
|
) : (
|
||||||
<Suspense fallback={<Loading></Loading>}>
|
<Suspense fallback={<CenterRouteLoading />}>
|
||||||
<UserCenter />
|
<UserCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
@@ -956,7 +960,7 @@ function App() {
|
|||||||
element={
|
element={
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
{isOrgCenterAvailable ? (
|
{isOrgCenterAvailable ? (
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<CenterRouteLoading />}>
|
||||||
<Organization />
|
<Organization />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import App from '../../App';
|
|||||||
import React, {
|
import React, {
|
||||||
useContext,
|
useContext,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
useState,
|
useState,
|
||||||
lazy,
|
lazy,
|
||||||
Suspense,
|
Suspense,
|
||||||
useRef,
|
useRef,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||||
|
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||||
|
import { CenterSidebarLoading } from './components/CenterSidebarLoading';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { API } from '../../helpers/api';
|
import { API } from '../../helpers/api';
|
||||||
import { isAuthPagePath } from '../../helpers/auth';
|
import { isAuthPagePath } from '../../helpers/auth';
|
||||||
@@ -62,6 +65,7 @@ const PageLayout = () => {
|
|||||||
const [userState, userDispatch] = useContext(UserContext);
|
const [userState, userDispatch] = useContext(UserContext);
|
||||||
const [, statusDispatch] = useContext(StatusContext);
|
const [, statusDispatch] = useContext(StatusContext);
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
const [collapsed] = useSidebarCollapsed();
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -120,6 +124,10 @@ const PageLayout = () => {
|
|||||||
const headerBarHeight = isMobile ? 56 : 72;
|
const headerBarHeight = isMobile ? 56 : 72;
|
||||||
const totalHeaderHeight = headerBarHeight + marqueeHeight;
|
const totalHeaderHeight = headerBarHeight + marqueeHeight;
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
document.body.classList.toggle('sidebar-collapsed', collapsed);
|
||||||
|
}, [collapsed]);
|
||||||
|
|
||||||
// 滚动容器引用
|
// 滚动容器引用
|
||||||
const scrollContainerRef = useRef(null);
|
const scrollContainerRef = useRef(null);
|
||||||
const authBootstrappedRef = useRef(false);
|
const authBootstrappedRef = useRef(false);
|
||||||
@@ -155,7 +163,7 @@ const PageLayout = () => {
|
|||||||
// 顶栏总高(顶栏 + 跑马灯)发布成全局 CSS 变量。
|
// 顶栏总高(顶栏 + 跑马灯)发布成全局 CSS 变量。
|
||||||
// 顶栏是 position:fixed,内容区从视口 0 开始流动,任何 `sticky top-0` 的页内元素
|
// 顶栏是 position:fixed,内容区从视口 0 开始流动,任何 `sticky top-0` 的页内元素
|
||||||
// 都会吸到顶栏底下被盖住。页面无从得知跑马灯开没开,只能由这里统一给出。
|
// 都会吸到顶栏底下被盖住。页面无从得知跑马灯开没开,只能由这里统一给出。
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
root.style.setProperty('--app-header-height', `${totalHeaderHeight}px`);
|
root.style.setProperty('--app-header-height', `${totalHeaderHeight}px`);
|
||||||
}, [totalHeaderHeight]);
|
}, [totalHeaderHeight]);
|
||||||
@@ -408,7 +416,11 @@ const PageLayout = () => {
|
|||||||
: undefined,
|
: undefined,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Suspense fallback={null}>
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<CenterSidebarLoading forceExpanded={siderForceExpanded} />
|
||||||
|
}
|
||||||
|
>
|
||||||
<SiderBar
|
<SiderBar
|
||||||
forceExpanded={siderForceExpanded}
|
forceExpanded={siderForceExpanded}
|
||||||
onNavigate={() => {
|
onNavigate={() => {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import '../../styles/center-layout.css';
|
|||||||
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||||
import { useSidebar } from '../../hooks/common/useSidebar';
|
import { useSidebar } from '../../hooks/common/useSidebar';
|
||||||
import { usePartnerWorkspaceEntry } from '../../hooks/common/usePartnerWorkspaceEntry';
|
import { usePartnerWorkspaceEntry } from '../../hooks/common/usePartnerWorkspaceEntry';
|
||||||
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
|
|
||||||
import { isAdmin, isRoot, showError } from '../../helpers';
|
import { isAdmin, isRoot, showError } from '../../helpers';
|
||||||
import {
|
import {
|
||||||
isMiniProgramPaymentPath,
|
isMiniProgramPaymentPath,
|
||||||
@@ -29,7 +28,7 @@ import {
|
|||||||
loadPersonalConsentGranted,
|
loadPersonalConsentGranted,
|
||||||
readPersonalConsentCache,
|
readPersonalConsentCache,
|
||||||
} from '../smart-router/api';
|
} from '../smart-router/api';
|
||||||
import SkeletonWrapper from './components/SkeletonWrapper';
|
import { CenterSidebarLoading } from './components/CenterSidebarLoading';
|
||||||
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
||||||
import { useAuthzView, usePerm } from '../../authz';
|
import { useAuthzView, usePerm } from '../../authz';
|
||||||
|
|
||||||
@@ -77,8 +76,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
|||||||
isRoot() || (isAdmin() && delegatedSettingTabs.length > 0);
|
isRoot() || (isAdmin() && delegatedSettingTabs.length > 0);
|
||||||
const commissionEnabled = statusState?.status?.commission_enabled !== false;
|
const commissionEnabled = statusState?.status?.commission_enabled !== false;
|
||||||
|
|
||||||
const showSkeleton = useMinimumLoadingTime(sidebarLoading, 200);
|
|
||||||
|
|
||||||
// 权限管理分组:模块切到新体系后按权限点判断,切换前只有 root 可见(legacy = isRoot())
|
// 权限管理分组:模块切到新体系后按权限点判断,切换前只有 root 可见(legacy = isRoot())
|
||||||
const canAuthzMenu = usePerm('platform.authz.menu.query', isRoot());
|
const canAuthzMenu = usePerm('platform.authz.menu.query', isRoot());
|
||||||
const canAuthzRole = usePerm('platform.authz.role.query', isRoot());
|
const canAuthzRole = usePerm('platform.authz.role.query', isRoot());
|
||||||
@@ -577,7 +574,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const navigation = navigationRef.current;
|
const navigation = navigationRef.current;
|
||||||
if (!navigation || showSkeleton) return;
|
if (!navigation || sidebarLoading) return;
|
||||||
let frame;
|
let frame;
|
||||||
const scheduleReveal = () => {
|
const scheduleReveal = () => {
|
||||||
cancelAnimationFrame(frame);
|
cancelAnimationFrame(frame);
|
||||||
@@ -599,7 +596,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
|||||||
mutationObserver.disconnect();
|
mutationObserver.disconnect();
|
||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
showSkeleton,
|
sidebarLoading,
|
||||||
selectedKeys,
|
selectedKeys,
|
||||||
collapsed,
|
collapsed,
|
||||||
forceExpanded,
|
forceExpanded,
|
||||||
@@ -607,17 +604,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
|||||||
foldedGroups,
|
foldedGroups,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 监控折叠状态变化以更新 body class(--sidebar-current-width 由它驱动)。
|
|
||||||
// 抽屉态下跳过:body class 是全局的,抽屉临时展开不该顺手把桌面侧栏宽度也改掉。
|
|
||||||
useEffect(() => {
|
|
||||||
if (forceExpanded) return;
|
|
||||||
if (persistedCollapsed) {
|
|
||||||
document.body.classList.add('sidebar-collapsed');
|
|
||||||
} else {
|
|
||||||
document.body.classList.remove('sidebar-collapsed');
|
|
||||||
}
|
|
||||||
}, [persistedCollapsed, forceExpanded]);
|
|
||||||
|
|
||||||
const renderMenuIcon = (key) =>
|
const renderMenuIcon = (key) =>
|
||||||
React.cloneElement(getLucideIcon(key), {
|
React.cloneElement(getLucideIcon(key), {
|
||||||
size: 16,
|
size: 16,
|
||||||
@@ -735,6 +721,9 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (sidebarLoading)
|
||||||
|
return <CenterSidebarLoading forceExpanded={forceExpanded} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className='ui-console-sidebar ui-center-sidebar'
|
className='ui-console-sidebar ui-center-sidebar'
|
||||||
@@ -746,55 +735,47 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
|||||||
background: 'var(--surface-sidebar)',
|
background: 'var(--surface-sidebar)',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SkeletonWrapper
|
<nav ref={navigationRef} className='ui-center-sidebar-nav'>
|
||||||
loading={showSkeleton}
|
{/* 聊天区域 */}
|
||||||
type='sidebar'
|
{hasSectionVisibleModules('chat') &&
|
||||||
className=''
|
renderGroup(
|
||||||
collapsed={collapsed}
|
'chat-group',
|
||||||
showAdmin={isAdmin()}
|
t('聊天'),
|
||||||
>
|
chatMenuItems.map(renderSubItem),
|
||||||
<nav ref={navigationRef} className='ui-center-sidebar-nav'>
|
)}
|
||||||
{/* 聊天区域 */}
|
|
||||||
{hasSectionVisibleModules('chat') &&
|
|
||||||
renderGroup(
|
|
||||||
'chat-group',
|
|
||||||
t('聊天'),
|
|
||||||
chatMenuItems.map(renderSubItem),
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 控制台区域 */}
|
{/* 控制台区域 */}
|
||||||
{hasSectionVisibleModules('console') &&
|
{hasSectionVisibleModules('console') &&
|
||||||
renderGroup(
|
renderGroup(
|
||||||
'console-group',
|
'console-group',
|
||||||
t('控制台'),
|
t('控制台'),
|
||||||
workspaceItems.map((item) => renderNavItem(item)),
|
workspaceItems.map((item) => renderNavItem(item)),
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 个人中心区域 */}
|
{/* 个人中心区域 */}
|
||||||
{hasSectionVisibleModules('personal') &&
|
{hasSectionVisibleModules('personal') &&
|
||||||
renderGroup(
|
renderGroup(
|
||||||
'personal-group',
|
'personal-group',
|
||||||
t('个人中心'),
|
t('个人中心'),
|
||||||
financeItems.map((item) => renderNavItem(item)),
|
financeItems.map((item) => renderNavItem(item)),
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 管理员区域:按角色、权限下放及菜单配置过滤。分佣管理为子菜单,走 renderSubItem。 */}
|
{/* 管理员区域:按角色、权限下放及菜单配置过滤。分佣管理为子菜单,走 renderSubItem。 */}
|
||||||
{(isAdmin() || visibleAdminItems.length > 0) &&
|
{(isAdmin() || visibleAdminItems.length > 0) &&
|
||||||
renderGroup(
|
renderGroup(
|
||||||
'admin-group',
|
'admin-group',
|
||||||
t('管理员'),
|
t('管理员'),
|
||||||
visibleAdminItems.map(renderSubItem),
|
visibleAdminItems.map(renderSubItem),
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 权限管理区域:至少有一项可见时显示 */}
|
{/* 权限管理区域:至少有一项可见时显示 */}
|
||||||
{authzItems.length > 0 &&
|
{authzItems.length > 0 &&
|
||||||
renderGroup(
|
renderGroup(
|
||||||
'authz-group',
|
'authz-group',
|
||||||
t('权限管理'),
|
t('权限管理'),
|
||||||
authzItems.map((item) => renderNavItem(item)),
|
authzItems.map((item) => renderNavItem(item)),
|
||||||
)}
|
)}
|
||||||
</nav>
|
</nav>
|
||||||
</SkeletonWrapper>
|
|
||||||
|
|
||||||
{/* 底部折叠按钮 —— 抽屉态不提供:收起后抽屉会变成 60px 窄条,等于自废 */}
|
{/* 底部折叠按钮 —— 抽屉态不提供:收起后抽屉会变成 60px 窄条,等于自废 */}
|
||||||
{!forceExpanded && (
|
{!forceExpanded && (
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useSidebarCollapsed } from '../../../hooks/common/useSidebarCollapsed';
|
||||||
|
|
||||||
|
const rows = [0, 1, 2, 3, 4, 5];
|
||||||
|
|
||||||
|
export function CenterSidebarLoading({ forceExpanded = false }) {
|
||||||
|
const [collapsed] = useSidebarCollapsed();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className='ui-center-sidebar ui-center-sidebar-placeholder'
|
||||||
|
data-collapsed={!forceExpanded && collapsed}
|
||||||
|
data-mobile={forceExpanded || undefined}
|
||||||
|
aria-busy='true'
|
||||||
|
aria-label={t('主导航')}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className='ui-center-sidebar-nav ui-center-sidebar-placeholder-rows'
|
||||||
|
aria-hidden='true'
|
||||||
|
>
|
||||||
|
{rows.map((row) => (
|
||||||
|
<div key={row} className='ui-center-menu-item'>
|
||||||
|
<span />
|
||||||
|
<span />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{!forceExpanded && (
|
||||||
|
<div
|
||||||
|
className='ui-center-sidebar-placeholder-footer'
|
||||||
|
aria-hidden='true'
|
||||||
|
>
|
||||||
|
<span />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CenterRouteLoading() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='ui-center-route-loading' role='status'>
|
||||||
|
<div className='hidden md:block'>
|
||||||
|
<CenterSidebarLoading />
|
||||||
|
</div>
|
||||||
|
<div className='ui-center-route-loading-body'>{t('加载中...')}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Compass as ActionCompass } from '@/components/common/icons/ActionIcons';
|
import { Compass as ActionCompass } from '@/components/common/icons/ActionIcons';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { Button, Dropdown } from 'antd';
|
import { Button, Dropdown } from 'antd';
|
||||||
import { ExternalLink } from 'lucide-react';
|
import { ExternalLink } from 'lucide-react';
|
||||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||||
@@ -14,9 +14,8 @@ import { isNavigationPathActive } from '../../console/consoleRoutes';
|
|||||||
*
|
*
|
||||||
* 目标路径/外链的推导逻辑必须与桌面端 Navigation 保持一致,避免两端跳转不同。
|
* 目标路径/外链的推导逻辑必须与桌面端 Navigation 保持一致,避免两端跳转不同。
|
||||||
*/
|
*/
|
||||||
const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
const MobileNavMenu = ({ mainNavLinks, userState, followTopLink, t }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
|
||||||
if (!mainNavLinks || mainNavLinks.length === 0) {
|
if (!mainNavLinks || mainNavLinks.length === 0) {
|
||||||
@@ -88,7 +87,7 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
|||||||
if (item.externalLink) {
|
if (item.externalLink) {
|
||||||
window.open(item.externalLink, '_blank', 'noopener,noreferrer');
|
window.open(item.externalLink, '_blank', 'noopener,noreferrer');
|
||||||
} else if (item.to) {
|
} else if (item.to) {
|
||||||
navigate(item.to);
|
followTopLink(item.to);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import SkeletonWrapper from '../components/SkeletonWrapper';
|
import SkeletonWrapper from '../components/SkeletonWrapper';
|
||||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||||
|
|
||||||
const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
const Navigation = ({
|
||||||
|
mainNavLinks,
|
||||||
|
isMobile,
|
||||||
|
isLoading,
|
||||||
|
userState,
|
||||||
|
followTopLink,
|
||||||
|
}) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -61,7 +67,14 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
|||||||
.map((item) => item.itemKey),
|
.map((item) => item.itemKey),
|
||||||
items: link.items.map((subItem) => ({
|
items: link.items.map((subItem) => ({
|
||||||
key: subItem.itemKey,
|
key: subItem.itemKey,
|
||||||
label: <Link to={subItem.to}>{subItem.text}</Link>,
|
label: (
|
||||||
|
<Link
|
||||||
|
to={subItem.to}
|
||||||
|
onClick={(event) => followTopLink(subItem.to, event)}
|
||||||
|
>
|
||||||
|
{subItem.text}
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
})),
|
})),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -97,6 +110,7 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
|||||||
<Link
|
<Link
|
||||||
key={link.itemKey}
|
key={link.itemKey}
|
||||||
to={targetPath}
|
to={targetPath}
|
||||||
|
onClick={(event) => followTopLink(targetPath, event)}
|
||||||
className={finalClasses}
|
className={finalClasses}
|
||||||
aria-current={isActive ? 'page' : undefined}
|
aria-current={isActive ? 'page' : undefined}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ChevronDown as ActionChevronDown } from '@/components/common/icons/ActionIcons';
|
import { ChevronDown as ActionChevronDown } from '@/components/common/icons/ActionIcons';
|
||||||
import React, { useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Avatar, Button as AntButton, Dropdown as AntDropdown } from 'antd';
|
import { Avatar, Button as AntButton, Dropdown as AntDropdown } from 'antd';
|
||||||
import { UserRound, KeyRound, LogOut } from 'lucide-react';
|
import { UserRound, KeyRound, LogOut } from 'lucide-react';
|
||||||
import { getUserAvatarUrl } from '../../../helpers';
|
import { getUserAvatarUrl } from '../../../helpers';
|
||||||
@@ -20,6 +20,7 @@ const AccountMenuLabel = ({ icon, tone, title, description }) => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
const MENU_ICON_PROPS = { size: 18, strokeWidth: 1.65, 'aria-hidden': true };
|
const MENU_ICON_PROPS = { size: 18, strokeWidth: 1.65, 'aria-hidden': true };
|
||||||
|
const HOVER_DELAY = 100;
|
||||||
|
|
||||||
const UserArea = ({
|
const UserArea = ({
|
||||||
userState,
|
userState,
|
||||||
@@ -33,7 +34,56 @@ const UserArea = ({
|
|||||||
navigate,
|
navigate,
|
||||||
t,
|
t,
|
||||||
}) => {
|
}) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [openMode, setOpenMode] = useState(null);
|
||||||
|
const triggerRef = useRef(null);
|
||||||
|
const popupRef = useRef(null);
|
||||||
|
const hoverTimer = useRef();
|
||||||
|
const open = openMode !== null;
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
clearTimeout(hoverTimer.current);
|
||||||
|
setOpenMode(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => () => clearTimeout(hoverTimer.current), []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
const handleOutsidePress = (event) => {
|
||||||
|
if (
|
||||||
|
!triggerRef.current?.contains(event.target) &&
|
||||||
|
!popupRef.current?.contains(event.target)
|
||||||
|
) {
|
||||||
|
clearTimeout(hoverTimer.current);
|
||||||
|
setOpenMode(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener('pointerdown', handleOutsidePress, true);
|
||||||
|
return () =>
|
||||||
|
document.removeEventListener('pointerdown', handleOutsidePress, true);
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
const queueHoverChange = (event, opening) => {
|
||||||
|
if (isMobile || event.pointerType !== 'mouse') return;
|
||||||
|
clearTimeout(hoverTimer.current);
|
||||||
|
if (opening ? open : openMode !== 'hover') return;
|
||||||
|
|
||||||
|
hoverTimer.current = setTimeout(() => {
|
||||||
|
setOpenMode((mode) => {
|
||||||
|
if (opening) return mode ?? 'hover';
|
||||||
|
return mode === 'hover' ? null : mode;
|
||||||
|
});
|
||||||
|
}, HOVER_DELAY);
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleOnClick = (event) => {
|
||||||
|
clearTimeout(hoverTimer.current);
|
||||||
|
const clickedMode = event.detail === 0 ? 'keyboard' : 'click';
|
||||||
|
// Clicking a hover preview keeps the panel open until the next click or dismissal.
|
||||||
|
setOpenMode((mode) =>
|
||||||
|
mode === null || mode === 'hover' ? clickedMode : null,
|
||||||
|
);
|
||||||
|
};
|
||||||
const isActionVisible = (key) => rightActions?.[key] !== false;
|
const isActionVisible = (key) => rightActions?.[key] !== false;
|
||||||
const hasHeaderModuleConfig =
|
const hasHeaderModuleConfig =
|
||||||
headerNavModules && Object.keys(headerNavModules).length > 0;
|
headerNavModules && Object.keys(headerNavModules).length > 0;
|
||||||
@@ -117,13 +167,22 @@ const UserArea = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AntDropdown
|
<AntDropdown
|
||||||
trigger={['hover', 'click']}
|
trigger={[]}
|
||||||
placement='bottomRight'
|
placement='bottomRight'
|
||||||
|
transitionName=''
|
||||||
open={open}
|
open={open}
|
||||||
onOpenChange={setOpen}
|
autoFocus={openMode === 'keyboard'}
|
||||||
menu={{ items, onClick: () => setOpen(false) }}
|
onOpenChange={(nextOpen) => {
|
||||||
|
if (!nextOpen) close();
|
||||||
|
}}
|
||||||
|
menu={{ items, onClick: close }}
|
||||||
popupRender={(menu) => (
|
popupRender={(menu) => (
|
||||||
<div className='ui-account-panel'>
|
<div
|
||||||
|
ref={popupRef}
|
||||||
|
className='ui-account-panel'
|
||||||
|
onPointerEnter={(event) => queueHoverChange(event, true)}
|
||||||
|
onPointerLeave={(event) => queueHoverChange(event, false)}
|
||||||
|
>
|
||||||
<div className='ui-account-summary'>
|
<div className='ui-account-summary'>
|
||||||
<Avatar
|
<Avatar
|
||||||
shape='square'
|
shape='square'
|
||||||
@@ -144,10 +203,14 @@ const UserArea = ({
|
|||||||
classNames={{ root: 'ui-account-dropdown' }}
|
classNames={{ root: 'ui-account-dropdown' }}
|
||||||
>
|
>
|
||||||
<AntButton
|
<AntButton
|
||||||
|
ref={triggerRef}
|
||||||
type='text'
|
type='text'
|
||||||
className='ui-header-account'
|
className='ui-header-account'
|
||||||
aria-haspopup='menu'
|
aria-haspopup='menu'
|
||||||
aria-expanded={open}
|
aria-expanded={open}
|
||||||
|
onPointerEnter={(event) => queueHoverChange(event, true)}
|
||||||
|
onPointerLeave={(event) => queueHoverChange(event, false)}
|
||||||
|
onClick={toggleOnClick}
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
shape='square'
|
shape='square'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { isAuthPagePath } from '../../../helpers/auth';
|
|||||||
import { useHeaderBar } from '../../../hooks/common/useHeaderBar';
|
import { useHeaderBar } from '../../../hooks/common/useHeaderBar';
|
||||||
import { useNotifications } from '../../../hooks/common/useNotifications';
|
import { useNotifications } from '../../../hooks/common/useNotifications';
|
||||||
import { useNavigation } from '../../../hooks/common/useNavigation';
|
import { useNavigation } from '../../../hooks/common/useNavigation';
|
||||||
|
import { useTopNavigation } from '../../../hooks/common/useTopNavigation';
|
||||||
import { usePartnerWorkspaceEntry } from '../../../hooks/common/usePartnerWorkspaceEntry';
|
import { usePartnerWorkspaceEntry } from '../../../hooks/common/usePartnerWorkspaceEntry';
|
||||||
import MobileMenuButton from './MobileMenuButton';
|
import MobileMenuButton from './MobileMenuButton';
|
||||||
import HeaderLogo from './HeaderLogo';
|
import HeaderLogo from './HeaderLogo';
|
||||||
@@ -69,6 +70,7 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
|||||||
const mainNavLinks = configuredNavLinks.filter(
|
const mainNavLinks = configuredNavLinks.filter(
|
||||||
(link) => link.itemKey !== 'keyManagement',
|
(link) => link.itemKey !== 'keyManagement',
|
||||||
);
|
);
|
||||||
|
const followTopLink = useTopNavigation();
|
||||||
|
|
||||||
const [hasOpenedNotice, setHasOpenedNotice] = useState(false);
|
const [hasOpenedNotice, setHasOpenedNotice] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -146,6 +148,7 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
|||||||
<MobileNavMenu
|
<MobileNavMenu
|
||||||
mainNavLinks={mainNavLinks}
|
mainNavLinks={mainNavLinks}
|
||||||
userState={userState}
|
userState={userState}
|
||||||
|
followTopLink={followTopLink}
|
||||||
t={t}
|
t={t}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -157,6 +160,7 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
|||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
userState={userState}
|
userState={userState}
|
||||||
|
followTopLink={followTopLink}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import {
|
|||||||
import { getHeaderModuleRequireAuth } from '../../constants/headerNavModules';
|
import { getHeaderModuleRequireAuth } from '../../constants/headerNavModules';
|
||||||
import { useWeyAiWebEntry } from './useWeyAiWebEntry';
|
import { useWeyAiWebEntry } from './useWeyAiWebEntry';
|
||||||
import { useAuthzView } from '../../authz';
|
import { useAuthzView } from '../../authz';
|
||||||
|
import { useExperienceModules } from '../../pages/ExperienceCenter/useExperienceModules';
|
||||||
|
import { useUserCenterRoutes } from '../../pages/UserCenter/useUserCenterRoutes';
|
||||||
|
|
||||||
export const useNavigation = (
|
export const useNavigation = (
|
||||||
t,
|
t,
|
||||||
@@ -24,6 +26,9 @@ export const useNavigation = (
|
|||||||
} = orgEntry;
|
} = orgEntry;
|
||||||
// WeyAi 网页端入口:按 /api/status 开关与 /api/client/v1/web/access 决定是否显示
|
// WeyAi 网页端入口:按 /api/status 开关与 /api/client/v1/web/access 决定是否显示
|
||||||
const { visible: weyaiVisible, url: weyaiUrl } = useWeyAiWebEntry();
|
const { visible: weyaiVisible, url: weyaiUrl } = useWeyAiWebEntry();
|
||||||
|
const { ready: navigationReady, defaultPath: experienceEntry } =
|
||||||
|
useExperienceModules();
|
||||||
|
const { firstRoute: userCenterEntry } = useUserCenterRoutes();
|
||||||
// 新权限体系:持有已切换的控制台菜单的非管理员(自定义平台角色)同样要有"控制台"入口,
|
// 新权限体系:持有已切换的控制台菜单的非管理员(自定义平台角色)同样要有"控制台"入口,
|
||||||
// 否则路由和侧栏都放行了,却只能手输地址进入
|
// 否则路由和侧栏都放行了,却只能手输地址进入
|
||||||
const platformView = useAuthzView('platform');
|
const platformView = useAuthzView('platform');
|
||||||
@@ -125,7 +130,8 @@ export const useNavigation = (
|
|||||||
{
|
{
|
||||||
text: t('体验中心'),
|
text: t('体验中心'),
|
||||||
itemKey: 'experienceCenter',
|
itemKey: 'experienceCenter',
|
||||||
to: '/experience-center',
|
to: (navigationReady && experienceEntry) || '/experience-center',
|
||||||
|
activePrefix: '/experience-center',
|
||||||
requireAuth: getHeaderModuleRequireAuth(modules, 'experienceCenter'),
|
requireAuth: getHeaderModuleRequireAuth(modules, 'experienceCenter'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -144,7 +150,8 @@ export const useNavigation = (
|
|||||||
{
|
{
|
||||||
text: t('用户中心'),
|
text: t('用户中心'),
|
||||||
itemKey: 'userCenter',
|
itemKey: 'userCenter',
|
||||||
to: '/user-center',
|
to: (navigationReady && userCenterEntry) || '/user-center',
|
||||||
|
activePrefix: '/user-center',
|
||||||
requireAuth: getHeaderModuleRequireAuth(modules, 'userCenter'),
|
requireAuth: getHeaderModuleRequireAuth(modules, 'userCenter'),
|
||||||
},
|
},
|
||||||
// 企业中心:仅当用户属于某个企业时作为一级入口展示(不跟随 headerNavModules 配置,
|
// 企业中心:仅当用户属于某个企业时作为一级入口展示(不跟随 headerNavModules 配置,
|
||||||
@@ -206,6 +213,9 @@ export const useNavigation = (
|
|||||||
weyaiVisible,
|
weyaiVisible,
|
||||||
weyaiUrl,
|
weyaiUrl,
|
||||||
hasConsoleMenu,
|
hasConsoleMenu,
|
||||||
|
navigationReady,
|
||||||
|
experienceEntry,
|
||||||
|
userCenterEntry,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { resolvePath, useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
import { useEffectEvent } from './useEffectEvent';
|
||||||
|
|
||||||
|
const NAVIGATION_INTERVAL = 180;
|
||||||
|
const normalizePathname = (path) => path.replace(/\/+$/, '') || '/';
|
||||||
|
|
||||||
|
export function useTopNavigation() {
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const timer = useRef();
|
||||||
|
const lastNavigationAt = useRef(-Infinity);
|
||||||
|
|
||||||
|
useEffect(() => () => clearTimeout(timer.current), []);
|
||||||
|
|
||||||
|
return useEffectEvent((to, event) => {
|
||||||
|
if (
|
||||||
|
!to ||
|
||||||
|
event?.defaultPrevented ||
|
||||||
|
(event &&
|
||||||
|
(event.button !== 0 ||
|
||||||
|
event.metaKey ||
|
||||||
|
event.altKey ||
|
||||||
|
event.ctrlKey ||
|
||||||
|
event.shiftKey))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event?.preventDefault();
|
||||||
|
clearTimeout(timer.current);
|
||||||
|
const target = resolvePath(to, location.pathname);
|
||||||
|
const current = window.location;
|
||||||
|
if (
|
||||||
|
normalizePathname(target.pathname) ===
|
||||||
|
normalizePathname(current.pathname) &&
|
||||||
|
(!target.search || target.search === current.search) &&
|
||||||
|
(!target.hash || target.hash === current.hash)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const originKey = window.history.state?.key;
|
||||||
|
const go = () => {
|
||||||
|
// Back/forward or a different control may have navigated during the wait.
|
||||||
|
if (window.history.state?.key !== originKey) return;
|
||||||
|
lastNavigationAt.current = performance.now();
|
||||||
|
navigate(to);
|
||||||
|
};
|
||||||
|
const wait =
|
||||||
|
NAVIGATION_INTERVAL - (performance.now() - lastNavigationAt.current);
|
||||||
|
// Apply the first click immediately and keep only the newest queued click.
|
||||||
|
if (wait > 0) timer.current = setTimeout(go, wait);
|
||||||
|
else go();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import { Building2, AlertTriangle, HelpCircle } from 'lucide-react';
|
|||||||
import { Button } from '@/components/ui';
|
import { Button } from '@/components/ui';
|
||||||
import { API } from '../../helpers/api';
|
import { API } from '../../helpers/api';
|
||||||
import { UserContext } from '../../context/User';
|
import { UserContext } from '../../context/User';
|
||||||
import Loading from '../../components/common/ui/Loading';
|
import { CenterRouteLoading } from '../../components/layout/components/CenterSidebarLoading';
|
||||||
import PageBackground from '../../components/common/PageBackground';
|
import PageBackground from '../../components/common/PageBackground';
|
||||||
import {
|
import {
|
||||||
getCurrentOrgId,
|
getCurrentOrgId,
|
||||||
@@ -95,7 +95,7 @@ const OrgResolver = ({
|
|||||||
}, [runCheck]);
|
}, [runCheck]);
|
||||||
|
|
||||||
if (mode === 'checking') {
|
if (mode === 'checking') {
|
||||||
return <Loading />;
|
return <CenterRouteLoading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === 'proxy_required') {
|
if (mode === 'proxy_required') {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { API } from '../../helpers/api';
|
|||||||
import { showError } from '../../helpers';
|
import { showError } from '../../helpers';
|
||||||
import { isMiniProgramWebView } from '../../helpers/miniProgram';
|
import { isMiniProgramWebView } 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 PageBackground from '../../components/common/PageBackground';
|
import PageBackground from '../../components/common/PageBackground';
|
||||||
import OrgResolver from './OrgResolver';
|
import OrgResolver from './OrgResolver';
|
||||||
import OrgSidebar from './OrgSidebar';
|
import OrgSidebar from './OrgSidebar';
|
||||||
@@ -776,7 +777,7 @@ const Organization = () => {
|
|||||||
(orgInfo &&
|
(orgInfo &&
|
||||||
(loadedOrgScope?.orgId !== orgId || loadedOrgScope?.user !== user))
|
(loadedOrgScope?.orgId !== orgId || loadedOrgScope?.user !== user))
|
||||||
) {
|
) {
|
||||||
return <Loading />;
|
return <CenterRouteLoading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 待激活占位页:不展示任何企业功能,仅引导联系客服/管理员
|
// 待激活占位页:不展示任何企业功能,仅引导联系客服/管理员
|
||||||
@@ -816,7 +817,7 @@ const Organization = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!firstOrgRoute) {
|
if (!firstOrgRoute) {
|
||||||
if (commissionAccess === 'loading') return <Loading />;
|
if (commissionAccess === 'loading') return <CenterRouteLoading />;
|
||||||
// 企业会话(org_only 员工、企业入口登录)、超管代理、或企业已有模块切到新体系:
|
// 企业会话(org_only 员工、企业入口登录)、超管代理、或企业已有模块切到新体系:
|
||||||
// 显示明确空态,不默认开放、不静默跳走(AC121)。其余(未切换的个人会话)保持原行为回个人中心
|
// 显示明确空态,不默认开放、不静默跳走(AC121)。其余(未切换的个人会话)保持原行为回个人中心
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useMemo } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import {
|
import {
|
||||||
Routes,
|
Routes,
|
||||||
Route,
|
Route,
|
||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
Gift,
|
Gift,
|
||||||
Receipt,
|
Receipt,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { StatusContext } from '../../context/Status';
|
|
||||||
import { UserContext } from '../../context/User';
|
import { UserContext } from '../../context/User';
|
||||||
import { isSidebarModuleVisible } from '../../helpers/navigationVisibility';
|
import { isSidebarModuleVisible } from '../../helpers/navigationVisibility';
|
||||||
import { useMarquee } from '../../hooks/common/useMarquee';
|
import { useMarquee } from '../../hooks/common/useMarquee';
|
||||||
@@ -33,11 +32,11 @@ import PersonalSetting from '../../components/settings/PersonalSetting';
|
|||||||
import ServiceDashboard from '../ServiceDashboard';
|
import ServiceDashboard from '../ServiceDashboard';
|
||||||
import WeyAiDownload from '../WeyAiDownload';
|
import WeyAiDownload from '../WeyAiDownload';
|
||||||
import KeyManagement from '../KeyManagement';
|
import KeyManagement from '../KeyManagement';
|
||||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
|
||||||
import {
|
import {
|
||||||
isMiniProgramPaymentPath,
|
isMiniProgramPaymentPath,
|
||||||
isMiniProgramWebView,
|
isMiniProgramWebView,
|
||||||
} from '../../helpers/miniProgram';
|
} from '../../helpers/miniProgram';
|
||||||
|
import { useUserCenterRoutes } from './useUserCenterRoutes';
|
||||||
|
|
||||||
// 移动端底部导航组件
|
// 移动端底部导航组件
|
||||||
const MobileBottomNav = ({ sidebarConfig }) => {
|
const MobileBottomNav = ({ sidebarConfig }) => {
|
||||||
@@ -138,56 +137,17 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const UserCenter = ({ keyManagementMode = false }) => {
|
const UserCenter = ({ keyManagementMode = false }) => {
|
||||||
const [statusState] = useContext(StatusContext);
|
const {
|
||||||
const [userState] = useContext(UserContext);
|
config: userCenterConfig,
|
||||||
const userGroup = userState?.user?.group;
|
userGroup,
|
||||||
|
firstRoute,
|
||||||
|
} = useUserCenterRoutes();
|
||||||
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
|
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
|
||||||
const ucRoute = useLocation().pathname.split('/')[2] || 'dashboard';
|
const ucRoute = useLocation().pathname.split('/')[2] || 'dashboard';
|
||||||
|
|
||||||
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
||||||
const { visible: hasMarquee } = useMarquee();
|
const { visible: hasMarquee } = useMarquee();
|
||||||
const userCenterConfig = useMemo(
|
const firstVisibleRoute = firstRoute || '/';
|
||||||
() =>
|
|
||||||
normalizeSidebarModulesAdmin(statusState?.status?.SidebarModulesAdmin)
|
|
||||||
.userCenter,
|
|
||||||
[statusState?.status?.SidebarModulesAdmin],
|
|
||||||
);
|
|
||||||
const userCenterRoutes = [
|
|
||||||
'dashboard',
|
|
||||||
'usageRecord',
|
|
||||||
'serviceDashboard',
|
|
||||||
'topup',
|
|
||||||
'invoice',
|
|
||||||
'invite',
|
|
||||||
'settings',
|
|
||||||
];
|
|
||||||
const routePathMap = {
|
|
||||||
dashboard: 'dashboard',
|
|
||||||
usageRecord: 'usage-record',
|
|
||||||
serviceDashboard: 'service-dashboard',
|
|
||||||
topup: 'topup',
|
|
||||||
invoice: 'invoice',
|
|
||||||
invite: 'invite',
|
|
||||||
settings: 'settings',
|
|
||||||
};
|
|
||||||
// 小程序里付费页面会被 App.jsx 送回 /user-center,所以默认页不能落在它们上面,否则来回跳转。
|
|
||||||
const inMiniProgram = isMiniProgramWebView();
|
|
||||||
const firstVisiblePath =
|
|
||||||
userCenterConfig.enabled === false
|
|
||||||
? null
|
|
||||||
: routePathMap[
|
|
||||||
userCenterRoutes.find(
|
|
||||||
(key) =>
|
|
||||||
isSidebarModuleVisible(userCenterConfig, key, userGroup) &&
|
|
||||||
!(
|
|
||||||
inMiniProgram &&
|
|
||||||
isMiniProgramPaymentPath(`/user-center/${routePathMap[key]}`)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
] || null;
|
|
||||||
const firstVisibleRoute = firstVisiblePath
|
|
||||||
? `/user-center/${firstVisiblePath}`
|
|
||||||
: '/';
|
|
||||||
const guardUserCenterRoute = (key, element) => {
|
const guardUserCenterRoute = (key, element) => {
|
||||||
if (!isSidebarModuleVisible(userCenterConfig, key, userGroup)) {
|
if (!isSidebarModuleVisible(userCenterConfig, key, userGroup)) {
|
||||||
return <Navigate to={firstVisibleRoute} replace />;
|
return <Navigate to={firstVisibleRoute} replace />;
|
||||||
@@ -195,7 +155,7 @@ const UserCenter = ({ keyManagementMode = false }) => {
|
|||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!firstVisiblePath && !keyManagementMode) {
|
if (!firstRoute && !keyManagementMode) {
|
||||||
return <Navigate to='/' replace />;
|
return <Navigate to='/' replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { useContext, useMemo } from 'react';
|
||||||
|
import { StatusContext } from '../../context/Status';
|
||||||
|
import { UserContext } from '../../context/User';
|
||||||
|
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||||
|
import { isSidebarModuleVisible } from '../../helpers/navigationVisibility';
|
||||||
|
import {
|
||||||
|
isMiniProgramPaymentPath,
|
||||||
|
isMiniProgramWebView,
|
||||||
|
} from '../../helpers/miniProgram';
|
||||||
|
|
||||||
|
const routes = {
|
||||||
|
dashboard: 'dashboard',
|
||||||
|
usageRecord: 'usage-record',
|
||||||
|
serviceDashboard: 'service-dashboard',
|
||||||
|
topup: 'topup',
|
||||||
|
invoice: 'invoice',
|
||||||
|
invite: 'invite',
|
||||||
|
settings: 'settings',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function useUserCenterRoutes() {
|
||||||
|
const [statusState] = useContext(StatusContext);
|
||||||
|
const [userState] = useContext(UserContext);
|
||||||
|
const userGroup = userState?.user?.group;
|
||||||
|
const savedConfig = statusState?.status?.SidebarModulesAdmin;
|
||||||
|
const config = useMemo(
|
||||||
|
() => normalizeSidebarModulesAdmin(savedConfig).userCenter,
|
||||||
|
[savedConfig],
|
||||||
|
);
|
||||||
|
const inMiniProgram = isMiniProgramWebView();
|
||||||
|
// The app redirects mini-program payment routes back to the center.
|
||||||
|
const firstRoute = Object.entries(routes)
|
||||||
|
.map(([key, segment]) => [key, `/user-center/${segment}`])
|
||||||
|
.find(
|
||||||
|
([key, path]) =>
|
||||||
|
config.enabled !== false &&
|
||||||
|
isSidebarModuleVisible(config, key, userGroup) &&
|
||||||
|
!(inMiniProgram && isMiniProgramPaymentPath(path)),
|
||||||
|
)?.[1];
|
||||||
|
|
||||||
|
return { config, userGroup, firstRoute };
|
||||||
|
}
|
||||||
@@ -21,6 +21,102 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui-center-route-loading {
|
||||||
|
display: flex;
|
||||||
|
height: 100vh;
|
||||||
|
padding-top: var(--console-header-offset, 72px);
|
||||||
|
background: var(--surface-bg-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-route-loading-body {
|
||||||
|
display: grid;
|
||||||
|
flex: 1;
|
||||||
|
place-items: center;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
animation: ui-center-sidebar-placeholder-reveal 100ms ease-out 140ms both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar .ui-center-sidebar-placeholder-rows {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
padding-top: 24px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder-rows .ui-center-menu-item {
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder-footer {
|
||||||
|
display: grid;
|
||||||
|
flex: none;
|
||||||
|
height: 58px;
|
||||||
|
place-items: center;
|
||||||
|
border-top: 1px solid var(--border-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder
|
||||||
|
:is(.ui-center-menu-item, .ui-center-sidebar-placeholder-footer)
|
||||||
|
> span {
|
||||||
|
display: block;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
flex: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--ui-color-fill-1);
|
||||||
|
animation: ui-center-sidebar-placeholder-reveal 100ms ease-out 140ms both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder .ui-center-menu-item > span + span {
|
||||||
|
width: 60%;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder
|
||||||
|
.ui-center-menu-item:nth-child(even)
|
||||||
|
> span
|
||||||
|
+ span {
|
||||||
|
width: 48%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder .ui-center-sidebar-placeholder-footer > span {
|
||||||
|
width: 64px;
|
||||||
|
height: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder[data-collapsed='true']
|
||||||
|
.ui-center-menu-item
|
||||||
|
> span
|
||||||
|
+ span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-center-sidebar-placeholder[data-collapsed='true']
|
||||||
|
.ui-center-sidebar-placeholder-footer
|
||||||
|
> span {
|
||||||
|
width: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes ui-center-sidebar-placeholder-reveal {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.ui-center-route-loading-body,
|
||||||
|
.ui-center-sidebar-placeholder
|
||||||
|
:is(.ui-center-menu-item, .ui-center-sidebar-placeholder-footer)
|
||||||
|
> span {
|
||||||
|
animation-duration: 0ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.ui-org-identity {
|
.ui-org-identity {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: none;
|
flex: none;
|
||||||
|
|||||||
@@ -181,6 +181,19 @@ html.dark body[data-ui-scope='admin'] {
|
|||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: var(--hd-panel-shadow);
|
box-shadow: var(--hd-panel-shadow);
|
||||||
}
|
}
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.ui-account-dropdown:not(.ant-dropdown-hidden) .ui-account-panel {
|
||||||
|
animation: ui-account-panel-enter 120ms ease-out both;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes ui-account-panel-enter {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
.ui-account-summary {
|
.ui-account-summary {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ for (const path of [
|
|||||||
mocks[path] = { __esModule: true, default: () => null };
|
mocks[path] = { __esModule: true, default: () => null };
|
||||||
const ServiceDashboard = () => null;
|
const ServiceDashboard = () => null;
|
||||||
mocks['../ServiceDashboard'] = { __esModule: true, default: ServiceDashboard };
|
mocks['../ServiceDashboard'] = { __esModule: true, default: ServiceDashboard };
|
||||||
|
mocks['./useUserCenterRoutes'] = await loadFrontendModule(
|
||||||
|
new URL('../../src/pages/UserCenter/useUserCenterRoutes.js', import.meta.url),
|
||||||
|
mocks,
|
||||||
|
);
|
||||||
const UserCenter = (
|
const UserCenter = (
|
||||||
await loadFrontendModule(
|
await loadFrontendModule(
|
||||||
new URL('../../src/pages/UserCenter/index.jsx', import.meta.url),
|
new URL('../../src/pages/UserCenter/index.jsx', import.meta.url),
|
||||||
|
|||||||
Reference in New Issue
Block a user