feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 9fc5fd212d
commit 28e924e371
242 changed files with 9242 additions and 5043 deletions
+18 -13
View File
@@ -58,6 +58,8 @@ const CustomerServiceFloat = lazy(() => import('../customer-service'));
// 跑马灯公告组件
import Marquee from './Marquee';
import { useMarquee } from '../../hooks/common/useMarquee';
import ConsolePageContainer from '../console/ConsolePageContainer';
import { isNavigationPathActive } from '../console/consoleRoutes';
const { Sider, Content, Header } = Layout;
@@ -92,13 +94,7 @@ const PageLayout = () => {
const [showGiftModal, setShowGiftModal] = useState(false);
const [giftQuota, setGiftQuota] = useState(0);
const shouldInnerPadding =
location.pathname.includes('/console') &&
!location.pathname.startsWith('/console/chat') &&
location.pathname !== '/console/playground' &&
location.pathname !== '/console/website-setting';
const isConsoleRoute = location.pathname.startsWith('/console');
const isConsoleRoute = isNavigationPathActive(location.pathname, '/console');
const showSider = isConsoleRoute && (!isMobile || drawerOpen);
const isHomePage = location.pathname === '/';
@@ -394,6 +390,11 @@ const PageLayout = () => {
)}
{showSider && (
<Sider
width={
siderForceExpanded
? 'var(--sidebar-width)'
: 'var(--sidebar-current-width)'
}
style={{
position: 'fixed',
left: 0,
@@ -439,15 +440,12 @@ const PageLayout = () => {
style={{
flex: '1 0 auto',
WebkitOverflowScrolling: 'touch',
padding: shouldInnerPadding
? isMobile
? '5px'
: '24px 24px 0 24px'
: '0',
padding: 0,
position: 'relative',
// 认证页等 min-height:100vh 的独立屏用它抵扣上方跑马灯占位的高度,
// 保证「占位 + 容器」总高恰为 100vh(无占位时回退 0px,不影响其他页面)
'--content-top-offset': `${marqueeHeight}px`,
'--console-header-offset': `${totalHeaderHeight}px`,
}}
>
{/* 跑马灯占位:当跑马灯存在时,为内容区域顶部增加等高间距,防止被固定头部遮挡 */}
@@ -458,10 +456,17 @@ const PageLayout = () => {
{marqueeHeight > 0 &&
!isExperienceCenter &&
!isUserCenter &&
!isConsoleRoute &&
!isOrgPage && (
<div style={{ height: marqueeHeight, flexShrink: 0 }} />
)}
<App />
{isConsoleRoute ? (
<ConsolePageContainer>
<App />
</ConsolePageContainer>
) : (
<App />
)}
</Content>
</Layout>
</Layout>
+110 -228
View File
@@ -17,11 +17,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { consoleMenuPaths, getConsoleMenuKeys } from '../console/consoleRoutes';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { getLucideIcon } from '../../helpers/render';
import { ChevronDown, ChevronLeft } from 'lucide-react';
import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';
import '../../styles/center-layout.css';
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
import { useSidebar } from '../../hooks/common/useSidebar';
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
@@ -35,37 +37,11 @@ import {
import SkeletonWrapper from './components/SkeletonWrapper';
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
import { Nav, Button } from '@/components/ui';
const routerMap = {
home: '/',
channel: '/console/channel',
'admin-token': '/console/token',
redemption: '/console/redemption',
topup: '/console/topup',
user: '/console/user',
log: '/console/log',
midjourney: '/console/midjourney',
setting: '/console/setting',
'website-setting': '/console/website-setting',
'demo-reservations': '/console/demo-reservations',
...consoleMenuPaths,
about: '/about',
detail: '/console',
pricing: '/market',
task: '/console/task',
models: '/console/models',
playground: '/console/playground',
personal: '/console/personal',
monitor: '/console/monitor',
analytics: '/console/analytics',
'my-commission': '/console/my-commission',
partner: '/console/partner',
organizations: '/console/organizations',
'skill-platform': '/console/skill-platform',
'expert-platform': '/console/expert-platform',
order: '/console/order',
invoice: '/console/invoice',
subscription: '/console/subscription',
};
// forceExpanded:手机端抽屉态。抽屉本来就是临时全宽浮层,折叠成 60px 图标条毫无意义,
@@ -183,7 +159,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
filteredItems.push({
text: t('我的提成'),
itemKey: 'my-commission',
to: '/console/my-commission',
});
// 合作伙伴:受平台总开关控制(参数设置页可配),开放后对全部登录用户可见
@@ -191,7 +166,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
filteredItems.push({
text: t('合作伙伴'),
itemKey: 'partner',
to: '/console/partner',
});
}
@@ -207,7 +181,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
{
text: t('运营看板'),
itemKey: 'analytics',
to: '/console/analytics',
className: isAdmin() ? '' : 'tableHiddle',
},
{
@@ -219,7 +192,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
{
text: t('模型管理'),
itemKey: 'models',
to: '/console/models',
className: isAdmin() ? '' : 'tableHiddle',
},
{
@@ -237,43 +209,36 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
{
text: t('会员卡管理'),
itemKey: 'subscription',
to: '/console/subscription',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('密钥管理'),
itemKey: 'admin-token',
to: '/console/token',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('企业管理'),
itemKey: 'organizations',
to: '/console/organizations',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('平台 Skill 中心'),
itemKey: 'skill-platform',
to: '/console/skill-platform',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('平台专家中心'),
itemKey: 'expert-platform',
to: '/console/expert-platform',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('订单管理'),
itemKey: 'order',
to: '/console/order',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('发票管理'),
itemKey: 'invoice',
to: '/console/invoice',
className: isAdmin() ? '' : 'tableHiddle',
},
{
@@ -415,23 +380,21 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
// 根据当前路径设置选中的菜单项
useEffect(() => {
const currentPath = location.pathname;
let matchingKey = Object.keys(routerMapState).find(
(key) => routerMapState[key] === currentPath,
);
let matchingKeys = getConsoleMenuKeys(currentPath, routerMapState);
// 处理聊天路由
if (!matchingKey && currentPath.startsWith('/console/chat/')) {
if (!matchingKeys.length && currentPath.startsWith('/console/chat/')) {
const chatIndex = currentPath.split('/').pop();
if (!isNaN(chatIndex)) {
matchingKey = 'chat' + chatIndex;
matchingKeys = ['chat' + chatIndex];
} else {
matchingKey = 'chat';
matchingKeys = ['chat'];
}
}
// 如果找到匹配的键,更新选中的键
if (matchingKey) {
setSelectedKeys([matchingKey]);
if (matchingKeys.length) {
setSelectedKeys(matchingKeys);
}
}, [location.pathname, routerMapState]);
@@ -446,121 +409,103 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
}
}, [persistedCollapsed, forceExpanded]);
// 选中高亮颜色(统一)
const SELECTED_COLOR = 'var(--ui-color-primary)';
const renderMenuIcon = (key) =>
React.cloneElement(getLucideIcon(key), {
size: 16,
strokeWidth: 1.5,
color: 'currentColor',
className: undefined,
'aria-hidden': true,
});
const renderGroup = (key, label, items) => {
const folded = foldedGroups.includes(key);
return (
<Nav.Group
itemKey={key}
folded={folded}
text={
<button
type='button'
className='sidebar-group-toggle'
aria-expanded={!folded}
onClick={() =>
setFoldedGroups((previous) =>
previous.includes(key)
? previous.filter((group) => group !== key)
: [...previous, key],
)
}
>
<span className='truncate'>{label}</span>
<ChevronDown size={13} className={folded ? '-rotate-90' : ''} />
</button>
}
>
{items}
</Nav.Group>
);
};
// 渲染自定义菜单项
const renderNavItem = (item) => {
// 跳过隐藏的项目
if (item.className === 'tableHiddle') return null;
const isSelected = selectedKeys.includes(item.itemKey);
const textColor = isSelected ? SELECTED_COLOR : 'inherit';
return (
<Nav.Item
key={item.itemKey}
itemKey={item.itemKey}
text={
<span
className='truncate font-medium text-sm'
style={{ color: textColor }}
>
{item.text}
</span>
}
icon={
<div className='sidebar-icon-container flex-shrink-0'>
{getLucideIcon(item.itemKey, isSelected)}
</div>
}
className={item.className}
/>
);
};
// 渲染子菜单项
const renderSubItem = (item) => {
if (item.items && item.items.length > 0) {
const isSelected = selectedKeys.includes(item.itemKey);
const textColor = isSelected ? SELECTED_COLOR : 'inherit';
return (
<Nav.Sub
key={item.itemKey}
itemKey={item.itemKey}
text={
<span
className='truncate font-medium text-sm'
style={{ color: textColor }}
>
{item.text}
</span>
}
icon={
<div className='sidebar-icon-container flex-shrink-0'>
{getLucideIcon(item.itemKey, isSelected)}
</div>
const renderGroup = (key, label, items) => (
<div key={key} className='ui-org-nav-group'>
{!collapsed && (
<button
type='button'
className='ui-org-group-toggle'
aria-expanded={!foldedGroups.includes(key)}
onClick={() =>
setFoldedGroups((previous) =>
previous.includes(key)
? previous.filter((group) => group !== key)
: [...previous, key],
)
}
>
{item.items.map((subItem) => {
const isSubSelected = selectedKeys.includes(subItem.itemKey);
const subTextColor = isSubSelected ? SELECTED_COLOR : 'inherit';
<span>{label}</span>
<ChevronDown
size={13}
className={foldedGroups.includes(key) ? 'is-folded' : ''}
aria-hidden='true'
/>
</button>
)}
<div
className='ui-org-group-items'
hidden={!collapsed && foldedGroups.includes(key)}
>
{items}
</div>
</div>
);
return (
<Nav.Item
key={subItem.itemKey}
itemKey={subItem.itemKey}
text={
<span
className='truncate font-medium text-sm'
style={{ color: subTextColor }}
>
{subItem.text}
</span>
}
/>
);
})}
</Nav.Sub>
);
} else {
return renderNavItem(item);
}
const renderNavItem = (item) => {
if (item.className === 'tableHiddle') return null;
const active = selectedKeys.includes(item.itemKey);
return (
<Link
key={item.itemKey}
to={routerMapState[item.itemKey] || routerMap[item.itemKey] || '#'}
onClick={onNavigate}
className='ui-center-menu-item'
data-active={active || undefined}
aria-current={active ? 'page' : undefined}
title={collapsed ? item.text : undefined}
>
{renderMenuIcon(item.itemKey)}
{!collapsed && (
<span className='ui-center-menu-label'>{item.text}</span>
)}
</Link>
);
};
const renderSubItem = (item) => {
if (!item.items?.length) return renderNavItem(item);
const open = openedKeys.includes(item.itemKey);
return (
<div key={item.itemKey}>
<button
type='button'
className='ui-center-menu-item ui-console-submenu-toggle'
title={collapsed ? item.text : undefined}
aria-label={item.text}
aria-expanded={open}
onClick={() =>
setOpenedKeys((previous) =>
previous.includes(item.itemKey)
? previous.filter((key) => key !== item.itemKey)
: [...previous, item.itemKey],
)
}
>
{renderMenuIcon(item.itemKey)}
{!collapsed && (
<span className='ui-center-menu-label'>{item.text}</span>
)}
</button>
<div className='ui-org-group-items' hidden={!open}>
{item.items.map(renderNavItem)}
</div>
</div>
);
};
return (
<div
className='sidebar-container'
className='ui-console-sidebar ui-center-sidebar'
data-collapsed={collapsed}
style={{
width: forceExpanded
? 'var(--sidebar-width)'
@@ -575,45 +520,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
collapsed={collapsed}
showAdmin={isAdmin()}
>
<Nav
className='sidebar-nav'
defaultIsCollapsed={collapsed}
isCollapsed={collapsed}
onCollapseChange={toggleCollapsed}
selectedKeys={selectedKeys}
itemStyle='sidebar-nav-item'
hoverStyle='sidebar-nav-item:hover'
selectedStyle='sidebar-nav-item-selected'
renderWrapper={({ itemElement, props }) => {
const to =
routerMapState[props.itemKey] || routerMap[props.itemKey];
// 如果没有路由,直接返回元素
if (!to) return itemElement;
return (
<Link
style={{ textDecoration: 'none' }}
to={to}
onClick={onNavigate}
>
{itemElement}
</Link>
);
}}
onSelect={(key) => {
// 如果点击的是已经展开的子菜单的父项,则收起子菜单
if (openedKeys.includes(key.itemKey)) {
setOpenedKeys(openedKeys.filter((k) => k !== key.itemKey));
}
setSelectedKeys([key.itemKey]);
}}
openKeys={openedKeys}
onOpenChange={(data) => {
setOpenedKeys(data.openKeys);
}}
>
<nav className='ui-center-sidebar-nav'>
{/* 聊天区域 */}
{hasSectionVisibleModules('chat') &&
renderGroup(
@@ -645,45 +552,20 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
t('管理员'),
adminItems.map(renderNavItem),
)}
</Nav>
</nav>
</SkeletonWrapper>
{/* 底部折叠按钮 —— 抽屉态不提供:收起后抽屉会变成 60px 窄条,等于自废 */}
{!forceExpanded && (
<div className='sidebar-collapse-button'>
<SkeletonWrapper
loading={showSkeleton}
type='button'
width={collapsed ? 36 : 156}
height={24}
className='w-full'
>
<Button
theme='outline'
type='tertiary'
size='small'
icon={
<ChevronLeft
size={16}
strokeWidth={2.5}
color='var(--ui-color-text-2)'
style={{
transform: collapsed ? 'rotate(180deg)' : 'rotate(0deg)',
}}
/>
}
onClick={toggleCollapsed}
aria-label={collapsed ? t('展开侧边栏') : t('收起侧边栏')}
style={
collapsed
? { width: 36, height: 24, padding: 0 }
: { padding: '4px 12px', width: '100%' }
}
>
{!collapsed ? t('收起侧边栏') : null}
</Button>
</SkeletonWrapper>
</div>
<button
type='button'
className='ui-center-sidebar-collapse'
onClick={toggleCollapsed}
aria-label={collapsed ? t('展开导航') : t('收起导航')}
>
{collapsed ? <ChevronRight size={16} /> : <ChevronLeft size={16} />}
{!collapsed && <span>{t('收起导航')}</span>}
</button>
)}
</div>
);
@@ -21,6 +21,7 @@ import React, { useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { Button, Dropdown } from '@/components/ui';
import { Compass, ExternalLink } from 'lucide-react';
import { isNavigationPathActive } from '../../console/consoleRoutes';
/**
* 移动端主导航入口。
@@ -41,14 +42,8 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
}
// 与 Navigation 一致:按完整路径段匹配,避免 /market 命中 /market-detail
const isPathActive = (matchPath) => {
if (!matchPath) return false;
if (matchPath === '/') return location.pathname === '/';
return (
location.pathname === matchPath ||
location.pathname.startsWith(`${matchPath}/`)
);
};
const isPathActive = (matchPath) =>
isNavigationPathActive(location.pathname, matchPath);
// 与 Navigation 一致:未登录时需要鉴权的入口统一引导到企业登录
const resolveTarget = (link) => {
@@ -122,7 +117,10 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
: '!text-gray-700 dark:!text-neutral-200'
}`}
>
<span className='flex items-center gap-1.5'>
<span
className='flex items-center gap-1.5'
aria-current={item.active ? 'page' : undefined}
>
{item.text}
{item.externalLink && (
<ExternalLink size={12} className='opacity-50' />
+11 -10
View File
@@ -22,6 +22,7 @@ import { Link, useLocation } from 'react-router-dom';
import { Dropdown } from '@/components/ui';
import { useTranslation } from 'react-i18next';
import SkeletonWrapper from '../components/SkeletonWrapper';
import { isNavigationPathActive } from '../../console/consoleRoutes';
const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
const location = useLocation();
@@ -36,13 +37,8 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
const spacingClasses = isMobile ? 'px-2 py-1 text-sm' : 'px-4 py-2';
// Match on full path segments so /market doesn't light up on /market-detail
const isPathActive = (matchPath) => {
if (matchPath === '/') return location.pathname === '/';
return (
location.pathname === matchPath ||
location.pathname.startsWith(`${matchPath}/`)
);
};
const isPathActive = (matchPath) =>
isNavigationPathActive(location.pathname, matchPath);
return mainNavLinks.map((link) => {
const linkContent = <span className='relative z-10'>{link.text}</span>;
@@ -58,7 +54,9 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
// Check if active
let isActive = false;
if (link.items && link.items.length > 0) {
if (link.activePrefix) {
isActive = isPathActive(link.activePrefix);
} else if (link.items && link.items.length > 0) {
isActive = link.items.some((subItem) => isPathActive(subItem.to));
} else if (!link.isExternal && targetPath) {
isActive = isPathActive(link.activePrefix || targetPath);
@@ -88,7 +86,10 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
</Dropdown.Menu>
}
>
<div className={`${finalClasses} cursor-pointer`}>
<div
className={`${finalClasses} cursor-pointer`}
aria-current={isActive ? 'page' : undefined}
>
{linkContent}
{/* Dropdown arrow */}
<svg
@@ -156,7 +157,7 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
className='ui-header-navigation flex flex-1 items-center gap-1 lg:gap-2 mx-1 sm:mx-3 md:mx-6 overflow-x-auto whitespace-nowrap scrollbar-hide min-w-0'
>
<SkeletonWrapper
loading={isLoading}
loading={isLoading && mainNavLinks.length === 0}
type='navigation'
count={4}
width={60}
+9 -7
View File
@@ -147,13 +147,15 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
/>
{/* 移动端:主导航收进下拉菜单,避免与右侧操作区互相挤压 */}
{!isAuthPage && isMobile && !isLoading && (
<MobileNavMenu
mainNavLinks={mainNavLinks}
userState={userState}
t={t}
/>
)}
{!isAuthPage &&
isMobile &&
(!isLoading || mainNavLinks.length > 0) && (
<MobileNavMenu
mainNavLinks={mainNavLinks}
userState={userState}
t={t}
/>
)}
</div>
{!isAuthPage && !isMobile && (