feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-04 19:59:06 +08:00
parent f1aa0399aa
commit 78fe73d0db
576 changed files with 18075 additions and 18912 deletions
+34 -41
View File
@@ -29,7 +29,7 @@ import {
Spin,
Empty,
Tag,
} from '@douyinfe/semi-ui';
} from '@/components/ui';
import {
Copy,
Users,
@@ -39,10 +39,10 @@ import {
Zap,
CreditCard,
DollarSign,
Sparkles,
UserPlus,
Link,
} from 'lucide-react';
import UserCenterPageHeader from '../../components/common/UserCenterPageHeader';
import { UserContext } from '../../context/User';
import { StatusContext } from '../../context/Status';
import {
@@ -345,52 +345,45 @@ const Invite = () => {
}
return (
<div className='relative p-4 sm:p-6'>
<div className='relative uc-page'>
<div className='pointer-events-none absolute inset-0 -z-10 bg-[radial-gradient(circle_at_8%_8%,rgba(14,165,233,0.12),transparent_28%),radial-gradient(circle_at_92%_12%,rgba(244,63,94,0.10),transparent_30%)]' />
{/* Page header */}
<div className='mb-6 flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between'>
<div className='flex items-center gap-3'>
<div className='flex h-12 w-12 items-center justify-center rounded-2xl bg-white/70 text-rose-500 shadow-[0_14px_34px_rgba(244,63,94,0.16)] ring-1 ring-white/70 backdrop-blur dark:bg-white/[0.06] dark:ring-white/10'>
<Gift size={23} />
</div>
<div>
<h1 className='flex items-center gap-2 text-2xl font-bold text-gray-950 dark:text-white'>
{t('\u9080\u8bf7\u6709\u5956')}
<Sparkles size={18} className='text-rose-500' />
</h1>
<p className='text-sm text-gray-500 dark:text-gray-400'>
{t('\u9080\u8bf7\u597d\u53cb\uff0c\u5171\u4eab\u5956\u52b1')}
</p>
</div>
</div>
<div className='flex flex-wrap gap-2'>
<Button
type='primary'
theme='solid'
disabled={!stats.current_aff_quota || stats.current_aff_quota <= 0}
onClick={() => {
setTransferAmount(stats.current_aff_quota || 0);
setOpenTransfer(true);
}}
icon={<Zap size={15} />}
className='!rounded-full !border-0 !bg-gradient-to-r !from-rose-500 !to-orange-400 !px-4 !shadow-lg !shadow-rose-500/20'
>
{t('\u5212\u8f6c\u5230\u4f59\u989d')}
</Button>
{stats.inviter_id === 0 && statusState?.status?.bind_inviter_enabled && (
<UserCenterPageHeader
title={t('\u9080\u8bf7\u6709\u5956')}
subtitle={t('\u9080\u8bf7\u597d\u53cb\uff0c\u5171\u4eab\u5956\u52b1')}
extra={
<>
<Button
theme='light'
type='primary'
icon={<UserPlus size={15} />}
onClick={() => setOpenBindInviter(true)}
className='!rounded-full !border !border-sky-200 !bg-sky-50/80 !px-4 !text-sky-700 dark:!border-sky-400/20 dark:!bg-sky-400/[0.08] dark:!text-sky-300'
theme='solid'
disabled={
!stats.current_aff_quota || stats.current_aff_quota <= 0
}
onClick={() => {
setTransferAmount(stats.current_aff_quota || 0);
setOpenTransfer(true);
}}
icon={<Zap size={15} />}
className='!rounded-full !border-0 !bg-gradient-to-r !from-rose-500 !to-orange-400 !px-4 !shadow-lg !shadow-rose-500/20'
>
{t('\u7ed1\u5b9a\u9080\u8bf7\u4eba')}
{t('\u5212\u8f6c\u5230\u4f59\u989d')}
</Button>
)}
</div>
</div>
{stats.inviter_id === 0 &&
statusState?.status?.bind_inviter_enabled && (
<Button
theme='light'
type='primary'
icon={<UserPlus size={15} />}
onClick={() => setOpenBindInviter(true)}
className='!rounded-full !border !border-sky-200 !bg-sky-50/80 !px-4 !text-sky-700 dark:!border-sky-400/20 dark:!bg-sky-400/[0.08] dark:!text-sky-300'
>
{t('\u7ed1\u5b9a\u9080\u8bf7\u4eba')}
</Button>
)}
</>
}
/>
{/* Stats overview */}
<div className='mb-5 grid grid-cols-1 gap-3 md:grid-cols-3'>
+6 -15
View File
@@ -31,7 +31,7 @@ import {
Typography,
Empty,
Spin,
} from '@douyinfe/semi-ui';
} from '@/components/ui';
import {
Receipt,
Plus,
@@ -39,6 +39,7 @@ import {
Eye,
X,
} from 'lucide-react';
import UserCenterPageHeader from '../../components/common/UserCenterPageHeader';
import { API, showError, showSuccess } from '../../helpers';
import {
INVOICE_STATUS,
@@ -400,13 +401,8 @@ const Invoice = () => {
if (!nuonuoEnabled) {
return (
<div className='p-4 sm:p-6'>
<div className='flex items-center gap-2 mb-4'>
<Receipt size={22} className='text-amber-500' />
<h1 className='text-xl font-bold text-gray-900 dark:text-white'>
{t('发票管理')}
</h1>
</div>
<div className='uc-page'>
<UserCenterPageHeader title={t('发票管理')} />
<Empty
image={<Receipt size={64} className='text-gray-300' />}
title={t('发票功能暂未开放')}
@@ -417,13 +413,8 @@ const Invoice = () => {
}
return (
<div className='p-4 sm:p-6'>
<div className='flex items-center gap-2 mb-4'>
<Receipt size={22} className='text-amber-500' />
<h1 className='text-xl font-bold text-gray-900 dark:text-white'>
{t('发票管理')}
</h1>
</div>
<div className='uc-page'>
<UserCenterPageHeader title={t('发票管理')} />
<Tabs type='line'>
<TabPane tab={t('申请开票')} itemKey='apply'>
+346 -205
View File
@@ -1,216 +1,357 @@
.usage-record-tab-button {
/*
* 使用记录(/user-center/usage-record)样式。
* 浅色数值来自原型图.zip:使用记录-消费记录.png、使用记录-绘图与视频.png(1920 宽视口实测)。
* 深色主题无原型:由既有主题变量与 Ant Design token 推导;JSX 中不写颜色。
*/
.usage-record-page {
--ur-card-border: #e6e9ef;
--ur-card-shadow: 0 4px 24px rgba(15, 23, 42, 0.02);
--ur-filter-bg: linear-gradient(90deg, #fffdf8 0%, #ffffff 55%);
--ur-label: #6b7789;
--ur-head-bg: #f8f9fc;
--ur-head-text: #687589;
--ur-row-split: #f0f0f0;
--ur-time-date: #8290a1;
--ur-text: rgba(0, 0, 0, 0.88);
--ur-model: #436f88;
--ur-cost: #b36513;
--ur-progress-done: #3d9a82;
--ur-success-bg: #edf7f2;
--ur-success-border: #dcebe5;
--ur-success-text: #24634f;
--ur-failure-bg: #fdf0ef;
--ur-failure-border: #f5e0dc;
--ur-failure-text: #a23d38;
--ur-pending-bg: #fff6e6;
--ur-pending-border: #f1e5cf;
--ur-pending-text: #80550e;
}
html.dark .usage-record-page {
--ur-card-border: var(--border-subtle);
--ur-card-shadow: none;
--ur-filter-bg: linear-gradient(
90deg,
color-mix(in srgb, var(--ui-color-primary) 6%, var(--surface-card)) 0%,
var(--surface-card) 55%
);
--ur-label: var(--text-secondary);
--ur-head-bg: var(--ui-color-fill-0);
--ur-head-text: var(--text-secondary);
--ur-row-split: var(--border-subtle);
--ur-time-date: var(--text-secondary);
--ur-text: var(--uc-heading);
--ur-model: color-mix(
in srgb,
var(--text-secondary) 70%,
rgb(var(--ui-blue-5))
);
--ur-cost: var(--ui-color-primary);
--ur-progress-done: var(--ui-color-success);
--ur-success-bg: color-mix(
in srgb,
var(--ui-color-success) 12%,
var(--surface-card)
);
--ur-success-border: color-mix(
in srgb,
var(--ui-color-success) 28%,
var(--surface-card)
);
--ur-success-text: var(--ui-color-success);
--ur-failure-bg: color-mix(
in srgb,
var(--ui-color-danger) 12%,
var(--surface-card)
);
--ur-failure-border: color-mix(
in srgb,
var(--ui-color-danger) 28%,
var(--surface-card)
);
--ur-failure-text: var(--ui-color-danger);
--ur-pending-bg: color-mix(
in srgb,
var(--ui-color-warning) 12%,
var(--surface-card)
);
--ur-pending-border: color-mix(
in srgb,
var(--ui-color-warning) 28%,
var(--surface-card)
);
--ur-pending-text: var(--ui-color-warning);
/* 在线原型深色:使用记录页签(选中文字与下划线)用品牌色 #f2ad41,其余主色为 #d1963a */
--ur-tab-accent: #f2ad41;
}
/* 页签:纯文字,主色 2px 下划线,页签间距 28px */
.usage-record-tabs > .ant-tabs-nav {
margin-bottom: 20px;
}
.usage-record-tabs .ant-tabs-tab + .ant-tabs-tab {
margin-left: 28px;
}
.usage-record-tabs > .ant-tabs-content-holder {
display: none;
}
html.dark .usage-record-tabs .ant-tabs-tab-active .ant-tabs-tab-btn {
color: var(--ur-tab-accent);
}
html.dark .usage-record-tabs .ant-tabs-ink-bar {
background: var(--ur-tab-accent);
}
.usage-record-panels {
display: flex;
flex-direction: column;
gap: 20px;
}
/* 卡片 */
.usage-record-card.ant-card {
border-color: var(--ur-card-border);
border-radius: 10px;
box-shadow: var(--ur-card-shadow);
}
.usage-record-card > .ant-card-body {
padding: 24px;
}
.usage-record-filter-card.ant-card {
background: var(--ur-filter-bg);
}
.usage-record-mobile-toggle {
margin-bottom: 12px;
}
/* 筛选:五列竖排标签表单,日期跨两列;重置/搜索右下 */
.usage-record-filter-grid {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
column-gap: 16px;
row-gap: 16px;
}
.usage-record-filter-grid .usage-record-filter-wide {
grid-column: span 2;
}
.usage-record-filter-form .ant-form-item {
margin-bottom: 0;
}
.usage-record-filter-form .ant-form-item-label {
padding-bottom: 8px;
}
.usage-record-filter-form .ant-form-item-label > label {
height: 21px;
color: var(--ur-label);
font-size: 13px;
}
.usage-record-filter-form .ant-picker,
.usage-record-filter-form .ant-select {
width: 100%;
}
.usage-record-filter-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 16px;
}
/* 表格卡 */
.usage-record-table-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
min-height: 34px;
margin: -6px 0 18px;
}
.usage-record-table-head h3 {
margin: 0;
color: var(--ur-text);
font-size: 15px;
font-weight: 600;
line-height: 24px;
}
.usage-record-table-actions {
display: flex;
align-items: center;
gap: 10px;
}
.usage-record-table-actions .ant-tag {
margin: 0;
}
.usage-record-table .ant-table-thead > tr > th {
height: 46px;
padding-block: 0;
border-bottom-color: var(--ur-row-split);
background: var(--ur-head-bg);
color: var(--ur-head-text);
font-weight: 400;
}
.usage-record-table .ant-table-tbody > tr > td {
border-bottom-color: var(--ur-row-split);
}
.usage-record-table .ant-tag {
margin-inline-end: 0;
}
.usage-record-time {
display: flex;
flex-direction: column;
line-height: 18px;
white-space: nowrap;
}
.usage-record-time span {
color: var(--ur-time-date);
font-size: 11px;
}
.usage-record-time strong {
margin-top: 3px;
color: var(--ur-text);
font-size: 15px;
font-weight: 600;
line-height: 20.33px;
}
.usage-record-copy-text {
padding: 0;
border: 0;
background: transparent;
color: inherit;
font: inherit;
cursor: pointer;
}
.usage-record-copy-text:hover {
color: var(--ui-color-primary);
}
/* 模型:等宽文本(复制与映射弹层沿用原有回调) */
.usage-record-model,
.usage-record-model .ant-tag {
color: var(--ur-model);
font-family: var(--ui-font-family-mono);
font-size: 12px;
}
.usage-record-model .ant-tag {
padding: 0;
border: 0;
background: transparent;
}
.usage-record-model .ant-tag > .anticon,
.usage-record-model .ant-tag > img,
.usage-record-model .ant-tag > svg {
display: none;
}
.usage-record-mono .ant-typography {
color: var(--ur-text);
font-family: var(--ui-font-family-mono);
font-size: 11px;
}
.usage-record-use-time {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 38px;
padding: 8px 16px;
border: 1px solid rgb(255 255 255 / 0.52);
border-radius: 999px;
background:
linear-gradient(180deg, rgb(255 255 255 / 0.66), rgb(255 255 255 / 0.32)),
color-mix(in srgb, var(--brand-gradient-via) 6%, transparent);
color: rgb(71 85 105);
font-size: 14px;
font-weight: 650;
box-shadow:
0 10px 24px rgb(15 23 42 / 0.06),
inset 0 1px 0 rgb(255 255 255 / 0.58);
backdrop-filter: blur(16px) saturate(1.25);
transition:
transform 160ms ease,
box-shadow 160ms ease,
border-color 160ms ease,
color 160ms ease;
white-space: nowrap;
}
.usage-record-use-time em {
color: var(--ur-time-date);
font-style: normal;
}
.usage-record-cost {
color: var(--ur-cost);
font-weight: 600;
}
.usage-record-link {
color: var(--ui-color-primary);
}
.usage-record-empty-hint {
margin-top: 4px;
color: var(--ui-color-text-2);
font-size: 12px;
}
.usage-record-pagination {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
.usage-record-tab-button:hover {
border-color: color-mix(in srgb, var(--brand-gradient-via) 38%, white);
color: var(--brand-gradient-to);
transform: translateY(-1px);
box-shadow:
0 14px 30px rgb(15 23 42 / 0.1),
inset 0 1px 0 rgb(255 255 255 / 0.66);
/* 绘图与视频:本页统计卡(原型三色卡) */
.usage-record-task-stats {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 15px;
}
.usage-record-task-stat {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 70px;
padding: 0 19px 0 18px;
border: 1px solid;
border-radius: 10px;
}
.usage-record-task-stat span {
font-size: 12px;
line-height: 18px;
}
.usage-record-task-stat strong {
font-size: 24px;
font-weight: 600;
line-height: 32px;
}
.usage-record-task-stat.is-success {
border-color: var(--ur-success-border);
background: var(--ur-success-bg);
color: var(--ur-success-text);
}
.usage-record-task-stat.is-failure {
border-color: var(--ur-failure-border);
background: var(--ur-failure-bg);
color: var(--ur-failure-text);
}
.usage-record-task-stat.is-pending {
border-color: var(--ur-pending-border);
background: var(--ur-pending-bg);
color: var(--ur-pending-text);
}
.usage-record-tab-button-active {
border-color: rgb(255 255 255 / 0.42);
background: linear-gradient(
135deg,
#0f6fff 0%,
#0958d9 54%,
#073b91 100%
) !important;
color: #fff !important;
box-shadow:
0 16px 36px rgb(9 88 217 / 0.3),
inset 0 1px 0 rgb(255 255 255 / 0.22);
text-shadow: 0 1px 2px rgb(15 23 42 / 0.35);
/* 计费详情弹窗(原型未定义:Ant Design 默认 + 语义背景/边框,无玻璃与模糊) */
.usage-billing-tile,
.usage-billing-factors {
padding: 12px;
border: 1px solid var(--border-subtle);
border-radius: 8px;
background: var(--surface-card);
}
.usage-billing-factors {
margin-top: 12px;
}
.usage-billing-pill {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
border: 1px solid var(--border-subtle);
border-radius: 6px;
background: var(--ui-color-fill-0);
font-size: 12px;
}
.usage-record-tab-button-active:hover {
color: #fff !important;
/* 窄屏:统一规范,筛选两列/一列,统计卡纵向 */
@media (max-width: 1200px) {
.usage-record-filter-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
.usage-record-tab-button-active svg {
filter: drop-shadow(0 1px 1px rgb(15 23 42 / 0.28));
}
.dark .usage-record-tab-button {
border-color: rgb(255 255 255 / 0.1);
background:
linear-gradient(180deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.035)),
rgb(15 23 42 / 0.32);
color: rgb(203 213 225);
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08);
}
.dark .usage-record-tab-button:hover {
border-color: color-mix(in srgb, var(--brand-gradient-from) 34%, transparent);
color: color-mix(in srgb, var(--brand-gradient-from) 82%, white);
}
html.dark .usage-record-tab-button-active,
body[theme-mode='dark'] .usage-record-tab-button-active {
border-color: rgb(125 211 252 / 0.38);
background: linear-gradient(
135deg,
#0f6fff 0%,
#0958d9 54%,
#073b91 100%
) !important;
color: #fff !important;
}
html.dark .usage-record-tab-button-active:hover,
body[theme-mode='dark'] .usage-record-tab-button-active:hover {
color: #fff !important;
}
html.dark .usage-record-page .semi-card-header,
body[theme-mode='dark'] .usage-record-page .semi-card-header {
border-bottom-color: rgb(148 163 184 / 0.14) !important;
background:
radial-gradient(
circle at 8% 0%,
color-mix(in srgb, var(--brand-gradient-from) 12%, transparent),
transparent 34%
),
linear-gradient(180deg, rgb(15 23 42 / 0.74), rgb(15 23 42 / 0.5)) !important;
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
}
html.dark .usage-record-page .usage-logs-filter-form,
body[theme-mode='dark'] .usage-record-page .usage-logs-filter-form,
html.dark .usage-record-page .usage-record-filter-form,
body[theme-mode='dark'] .usage-record-page .usage-record-filter-form {
border: 1px solid rgb(148 163 184 / 0.16) !important;
border-radius: 24px;
background:
linear-gradient(180deg, rgb(15 23 42 / 0.7), rgb(15 23 42 / 0.48)),
rgb(2 6 23 / 0.42) !important;
box-shadow:
0 18px 48px rgb(0 0 0 / 0.34),
inset 0 1px 0 rgb(255 255 255 / 0.06) !important;
backdrop-filter: blur(18px) saturate(1.1);
}
html.dark .usage-record-page .usage-record-filter-form {
padding: 16px;
}
body[theme-mode='dark'] .usage-record-page .usage-record-filter-form {
padding: 16px;
}
html.dark .usage-record-page .usage-logs-filter-title,
body[theme-mode='dark'] .usage-record-page .usage-logs-filter-title,
html.dark .usage-record-page .usage-record-filter-form > div > div:first-child,
body[theme-mode='dark']
.usage-record-page
.usage-record-filter-form
> div
> div:first-child {
border-bottom-color: rgb(148 163 184 / 0.16) !important;
}
html.dark .usage-record-page .semi-card-header .semi-input-wrapper,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-input-wrapper,
html.dark .usage-record-page .semi-card-header .semi-select,
body[theme-mode='dark'] .usage-record-page .semi-card-header .semi-select,
html.dark .usage-record-page .semi-card-header .semi-datepicker,
body[theme-mode='dark'] .usage-record-page .semi-card-header .semi-datepicker,
html.dark .usage-record-page .semi-card-header .semi-datepicker-range,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-datepicker-range {
border-color: rgb(148 163 184 / 0.16) !important;
background: rgb(15 23 42 / 0.58) !important;
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.05),
0 8px 24px rgb(0 0 0 / 0.16) !important;
}
html.dark .usage-record-page .semi-card-header .semi-input-wrapper:hover,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-input-wrapper:hover,
html.dark .usage-record-page .semi-card-header .semi-select:hover,
body[theme-mode='dark'] .usage-record-page .semi-card-header .semi-select:hover,
html.dark .usage-record-page .semi-card-header .semi-datepicker:hover,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-datepicker:hover,
html.dark .usage-record-page .semi-card-header .semi-datepicker-range:hover,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-datepicker-range:hover {
border-color: color-mix(
in srgb,
var(--brand-gradient-from) 42%,
transparent
) !important;
background: rgb(15 23 42 / 0.72) !important;
}
html.dark .usage-record-page .semi-card-header .semi-input,
body[theme-mode='dark'] .usage-record-page .semi-card-header .semi-input,
html.dark .usage-record-page .semi-card-header .semi-select-selection-text,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-select-selection-text,
html.dark .usage-record-page .semi-card-header .semi-datepicker-input,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-datepicker-input {
color: rgb(226 232 240) !important;
}
html.dark .usage-record-page .semi-card-header .semi-input::placeholder,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-input::placeholder,
html.dark
.usage-record-page
.semi-card-header
.semi-select-selection-placeholder,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-select-selection-placeholder,
html.dark .usage-record-page .semi-card-header .semi-datepicker-placeholder,
body[theme-mode='dark']
.usage-record-page
.semi-card-header
.semi-datepicker-placeholder {
color: rgb(148 163 184 / 0.82) !important;
@media (max-width: 768px) {
.usage-record-filter-grid,
.usage-record-task-stats {
grid-template-columns: minmax(0, 1fr);
}
.usage-record-filter-grid .usage-record-filter-wide {
grid-column: auto;
}
.usage-record-card > .ant-card-body {
padding: 16px;
}
.usage-record-table-head {
flex-wrap: wrap;
margin-top: 0;
}
}
+15 -53
View File
@@ -20,8 +20,9 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { BadgeCheck, Sparkles, Workflow } from 'lucide-react';
import { Tabs } from 'antd';
import UsageLogsTable from '../../components/table/usage-logs';
import UserCenterPageHeader from '../../components/common/UserCenterPageHeader';
import TaskLogsTable from '../../components/table/task-logs';
import '../../styles/usage-record-controls.css';
import './UsageRecord.css';
@@ -66,17 +67,13 @@ const UsageRecord = () => {
label: t('消费记录'),
// 标题随 tab 切换显示对应的"查看什么",避免"使用记录"这种笼统措辞让用户拿不准当前页面在看什么
title: t('消费记录'),
subtitle: t('查看API调用与计费明细'),
icon: BadgeCheck,
gradient: 'from-brand-from to-brand-to',
subtitle: t('查看 API 调用与计费明细'),
},
{
key: TAB_KEYS.TASK,
label: t('绘图与视频'),
title: t('绘图与视频'),
subtitle: t('查看异步任务的执行状态'),
icon: Workflow,
gradient: 'from-cyan-600 to-blue-600',
},
];
@@ -119,54 +116,19 @@ const UsageRecord = () => {
}, [activeTab, currentTab.title, t]);
return (
<div className='usage-record-page p-4 sm:p-6'>
<header className='mb-4 sm:mb-6 flex items-center gap-2 sm:gap-3'>
<div
className={`
relative flex items-center justify-center
w-10 h-10 sm:w-12 sm:h-12 rounded-lg sm:rounded-xl
bg-gradient-to-br ${currentTab.gradient}
shadow-lg
`}
>
<currentTab.icon
className='w-5 h-5 sm:w-6 sm:h-6 text-white'
strokeWidth={1.5}
/>
<Sparkles className='absolute -top-1 -right-1 w-3 h-3 sm:w-4 sm:h-4 text-amber-400 animate-pulse' />
</div>
<div>
<h1
className={`text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r ${currentTab.gradient}`}
>
{currentTab.title}
</h1>
<p className='text-xs sm:text-sm text-gray-500 dark:text-gray-400 mt-0.5 hidden sm:block'>
{currentTab.subtitle}
</p>
</div>
</header>
<div className='usage-record-page uc-page'>
<UserCenterPageHeader
title={currentTab.title}
subtitle={currentTab.subtitle}
/>
<nav className='flex gap-2 mb-4' aria-label={t('使用记录')}>
{tabs.map((tab) => {
const isActive = activeTab === tab.key;
const TabIcon = tab.icon;
return (
<button
key={tab.key}
onClick={() => handleTabChange(tab.key)}
className={`usage-record-tab-button ${
isActive
? `usage-record-tab-button-active bg-gradient-to-r ${tab.gradient}`
: ''
}`}
>
<TabIcon size={16} strokeWidth={2} />
{tab.label}
</button>
);
})}
</nav>
<Tabs
className='usage-record-tabs'
aria-label={t('使用记录')}
activeKey={activeTab}
onChange={handleTabChange}
items={tabs.map((tab) => ({ key: tab.key, label: tab.label }))}
/>
{mountedTabs.has(TAB_KEYS.USAGE) && (
<section hidden={activeTab !== TAB_KEYS.USAGE}>
+38 -154
View File
@@ -17,19 +17,20 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { Menu, Button } from 'antd';
import React, { useMemo, useContext } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import {
BarChart2,
FileText,
CreditCard,
LayoutGrid,
ScrollText,
Wallet,
KeyRound,
UserRound,
Receipt,
Gift,
UserCog,
ChevronLeft,
ChevronRight,
User,
Activity,
MonitorDown,
} from 'lucide-react';
@@ -101,13 +102,19 @@ const UserCenterSidebar = () => {
itemKey: '/user-center/dashboard',
configKey: 'dashboard',
text: t('数据看板'),
icon: BarChart2,
icon: LayoutGrid,
},
{
itemKey: '/user-center/usage-record',
configKey: 'usageRecord',
text: t('使用记录'),
icon: FileText,
icon: ScrollText,
},
{
itemKey: '/user-center/key-management',
configKey: 'keyManagement',
text: t('密钥管理'),
icon: KeyRound,
},
{
itemKey: '/user-center/service-dashboard',
@@ -119,7 +126,7 @@ const UserCenterSidebar = () => {
itemKey: '/user-center/topup',
configKey: 'topup',
text: t('在线充值'),
icon: CreditCard,
icon: Wallet,
},
{
itemKey: '/user-center/invoice',
@@ -137,7 +144,7 @@ const UserCenterSidebar = () => {
itemKey: '/user-center/settings',
configKey: 'settings',
text: t('个人设置'),
icon: UserCog,
icon: UserRound,
},
...(weyaiDownloadEnabled
? [
@@ -183,152 +190,29 @@ const UserCenterSidebar = () => {
const selectedKey = getSelectedKey();
return (
<div
className={`
relative flex flex-col h-full transition-all duration-300 ease-out
bg-white/60 dark:bg-neutral-900/60 backdrop-blur-2xl backdrop-saturate-[1.8]
border-r border-white/40 dark:border-neutral-700/50
shadow-[1px_0_24px_-4px_rgba(0,0,0,0.06)] dark:shadow-[1px_0_24px_-4px_rgba(0,0,0,0.3)]
${collapsed ? 'w-[68px]' : 'w-[240px]'}
`}
>
{/* 毛玻璃内层光泽 */}
<div className='absolute inset-0 bg-gradient-to-b from-white/40 via-white/10 to-white/20 dark:from-white/[0.06] dark:via-transparent dark:to-white/[0.03] pointer-events-none' />
{/* 顶部装饰渐变 —— 跟随品牌 */}
<div className='absolute top-0 left-0 right-0 h-32 bg-gradient-to-b from-brand/10 to-transparent pointer-events-none' />
{/* Logo/标题区域 */}
{!collapsed && (
<div className='px-4 pt-5 pb-3'>
<div className='flex items-center gap-2'>
<div className='p-1.5 bg-gradient-to-br from-brand-from to-brand-to rounded-lg shadow-md shadow-brand/25'>
<User size={16} className='text-white' />
</div>
<span className='font-bold text-gray-900 dark:text-white'>
{t('用户中心')}
</span>
</div>
</div>
)}
{/* 导航区域 */}
<nav
className={`relative flex-1 px-3 ${collapsed ? 'pt-4' : 'pt-2'} space-y-1.5 overflow-y-auto overflow-x-hidden`}
<aside className='ui-user-sidebar' style={{ width: collapsed ? 64 : 216 }}>
<Menu
mode='inline'
inlineCollapsed={collapsed}
selectedKeys={[selectedKey]}
items={items.map((item) => ({
key: item.itemKey,
icon: <item.icon size={16} strokeWidth={1.5} />,
label: <Link to={item.itemKey}>{item.text}</Link>,
}))}
/>
<Button
type='text'
className='ui-sidebar-collapse'
onClick={toggleCollapsed}
aria-label={collapsed ? t('展开导航') : t('收起导航')}
icon={
collapsed ? <ChevronRight size={16} /> : <ChevronLeft size={16} />
}
>
{items.map((item) => {
const isSelected = selectedKey === item.itemKey;
const IconComponent = item.icon;
return (
<Link
key={item.itemKey}
to={item.itemKey}
className={`
group relative flex items-center gap-3 rounded-xl transition-all duration-200
${collapsed ? 'justify-center p-3' : 'px-3 py-2.5'}
${
isSelected
? 'bg-brand/10 dark:bg-brand/15 shadow-sm shadow-brand/5'
: 'hover:bg-brand/5 dark:hover:bg-brand/10'
}
`}
>
{/* 选中指示器 —— 统一品牌色 */}
{isSelected && (
<div className='absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 rounded-r-full bg-gradient-to-b from-brand-from to-brand-to' />
)}
{/* 图标 —— 激活:品牌渐变实底白图标;非激活:中性底,hover 转品牌 */}
<div
className={`
relative flex-shrink-0 p-1.5 rounded-lg transition-all duration-200
${
isSelected
? 'bg-gradient-to-br from-brand-from to-brand-to shadow-lg shadow-brand/25'
: 'bg-gray-100/80 dark:bg-neutral-800/80 group-hover:bg-brand/10 group-hover:scale-105'
}
`}
>
<IconComponent
size={18}
strokeWidth={2}
className={
isSelected
? 'text-white'
: 'text-gray-500 dark:text-gray-400 group-hover:text-brand-deep dark:group-hover:text-brand-from transition-colors'
}
/>
</div>
{/* 文字 —— 激活品牌色加粗,非激活中性、hover 转品牌 */}
{!collapsed && (
<span
className={`
text-sm transition-colors truncate
${
isSelected
? 'text-brand-deep dark:text-brand-from font-semibold'
: 'font-medium text-gray-600 dark:text-gray-300 group-hover:text-brand-deep dark:group-hover:text-brand-from'
}
`}
>
{item.text}
</span>
)}
{/* Tooltip for collapsed state */}
{collapsed && (
<div
className='
absolute left-full ml-2 px-2.5 py-1.5
bg-gray-900 dark:bg-white text-white dark:text-gray-900
text-xs font-medium rounded-lg shadow-lg
opacity-0 invisible group-hover:opacity-100 group-hover:visible
transition-all duration-200 whitespace-nowrap z-50
'
>
{item.text}
<div
className='absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2
border-4 border-transparent border-r-gray-900 dark:border-r-white'
/>
</div>
)}
</Link>
);
})}
</nav>
{/* 底部分隔线装饰 */}
<div className='mx-4 h-px bg-gradient-to-r from-transparent via-gray-200/60 dark:via-neutral-700/60 to-transparent' />
{/* 底部折叠按钮 */}
<div className='relative p-3'>
<button
onClick={toggleCollapsed}
className={`
flex items-center justify-center gap-2 w-full py-2 rounded-lg
text-gray-500 dark:text-gray-400 text-sm font-medium
bg-white/50 dark:bg-neutral-800/50
border border-gray-200/40 dark:border-neutral-700/40
hover:bg-brand/10 dark:hover:bg-brand/15
hover:text-brand-deep dark:hover:text-brand-from
hover:border-brand/30
transition-all duration-200
${collapsed ? 'px-2' : 'px-3'}
`}
>
{collapsed ? (
<ChevronRight size={16} strokeWidth={2.5} />
) : (
<>
<ChevronLeft size={16} strokeWidth={2.5} />
<span>{t('收起')}</span>
</>
)}
</button>
</div>
</div>
{!collapsed && t('收起导航')}
</Button>
</aside>
);
};
+137 -235
View File
@@ -18,18 +18,12 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useContext, useEffect, useState } from 'react';
import { Button, Progress } from '@douyinfe/semi-ui';
import { IconFilter, IconRefresh } from '@douyinfe/semi-icons';
import {
BarChart2,
Sparkles,
Activity,
Calendar,
Crown,
Zap,
Clock,
TrendingUp,
} from 'lucide-react';
import { Select } from 'antd';
import UserCenterPageHeader from '../../components/common/UserCenterPageHeader';
import dashboardCompute from '../../assets/prototype/dashboard-compute.svg';
import { Button, Progress, Tag } from '@/components/ui';
import { IconFilter, IconRefresh } from '@/components/ui/icons';
import { Sparkles, Crown, Zap, Clock, TrendingUp } from 'lucide-react';
import { UserContext } from '../../context/User';
import { StatusContext } from '../../context/Status';
@@ -44,10 +38,7 @@ import { useDashboardData } from '../../hooks/dashboard/useDashboardData';
import { useDashboardStats } from '../../hooks/dashboard/useDashboardStats';
import { useDashboardCharts } from '../../hooks/dashboard/useDashboardCharts';
import {
CHART_CONFIG,
CARD_PROPS,
} from '../../constants/dashboard.constants';
import { CHART_CONFIG, CARD_PROPS } from '../../constants/dashboard.constants';
import { getTrendSpec } from '../../helpers/dashboard';
const UserDashboard = () => {
@@ -159,7 +150,11 @@ const UserDashboard = () => {
}, []);
return (
<div className='p-4 md:p-5 h-full overflow-y-auto relative'>
<div className='uc-dashboard h-full overflow-y-auto relative'>
{/* 原型 .dashboard-hero 装饰层:渐变、网格线、底部渐隐与右侧插画(纯视觉,不参与交互) */}
<div className='uc-dashboard-hero' aria-hidden='true'>
<img src={dashboardCompute} alt='' className='ui-dashboard-art' />
</div>
{/* 公告弹窗 */}
<NoticeModal
visible={noticeVisible}
@@ -171,76 +166,46 @@ const UserDashboard = () => {
{/* 主内容 - flex 列布局,数据分析区撑满剩余视口 */}
<div className='relative z-10 flex flex-col min-h-full'>
{/* Header - 更现代的设计 */}
<div className='flex flex-col lg:flex-row justify-between items-start lg:items-center gap-3 mb-5'>
<div className='flex items-center gap-4'>
{/* 动态图标容器 */}
<div className='relative group'>
<div className='absolute inset-0 bg-gradient-to-br from-brand-from via-brand-via to-brand-to rounded-2xl blur-lg opacity-50 group-hover:opacity-70 transition-opacity' />
<div className='relative p-3 bg-gradient-to-br from-brand-from via-brand-via to-brand-to rounded-2xl shadow-lg shadow-brand/25'>
<BarChart2 size={22} className='text-white' />
<Sparkles
size={11}
className='absolute -top-1 -right-1 text-amber-300 animate-pulse'
/>
</div>
</div>
<div>
<div className='flex items-center gap-2'>
<h1 className='text-xl md:text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-brand-deep via-brand to-brand-via dark:from-brand-from dark:via-brand-via dark:to-brand-to tracking-tight'>
{dashboardData.t('用量洞察中心')}
</h1>
{/* LIVE 实时脉冲指示 */}
<span className='inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-emerald-50 dark:bg-emerald-950/40 border border-emerald-200/60 dark:border-emerald-800/40'>
<span className='relative flex h-1.5 w-1.5'>
<span className='absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75 animate-ping' />
<span className='relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500' />
</span>
<span className='text-[10px] font-bold text-emerald-700 dark:text-emerald-300 tracking-wider'>
LIVE
</span>
</span>
</div>
<p className='text-xs md:text-sm text-gray-500 dark:text-gray-400 mt-0.5 flex items-center gap-1.5'>
<Activity size={12} className='text-brand' />
{dashboardData.t('实时追踪您的每一次调用与消费')}
</p>
</div>
</div>
{/* 操作按钮组 */}
<div className='flex items-center gap-3'>
{/* 时间范围显示 */}
<div className='hidden md:flex items-center gap-2 px-4 py-2 bg-white/60 dark:bg-neutral-800/70 backdrop-blur-sm rounded-xl border border-gray-200/50 dark:border-neutral-600/50'>
<Calendar size={14} className='text-gray-400' />
<span className='text-sm text-gray-600 dark:text-gray-300'>
{dashboardData.dataExportDefaultTime}
</span>
</div>
{/* 刷新按钮 */}
<Button
icon={<IconRefresh />}
onClick={initChart}
loading={dashboardData.loading || dashboardData.tokenUsageLoading}
>
{dashboardData.t('刷新')}
</Button>
{/* 筛选按钮 */}
<Button
type='tertiary'
icon={<IconFilter style={{ color: '#ffffff' }} />}
onClick={dashboardData.showSearchModal}
className='!rounded-xl !bg-gradient-to-r !from-brand-from !via-brand-via !to-brand-to !border-0 hover:!opacity-90 !transition-all !shadow-md !shadow-brand/30'
style={{ color: '#ffffff' }}
>
<span className='hidden sm:inline ml-1'>
<UserCenterPageHeader
title={dashboardData.t('用量洞察中心')}
subtitle={dashboardData.t(
'追踪每一次模型调用,让用量与成本清晰可见。',
)}
extra={
<div className='ui-page-actions'>
{/* 时间粒度:与筛选弹窗中的同名下拉共用 handleInputChange / 本地存储;
新粒度在下一次“刷新 / 筛选数据”加载时生效,不新增请求触发 */}
<Select
aria-label={dashboardData.t('时间粒度')}
value={dashboardData.dataExportDefaultTime}
options={dashboardData.timeOptions}
onChange={(value) =>
dashboardData.handleInputChange(
value,
'data_export_default_time',
)
}
/>
<Button
icon={<IconRefresh />}
onClick={initChart}
loading={
dashboardData.loading || dashboardData.tokenUsageLoading
}
>
{dashboardData.t('刷新')}
</Button>
<Button
theme='solid'
type='primary'
icon={<IconFilter />}
onClick={dashboardData.showSearchModal}
>
{dashboardData.t('筛选数据')}
</span>
</Button>
</div>
</div>
</Button>
</div>
}
/>
<SearchModal
searchModalVisible={dashboardData.searchModalVisible}
@@ -257,13 +222,6 @@ const UserDashboard = () => {
{/* 详细统计卡片 —— 扁平化:去掉外层白 panel,实底卡直接浮在页面 bg-glow 上 */}
<div className='mb-5'>
{/* 区块标题 */}
<div className='flex items-center gap-2 mb-3'>
<div className='w-1 h-4 bg-gradient-to-b from-brand-from via-brand-via to-brand-to rounded-full' />
<h2 className='text-base font-semibold text-gray-900 dark:text-white tracking-wide'>
{dashboardData.t('核心指标')}
</h2>
</div>
<StatsCards
groupedStatsData={groupedStatsData}
loading={dashboardData.loading || dashboardData.tokenUsageLoading}
@@ -273,159 +231,103 @@ const UserDashboard = () => {
/>
</div>
{/* 会员额度使用卡片 —— 扁平化:去掉外层白 panel,实底卡浮在 bg-glow 上 */}
{/* 会员额度使用卡片(原型无此状态:按统一规范使用语义底色/边框,无渐变、光晕与悬停位移) */}
{!membershipLoading && membershipInfo && (
<div className='mb-5'>
{/* 区块标题 */}
<div className='flex items-center justify-between mb-3'>
<div className='flex items-center gap-2'>
<div className='w-1 h-4 bg-gradient-to-b from-brand-from via-brand-via to-brand-to rounded-full' />
<h2 className='text-base font-semibold text-gray-900 dark:text-white tracking-wide'>
{dashboardData.t('会员权益')}
</h2>
<span className='text-xs text-gray-400 bg-gray-100 dark:bg-neutral-800 px-2 py-0.5 rounded-full'>
{membershipInfo.plan_name}
</span>
</div>
<div className='flex items-center gap-1.5 text-xs text-gray-400'>
<Clock size={12} />
<span>
{dashboardData.t('剩余')} {membershipInfo.remaining_days}{' '}
{dashboardData.t('天')}
</span>
</div>
</div>
<div className='uc-member-benefits'>
<div className='uc-member-benefits-head'>
<h2>{dashboardData.t('会员权益')}</h2>
<Tag size='small'>{membershipInfo.plan_name}</Tag>
<span className='uc-member-benefits-meta'>
<Clock size={12} />
{dashboardData.t('剩余')} {membershipInfo.remaining_days}{' '}
{dashboardData.t('天')}
</span>
</div>
{/* 卡片网格 */}
<div className='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3'>
{/* 今日可用额度 —— 青 */}
<div className='group/m relative overflow-hidden rounded-xl bg-white dark:bg-neutral-900/90 border border-gray-100 dark:border-neutral-800 shadow-[0_2px_12px_-2px_rgba(0,0,0,0.06)] dark:shadow-[0_2px_12px_-2px_rgba(0,0,0,0.4)] p-3 hover:shadow-[0_12px_28px_-6px_rgba(0,0,0,0.12)] hover:-translate-y-0.5 transition-all duration-300 ease-out'>
<div className='pointer-events-none absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-cyan-400 to-sky-500 opacity-70' />
<div className='absolute -top-6 -right-6 w-20 h-20 bg-gradient-to-br from-cyan-400/25 to-sky-300/5 rounded-full blur-2xl group-hover/m:scale-110 transition-transform duration-500' />
<div className='relative'>
<div className='flex items-center gap-2 mb-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-cyan-500 to-sky-600 flex items-center justify-center shadow-md shadow-cyan-500/25'>
<Sparkles size={14} className='text-white' />
</div>
<span className='text-xs text-gray-500 dark:text-gray-400'>
{dashboardData.t('今日剩余')}
</span>
</div>
<div className='text-xl font-bold text-gray-900 dark:text-white mb-2'>
{renderQuota(membershipInfo.membership_quota)}
</div>
{membershipInfo.daily_quota > 0 && (
<Progress
percent={Math.min(
100,
Math.max(
0,
Math.round(
(membershipInfo.membership_quota /
membershipInfo.daily_quota) *
100,
),
),
)}
showInfo={false}
stroke='#06b6d4'
style={{ height: 4 }}
/>
)}
</div>
</div>
{/* 今日已用额度 —— 天蓝 */}
<div className='group/m relative overflow-hidden rounded-xl bg-white dark:bg-neutral-900/90 border border-gray-100 dark:border-neutral-800 shadow-[0_2px_12px_-2px_rgba(0,0,0,0.06)] dark:shadow-[0_2px_12px_-2px_rgba(0,0,0,0.4)] p-3 hover:shadow-[0_12px_28px_-6px_rgba(0,0,0,0.12)] hover:-translate-y-0.5 transition-all duration-300 ease-out'>
<div className='pointer-events-none absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-sky-400 to-blue-500 opacity-70' />
<div className='absolute -top-6 -right-6 w-20 h-20 bg-gradient-to-br from-sky-400/25 to-blue-300/5 rounded-full blur-2xl group-hover/m:scale-110 transition-transform duration-500' />
<div className='relative'>
<div className='flex items-center gap-2 mb-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-sky-500 to-blue-600 flex items-center justify-center shadow-md shadow-sky-500/25'>
<Zap size={14} className='text-white' />
</div>
<span className='text-xs text-gray-500 dark:text-gray-400'>
{dashboardData.t('今日消耗')}
</span>
</div>
<div className='text-xl font-bold text-gray-900 dark:text-white mb-2'>
{renderQuota(
Math.max(
0,
membershipInfo.daily_quota -
membershipInfo.membership_quota,
<div className='uc-member-benefits-grid'>
<div className='uc-member-benefit'>
<span className='uc-member-benefit-label'>
<Sparkles size={14} />
{dashboardData.t('今日剩余')}
</span>
<strong>{renderQuota(membershipInfo.membership_quota)}</strong>
{membershipInfo.daily_quota > 0 && (
<Progress
percent={Math.min(
100,
Math.max(
0,
Math.round(
(membershipInfo.membership_quota /
membershipInfo.daily_quota) *
100,
),
)}
</div>
{membershipInfo.daily_quota > 0 && (
<div className='text-xs text-gray-400'>
{dashboardData.t('使用率')}{' '}
{Math.round(
Math.max(
0,
(membershipInfo.daily_quota -
membershipInfo.membership_quota) /
membershipInfo.daily_quota,
) * 100,
)}
%
</div>
),
)}
</div>
</div>
{/* 每日额度上限 —— 蓝 */}
<div className='group/m relative overflow-hidden rounded-xl bg-white dark:bg-neutral-900/90 border border-gray-100 dark:border-neutral-800 shadow-[0_2px_12px_-2px_rgba(0,0,0,0.06)] dark:shadow-[0_2px_12px_-2px_rgba(0,0,0,0.4)] p-3 hover:shadow-[0_12px_28px_-6px_rgba(0,0,0,0.12)] hover:-translate-y-0.5 transition-all duration-300 ease-out'>
<div className='pointer-events-none absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-blue-400 to-indigo-500 opacity-70' />
<div className='absolute -top-6 -right-6 w-20 h-20 bg-gradient-to-br from-blue-400/25 to-indigo-300/5 rounded-full blur-2xl group-hover/m:scale-110 transition-transform duration-500' />
<div className='relative'>
<div className='flex items-center gap-2 mb-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center shadow-md shadow-blue-500/25'>
<Crown size={14} className='text-white' />
</div>
<span className='text-xs text-gray-500 dark:text-gray-400'>
{dashboardData.t('每日总额')}
</span>
</div>
<div className='text-xl font-bold text-gray-900 dark:text-white mb-2'>
{renderQuota(membershipInfo.daily_quota)}
</div>
<div className='text-xs text-gray-400'>
{dashboardData.t('每日自动重置')}
</div>
</div>
</div>
{/* 累计已用额度 —— 靛 */}
<div className='group/m relative overflow-hidden rounded-xl bg-white dark:bg-neutral-900/90 border border-gray-100 dark:border-neutral-800 shadow-[0_2px_12px_-2px_rgba(0,0,0,0.06)] dark:shadow-[0_2px_12px_-2px_rgba(0,0,0,0.4)] p-3 hover:shadow-[0_12px_28px_-6px_rgba(0,0,0,0.12)] hover:-translate-y-0.5 transition-all duration-300 ease-out'>
<div className='pointer-events-none absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-indigo-400 to-violet-500 opacity-70' />
<div className='absolute -top-6 -right-6 w-20 h-20 bg-gradient-to-br from-indigo-400/25 to-violet-300/5 rounded-full blur-2xl group-hover/m:scale-110 transition-transform duration-500' />
<div className='relative'>
<div className='flex items-center gap-2 mb-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-violet-600 flex items-center justify-center shadow-md shadow-indigo-500/25'>
<TrendingUp size={14} className='text-white' />
</div>
<span className='text-xs text-gray-500 dark:text-gray-400'>
{dashboardData.t('累计消耗')}
</span>
</div>
<div className='text-xl font-bold text-gray-900 dark:text-white mb-2'>
{renderQuota(membershipInfo.membership_used_quota || 0)}
</div>
<div className='text-xs text-gray-400'>
{dashboardData.t('会员期间总消耗')}
</div>
</div>
</div>
showInfo={false}
stroke='var(--ui-color-primary)'
style={{ height: 4 }}
/>
)}
</div>
<div className='uc-member-benefit'>
<span className='uc-member-benefit-label'>
<Zap size={14} />
{dashboardData.t('今日消耗')}
</span>
<strong>
{renderQuota(
Math.max(
0,
membershipInfo.daily_quota -
membershipInfo.membership_quota,
),
)}
</strong>
{membershipInfo.daily_quota > 0 && (
<small>
{dashboardData.t('使用率')}{' '}
{Math.round(
Math.max(
0,
(membershipInfo.daily_quota -
membershipInfo.membership_quota) /
membershipInfo.daily_quota,
) * 100,
)}
%
</small>
)}
</div>
<div className='uc-member-benefit'>
<span className='uc-member-benefit-label'>
<Crown size={14} />
{dashboardData.t('每日总额')}
</span>
<strong>{renderQuota(membershipInfo.daily_quota)}</strong>
<small>{dashboardData.t('每日自动重置')}</small>
</div>
<div className='uc-member-benefit'>
<span className='uc-member-benefit-label'>
<TrendingUp size={14} />
{dashboardData.t('累计消耗')}
</span>
<strong>
{renderQuota(membershipInfo.membership_used_quota || 0)}
</strong>
<small>{dashboardData.t('会员期间总消耗')}</small>
</div>
</div>
</div>
)}
{/* 模型数据分析图表 - 自适应填满剩余视口高度。扁平化:去外层白 panel,图卡自身实底 */}
<div className='flex-1 flex flex-col min-h-[420px]'>
{/* 区块标题 */}
<div className='flex items-center gap-2 mb-3 shrink-0'>
<div className='w-1 h-4 bg-gradient-to-b from-brand-from via-brand-via to-brand-to rounded-full' />
<div className='ui-dashboard-chart-heading flex items-center gap-2 mb-3 shrink-0'>
<h2 className='text-base font-semibold text-gray-900 dark:text-white tracking-wide'>
{dashboardData.t('用量洞察')}
</h2>
+95 -92
View File
@@ -27,15 +27,17 @@ import {
} from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import {
KeyRound,
LayoutGrid,
ScrollText,
Wallet,
UserRound,
Activity,
BarChart2,
CreditCard,
FileText,
Gift,
Receipt,
Settings,
} from 'lucide-react';
import { StatusContext } from '../../context/Status';
import { useMarquee } from '../../hooks/common/useMarquee';
import PageBackground from '../../components/common/PageBackground';
import UserCenterSidebar from './UserCenterSidebar';
import UserDashboard from './UserDashboard';
@@ -47,6 +49,7 @@ import TopUp from '../TopUp';
import PersonalSetting from '../../components/settings/PersonalSetting';
import ServiceDashboard from '../ServiceDashboard';
import WeyAiDownload from '../WeyAiDownload';
import KeyManagement from '../KeyManagement';
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
// 移动端底部导航组件
@@ -58,16 +61,22 @@ const MobileBottomNav = ({ sidebarConfig }) => {
const navItems = [
{
key: 'dashboard',
icon: BarChart2,
icon: LayoutGrid,
label: t('概览'),
path: '/user-center/dashboard',
},
{
key: 'usageRecord',
icon: FileText,
icon: ScrollText,
label: t('记录'),
path: '/user-center/usage-record',
},
{
key: 'keyManagement',
icon: KeyRound,
label: t('密钥管理'),
path: '/user-center/key-management',
},
{
key: 'serviceDashboard',
icon: Activity,
@@ -82,7 +91,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
},
{
key: 'topup',
icon: CreditCard,
icon: Wallet,
label: t('充值'),
path: '/user-center/topup',
},
@@ -94,7 +103,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
},
{
key: 'settings',
icon: Settings,
icon: UserRound,
label: t('设置'),
path: '/user-center/settings',
},
@@ -110,7 +119,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
}
return (
<div className='md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl border-t border-gray-200/80 dark:border-neutral-800/80 safe-area-inset-bottom'>
<nav className='uc-mobile-nav md:hidden fixed bottom-0 left-0 right-0 z-50 safe-area-inset-bottom'>
<div className='flex items-center justify-around h-14'>
{visibleNavItems.map((item) => {
const isActive =
@@ -121,43 +130,29 @@ const MobileBottomNav = ({ sidebarConfig }) => {
return (
<button
key={item.key}
type='button'
data-active={isActive}
aria-current={isActive ? 'page' : undefined}
onClick={() => navigate(item.path)}
className={`flex flex-col items-center justify-center flex-1 h-full transition-all ${
isActive ? 'scale-105' : 'opacity-60'
}`}
className='uc-mobile-nav-item flex flex-col items-center justify-center flex-1 h-full'
>
<div
className={`p-1.5 rounded-lg ${isActive ? 'bg-gradient-to-br from-blue-500 to-brand-to' : ''}`}
>
<IconComponent
size={20}
className={
isActive ? 'text-white' : 'text-gray-500 dark:text-gray-400'
}
/>
</div>
<span
className={`text-[10px] mt-0.5 font-medium ${
isActive
? 'text-gray-900 dark:text-white'
: 'text-gray-500 dark:text-gray-400'
}`}
>
{item.label}
</span>
<IconComponent size={20} />
<span>{item.label}</span>
</button>
);
})}
</div>
</div>
</nav>
);
};
const UserCenter = () => {
const UserCenter = ({ keyManagementMode = false }) => {
const [statusState] = useContext(StatusContext);
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
const ucRoute = useLocation().pathname.split('/')[2] || 'dashboard';
// 跑马灯公告是否存在(用于动态计算顶部间距)
const hasMarquee = !!statusState?.status?.marquee_content?.trim();
const { visible: hasMarquee } = useMarquee();
const userCenterConfig = useMemo(
() =>
normalizeSidebarModulesAdmin(statusState?.status?.SidebarModulesAdmin)
@@ -198,13 +193,14 @@ const UserCenter = () => {
return element;
};
if (!firstVisiblePath) {
if (!firstVisiblePath && !keyManagementMode) {
return <Navigate to='/' replace />;
}
return (
<div
className={`flex flex-col md:flex-row h-screen overflow-hidden bg-[var(--surface-bg-base)] transition-colors duration-300 ${hasMarquee ? 'pt-[96px] sm:pt-[104px]' : 'pt-14 sm:pt-16'}`}
data-uc-route={ucRoute}
className={`user-center flex flex-col md:flex-row h-screen overflow-hidden bg-[var(--surface-bg-base)] ${hasMarquee ? 'pt-[91px] md:pt-[107px]' : 'pt-14 md:pt-[72px]'}`}
>
{/* Sidebar - 仅桌面端 */}
<div className='hidden md:block flex-shrink-0 h-full'>
@@ -218,68 +214,75 @@ const UserCenter = () => {
{/* 内容区域 */}
<div className='relative z-10 h-full overflow-y-auto uc-page-scrollbar'>
<Routes>
<Route
path='/'
element={<Navigate to={firstVisibleRoute} replace />}
/>
<Route
path='dashboard'
element={guardUserCenterRoute('dashboard', <UserDashboard />)}
/>
<Route
path='usage-record'
element={guardUserCenterRoute('usageRecord', <UsageRecord />)}
/>
{/* ServiceDashboard 组件内部有 min-h-screen pt-[88px],嵌入 UserCenter 后用 -mt-[64px] 部分抵消 pt,保留 24px 顶部间距(与其他页面 p-6 一致),[&>div]:min-h-0 避免撑高 */}
<Route
path='service-dashboard'
element={guardUserCenterRoute(
'serviceDashboard',
<div className='-mt-[64px] [&>div]:min-h-0'>
<ServiceDashboard />
</div>,
)}
/>
{/* TopUp 组件内部有 pt-[64px] 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消。
* embedded:UserCenter shell 已提供 PageBackground,子页面不再渲染自身背景,避免双层叠加 */}
<Route
path='topup'
element={guardUserCenterRoute(
'topup',
<div className='-mt-[64px]'>
<TopUp embedded />
</div>,
)}
/>
{/* PersonalSetting 内部有 pt-16 sm:pt-20 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消 */}
{/* 邀请返利 / 发票抬头:侧栏项、routePathMap、权限守卫此前都已配好,
{keyManagementMode ? (
<KeyManagement embedded />
) : (
<Routes>
<Route
path='/'
element={<Navigate to={firstVisibleRoute} replace />}
/>
<Route
path='dashboard'
element={guardUserCenterRoute('dashboard', <UserDashboard />)}
/>
<Route
path='usage-record'
element={guardUserCenterRoute('usageRecord', <UsageRecord />)}
/>
{/* ServiceDashboard 组件内部有 min-h-screen pt-[88px],嵌入 UserCenter 后用 -mt-[64px] 部分抵消 pt,保留 24px 顶部间距(与其他页面 p-6 一致),[&>div]:min-h-0 避免撑高 */}
<Route
path='service-dashboard'
element={guardUserCenterRoute(
'serviceDashboard',
<div className='-mt-[64px] [&>div]:min-h-0'>
<ServiceDashboard />
</div>,
)}
/>
{/* TopUp 组件内部有 pt-[64px] 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消。
* embedded:UserCenter shell 已提供 PageBackground,子页面不再渲染自身背景,避免双层叠加 */}
<Route
path='topup'
element={guardUserCenterRoute(
'topup',
<div className='-mt-[64px]'>
<TopUp embedded />
</div>,
)}
/>
{/* PersonalSetting 内部有 pt-16 sm:pt-20 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消 */}
{/* 邀请返利 / 发票抬头:侧栏项、routePathMap、权限守卫此前都已配好,
唯独漏了这两个 <Route>,导致点进来是空白内容区。
手机端侧栏是 hidden md:block,底部导航是唯一入口,等于两个死路口。
两个组件根节点都是 p-4 sm:p-6、无自带顶部偏移,可直接嵌入。 */}
<Route
path='invite'
element={guardUserCenterRoute('invite', <Invite />)}
/>
<Route
path='invoice'
element={guardUserCenterRoute('invoice', <Invoice />)}
/>
<Route
path='settings'
element={guardUserCenterRoute(
'settings',
<div className='-mt-16 sm:-mt-20 [&_.sticky]:!top-4'>
<PersonalSetting />
</div>,
)}
/>
{/* WeyAi 桌面端下载:侧栏入口指到这里而不是独立的 /weyai/download,
<Route
path='invite'
element={guardUserCenterRoute('invite', <Invite />)}
/>
<Route
path='invoice'
element={guardUserCenterRoute('invoice', <Invoice />)}
/>
<Route
path='settings'
element={guardUserCenterRoute(
'settings',
<div className='-mt-16 sm:-mt-20 [&_.sticky]:!top-4'>
<PersonalSetting />
</div>,
)}
/>
{/* WeyAi 桌面端下载:侧栏入口指到这里而不是独立的 /weyai/download,
否则点一下侧栏就整页跳走、导航栏消失。embedded:不加顶部让位、
不自绘背景(shell 已有 PageBackground)。未开放时页面自身显示空态,
侧栏项也随开关隐藏,无需再加守卫 */}
<Route path='weyai-download' element={<WeyAiDownload embedded />} />
</Routes>
<Route
path='weyai-download'
element={<WeyAiDownload embedded />}
/>
</Routes>
)}
</div>
</div>