fix(ui): 修复登录和并发请求并统一页面展示

调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
zhanjunhao
2026-11-19 18:58:46 +08:00
parent 9b6eb1c7c4
commit 7908ed53a3
128 changed files with 4672 additions and 5391 deletions
+116 -128
View File
@@ -16,24 +16,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import {
Eye as ActionEye,
Check as ActionCheck,
X as ActionX,
Ban as ActionBan,
RotateCw as ActionRotateCw,
} from '@/components/common/icons/ActionIcons';
import {
ConsoleCard,
ConsoleSearchBar,
ConsoleSearchActions,
ConsoleFilterField,
ConsoleFilterGrid,
ConsoleListTable,
} from '../../components/console/ConsolePrimitives';
import ConsoleCollection from '../../components/console/ConsoleCollection';
import { TableRowActions } from '../../components/common/table/TableToolbar';
import { useIsMobile } from '../../hooks/common/useIsMobile';
import { createCardProPagination } from '../../helpers/utils';
import React, { useEffect, useState, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import {
Table,
Button,
Input,
Tag,
@@ -63,6 +60,7 @@ const paymentMethodMap = {
const AdminInvoice = () => {
const { t, i18n } = useTranslation();
const isMobile = useIsMobile();
const [invoices, setInvoices] = useState([]);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
@@ -118,6 +116,13 @@ const AdminInvoice = () => {
setSearchKeyword(keyword);
};
const handleReset = () => {
setPage(1);
setKeyword('');
setSearchKeyword('');
setStatusFilter('');
};
const handleStatusFilterChange = (value) => {
setPage(1);
setStatusFilter(value || '');
@@ -301,138 +306,118 @@ const AdminInvoice = () => {
},
{
title: t('操作'),
width: 200,
key: 'actions',
width: 140,
fixed: 'right',
render: (_, record) => (
<div className='flex items-center gap-1 flex-wrap'>
<TableRowActions
items={[
record.status === INVOICE_STATUS.PENDING && {
key: 'approve',
label: t('通过'),
onClick: () => {
setApproveId(record.id);
setApproveVisible(true);
},
},
record.status === INVOICE_STATUS.PENDING && {
key: 'reject',
label: t('拒绝'),
danger: true,
onClick: () => {
setRejectId(record.id);
setRejectVisible(true);
},
},
record.status === INVOICE_STATUS.FAILED && {
key: 'retry',
label: t('重试'),
onClick: () => handleRetry(record.id),
},
[
INVOICE_STATUS.APPROVED,
INVOICE_STATUS.INVOICING,
INVOICE_STATUS.FAILED,
].includes(record.status) && {
key: 'cancel',
label: t('取消'),
danger: true,
onClick: () => handleFailCancel(record.id),
},
]}
>
<Button
type='link'
size='small'
theme='borderless'
icon={<ActionEye size={14} />}
onClick={() => handleViewDetail(record.id)}
/>
{record.status === INVOICE_STATUS.PENDING && (
<>
<Button
size='small'
theme='borderless'
type='primary'
icon={<ActionCheck size={14} />}
onClick={() => {
setApproveId(record.id);
setApproveVisible(true);
}}
>
{t('通过')}
</Button>
<Button
size='small'
theme='borderless'
type='danger'
icon={<ActionX size={14} />}
onClick={() => {
setRejectId(record.id);
setRejectVisible(true);
}}
>
{t('拒绝')}
</Button>
</>
)}
{(record.status === INVOICE_STATUS.APPROVED ||
record.status === INVOICE_STATUS.INVOICING) && (
<Button
size='small'
theme='borderless'
type='danger'
icon={<ActionBan size={14} />}
onClick={() => handleFailCancel(record.id)}
>
{t('取消')}
</Button>
)}
{record.status === INVOICE_STATUS.FAILED && (
<>
<Button
size='small'
theme='borderless'
icon={<ActionRotateCw size={14} />}
onClick={() => handleRetry(record.id)}
>
{t('重试')}
</Button>
<Button
size='small'
theme='borderless'
type='danger'
icon={<ActionBan size={14} />}
onClick={() => handleFailCancel(record.id)}
>
{t('取消')}
</Button>
</>
)}
</div>
>
{t('详情')}
</Button>
</TableRowActions>
),
},
];
return (
<div className='console-content'>
{/* 筛选区:标题与筛选项同行 */}
<ConsoleSearchBar formProps={{ layout: 'inline' }}>
<div className='console-search-fields'>
<Input
prefix={<Search size={14} />}
placeholder={t('搜索抬头/税号/订单号/用户')}
value={keyword}
onChange={setKeyword}
onEnterPress={handleSearch}
style={{ width: 240 }}
/>
<Select
placeholder={t('状态')}
value={statusFilter || undefined}
onChange={handleStatusFilterChange}
style={{ width: 120 }}
allowClear
optionList={[
{ label: t('待审核'), value: '1' },
{ label: t('审核通过'), value: '2' },
{ label: t('已拒绝'), value: '3' },
{ label: t('开票中'), value: '4' },
{ label: t('已开票'), value: '5' },
{ label: t('已取消'), value: '6' },
{ label: t('开票失败'), value: '7' },
]}
/>
<ConsoleSearchActions onSearch={handleSearch} loading={loading} />
</div>
</ConsoleSearchBar>
{/* 表格 */}
<ConsoleCard>
<Table
<ConsoleCollection
searchArea={
<ConsoleFilterGrid
onReset={handleReset}
onSearch={handleSearch}
loading={loading}
>
<ConsoleFilterField label={t('搜索关键字')} id='invoice-keyword'>
<Input
id='invoice-keyword'
prefix={<Search size={14} />}
placeholder={t('搜索抬头/税号/订单号/用户')}
value={keyword}
onChange={setKeyword}
onEnterPress={handleSearch}
/>
</ConsoleFilterField>
<ConsoleFilterField label={t('状态')} id='invoice-status'>
<Select
id='invoice-status'
placeholder={t('状态')}
value={statusFilter || undefined}
onChange={handleStatusFilterChange}
allowClear
optionList={[
{ label: t('待审核'), value: '1' },
{ label: t('审核通过'), value: '2' },
{ label: t('已拒绝'), value: '3' },
{ label: t('开票中'), value: '4' },
{ label: t('已开票'), value: '5' },
{ label: t('已取消'), value: '6' },
{ label: t('开票失败'), value: '7' },
]}
/>
</ConsoleFilterField>
</ConsoleFilterGrid>
}
paginationArea={createCardProPagination({
currentPage: page,
pageSize,
total,
onPageChange: setPage,
onPageSizeChange: (size) => {
setPage(1);
setPageSize(size);
},
isMobile,
t,
})}
>
<ConsoleListTable
columns={columns}
dataSource={invoices}
loading={loading}
rowKey='id'
pagination={{
currentPage: page,
total,
pageSize,
onPageChange: setPage,
onPageSizeChange: (size) => {
setPage(1);
setPageSize(size);
},
showTotal: true,
}}
scroll={{ x: 1100 }}
size='middle'
empty={t('暂无发票数据')}
pagination={false}
/>
</ConsoleCard>
</ConsoleCollection>
{/* 审核通过弹窗 */}
<Modal
@@ -510,7 +495,10 @@ const AdminInvoice = () => {
<div>
{detailData.display_name ||
detailData.username ||
`User#${detailData.user_id}`}
formatUserReference(
detailData.display_name || detailData.username,
detailData.user_id,
)}
</div>
</div>
<div>
+63 -86
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { TableRowActions } from '@/components/common/table/TableToolbar';
import {
ExternalLink as ActionExternalLink,
BarChart3 as ActionBarChart3,
@@ -852,95 +853,71 @@ const AdminOrganizations = () => {
},
{
title: t('操作'),
width: 380,
render: (_, record) => (
<div className='console-module-row-actions'>
{isAdmin() && (
<>
<Button
type='link'
size='small'
onClick={() => openEditModal(record)}
>
{t('编辑')}
</Button>
<Button
type='link'
size='small'
onClick={() => {
key: 'actions',
width: 140,
fixed: 'right',
render: (_, record) =>
isAdmin() ? (
<TableRowActions
items={[
{
key: 'quota',
label: t('调额'),
onClick: () => {
setQuotaOrgId(record.id);
setQuotaAmount(0);
setQuotaModalVisible(true);
}}
>
{t('调额')}
</Button>
<Button
type='link'
size='small'
onClick={() => openFeatureModal(record)}
>
{t('功能开关')}
</Button>
{record.status === 4 ? (
<Button
size='small'
type='link'
onClick={() => handleActivate(record.id)}
>
{t('激活')}
</Button>
) : record.status === 1 ? (
<Button
size='small'
type='link'
onClick={() => handleStatusChange(record.id, 2)}
>
{t('冻结')}
</Button>
) : (
<Button
size='small'
type='link'
onClick={() => handleStatusChange(record.id, 1)}
>
{t('解冻')}
</Button>
)}
<Button
type='link'
size='small'
danger
onClick={() => handleDelete(record.id)}
>
{t('删除')}
</Button>
{isRoot() && (
<Button
size='small'
type='link'
loading={alertToggleLoading === record.id}
title={
alertExcludedIds.has(record.id)
? t('已屏蔽预警,点击恢复')
: t('屏蔽该企业的预警通知')
}
aria-label={
alertExcludedIds.has(record.id)
? t('恢复该企业的预警')
: t('屏蔽该企业的预警')
}
onClick={() => toggleAlertExclude(record)}
>
{alertExcludedIds.has(record.id)
? t('恢复通知')
: t('屏蔽通知')}
</Button>
)}
</>
)}
</div>
),
},
},
{
key: 'features',
label: t('功能开关'),
onClick: () => openFeatureModal(record),
},
{
key: 'status',
label:
record.status === 4
? t('激活')
: record.status === 1
? t('冻结')
: t('解冻'),
onClick: () =>
record.status === 4
? handleActivate(record.id)
: handleStatusChange(
record.id,
record.status === 1 ? 2 : 1,
),
},
isRoot() && {
key: 'notifications',
disabled: alertToggleLoading === record.id,
label: alertExcludedIds.has(record.id)
? t('恢复通知')
: t('屏蔽通知'),
title: alertExcludedIds.has(record.id)
? t('已屏蔽预警,点击恢复')
: t('屏蔽该企业的预警通知'),
onClick: () => toggleAlertExclude(record),
},
{
key: 'delete',
label: t('删除'),
danger: true,
onClick: () => handleDelete(record.id),
},
]}
>
<Button
type='link'
size='small'
onClick={() => openEditModal(record)}
>
{t('编辑')}
</Button>
</TableRowActions>
) : null,
},
];
+2 -2
View File
@@ -522,8 +522,8 @@
两列都给定上限并整体居中——否则宽屏下 1fr 撑满而 composer 自身
max-width 封顶,右侧会空出一大片(用户反馈:大面积空白)。 */
.brain-expert-layout.is-composing {
grid-template-columns: minmax(220px, 280px) minmax(0, 860px);
justify-content: center;
grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
justify-content: start;
}
.brain-expert-grid {
display: grid;
+13 -6
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatPercent } from '../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
@@ -1611,7 +1613,7 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
}
if (assignmentScope === 'member') {
return members.map((item) => ({
label: item.display_name || item.username || `#${item.id}`,
label: item.display_name || item.username || formatIdReference(item.id),
value: item.id,
}));
}
@@ -1640,9 +1642,11 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
)
.map((item) => ({
...item,
expert_name: expertNameById.get(item.expert_id) || `#${item.expert_id}`,
expert_name:
expertNameById.get(item.expert_id) ||
formatIdReference(item.expert_id),
scope_type_label: scopeTypeLabel[item.scope_type] || item.scope_type,
scope_label: item.scope_name || `#${item.scope_id}`,
scope_label: item.scope_name || formatIdReference(item.scope_id),
}));
}, [assignments, expertCatalog, t]);
@@ -1882,7 +1886,9 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
</div>
<div>
<span>{t('任务完成率')}</span>
<strong>{(metrics.completion_rate * 100).toFixed(1)}%</strong>
<strong>
{formatPercent(Number(metrics.completion_rate) * 100, 1)}
</strong>
</div>
<div>
<span>{t('平均耗时')}</span>
@@ -1892,7 +1898,7 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
<span>{t('用户认可率')}</span>
<strong>
{metrics.feedback_count
? `${(metrics.useful_rate * 100).toFixed(1)}%`
? formatPercent(Number(metrics.useful_rate) * 100, 1)
: '—'}
</strong>
</div>
@@ -2702,7 +2708,8 @@ const CloudBrain = ({ organization = false, orgId = 0, canManage = false }) => {
<b>[{citation.citation_id}]</b>
<span>{citation.source_label}</span>
<small>
{t('相关度')} {(citation.score * 100).toFixed(1)}%
{t('相关度')}{' '}
{formatPercent(Number(citation.score) * 100, 1)}
</small>
</div>
))}
+4 -2
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatUserReference } from '../../helpers/safeDisplay';
import React, { useEffect, useState } from 'react';
import { Button, Descriptions, Spin, Tag } from 'antd';
@@ -112,7 +114,7 @@ export default function PartnerDetail({
['主体类型', commissionLabel(t, 'partnerType', row.type)],
['状态', commissionLabel(t, 'status', row.status)],
['伙伴名称', row.name],
['登录主体', `#${row.user_id}`],
['登录主体', formatUserReference('', row.user_id, t('未知用户'))],
['证件号码', row.identity_no],
['联系人', row.contact_name],
['联系电话', row.contact_phone],
@@ -150,7 +152,7 @@ export default function PartnerDetail({
{
title: t('客户'),
render: (_, item) =>
item.customer_name || `#${item.subject_id}`,
item.customer_name || formatIdReference(item.subject_id),
},
{
title: t('类型'),
+30 -32
View File
@@ -16,7 +16,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import React, {
useCallback,
useEffect,
@@ -494,9 +496,25 @@ export default function PartnerPortal({
},
{
title: t('操作'),
width: 230,
width: 175,
render: (_, row) => (
<div className='partner-portal-row-actions'>
<TableRowActions
items={[
{
key: 'export',
label: t('导出'),
disabled: exportingId !== null || mutationLoading,
onClick: () => exportStatement(row),
},
row.status === 'pending_confirmation' && {
key: 'reject',
label: t('驳回'),
danger: true,
disabled: mutationLoading,
onClick: () => open(row, 'reject'),
},
]}
>
<Button
type='link'
size='small'
@@ -506,36 +524,16 @@ export default function PartnerPortal({
{t('查看')}
</Button>
{row.status === 'pending_confirmation' && (
<>
<Button
type='link'
size='small'
disabled={mutationLoading}
onClick={() => open(row, 'confirm')}
>
{t('确认')}
</Button>
<Button
type='link'
size='small'
danger
disabled={mutationLoading}
onClick={() => open(row, 'reject')}
>
{t('驳回')}
</Button>
</>
<Button
type='link'
size='small'
disabled={mutationLoading}
onClick={() => open(row, 'confirm')}
>
{t('确认')}
</Button>
)}
<Button
type='link'
size='small'
disabled={exportingId !== null || mutationLoading}
loading={exportingId === row.id}
onClick={() => exportStatement(row)}
>
{t('导出')}
</Button>
</div>
</TableRowActions>
),
},
];
@@ -887,7 +885,7 @@ export default function PartnerPortal({
<Users size={17} />
</span>
<span>
{row.customer_name || `#${row.subject_id}`} ·{' '}
{row.customer_name || formatIdReference(row.subject_id)} ·{' '}
{t('客户保护期临近到期')}
<small>{date(protectionUntil(row))}</small>
</span>
+111 -154
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import React, {
useCallback,
@@ -56,7 +57,6 @@ import {
PencilLine,
ScrollText,
ShieldAlert,
ChevronDown,
} from 'lucide-react';
import Dashboard from './Dashboard';
import ListPanel from './ListPanel';
@@ -65,20 +65,12 @@ import PartnerDetail from './PartnerDetail';
import PartnerPortal from './PartnerPortal';
import { partnerScope, createPartnerTransport } from './partnerScope';
import { tierStatus } from './listFilters';
import {
Button,
DatePicker,
Dropdown,
Empty,
Select,
Spin,
Tag,
Typography,
} from 'antd';
import { Button, DatePicker, Empty, Select, Spin, Tag, Typography } from 'antd';
import dayjs from 'dayjs';
import { Plus, RefreshCw } from '../../components/common/icons/ActionIcons';
import { API } from '../../helpers';
import * as XLSX from 'xlsx';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import './styles.css';
import {
OperationsDialog,
@@ -194,7 +186,7 @@ function TierSummary({ items }) {
const key = `${item.subject_type}:${item.subject_id}:${item.customer_name}:${item.tier_source}:${item.tier_key}:${item.group_name || item.group || ''}:${item.rate_bps}`;
const value = groups.get(key) || {
id: key,
customer: item.customer_name || `#${item.subject_id || '—'}`,
customer: item.customer_name || formatIdReference(item.subject_id, '—'),
tier: item.tier_name || item.tier_key || '—',
group: item.group_name || item.group || '—',
rate_bps: item.rate_bps,
@@ -930,7 +922,9 @@ function AdminPage() {
dataIndex: 'user_id',
render: (value, row) => (
<EntityLabel
name={entityNames.users.get(Number(value)) || `#${value}`}
name={
entityNames.users.get(Number(value)) || formatIdReference(value)
}
reference={
row.organization_id
? entityNames.organizations.get(Number(row.organization_id))
@@ -990,7 +984,59 @@ function AdminPage() {
title: t('操作'),
width: 175,
render: (_, row) => (
<div className='commission-row-actions'>
<TableRowActions
items={[
{
key: 'partner-agreement',
label: t('登记或续签协议'),
onClick: () =>
setOperation({ kind: 'partner-agreement', row }),
},
...(['draft', 'suspended'].includes(row.status)
? [
{
key: 'partner-active',
label: t(row.status === 'draft' ? '启用' : '恢复生效'),
onClick: () =>
setOperation({
kind: 'partner-status',
row,
status: 'active',
}),
},
]
: []),
...(row.status === 'active'
? [
{
key: 'partner-suspend',
label: t('暂停合作'),
onClick: () =>
setOperation({
kind: 'partner-status',
row,
status: 'suspended',
}),
},
]
: []),
...(row.status !== 'terminated'
? [
{
key: 'partner-terminate',
label: t('终止合作'),
danger: true,
onClick: () =>
setOperation({
kind: 'partner-status',
row,
status: 'terminated',
}),
},
]
: []),
]}
>
<Button
onClick={() => setPartnerDetail(row)}
type='link'
@@ -1005,75 +1051,7 @@ function AdminPage() {
>
{t('编辑')}
</Button>
<Dropdown
trigger={['click']}
placement='bottomRight'
menu={{
items: [
{
key: 'partner-agreement',
label: t('登记或续签协议'),
onClick: () =>
setOperation({ kind: 'partner-agreement', row }),
},
...(['draft', 'suspended'].includes(row.status)
? [
{
key: 'partner-active',
label: t(
row.status === 'draft' ? '启用' : '恢复生效',
),
onClick: () =>
setOperation({
kind: 'partner-status',
row,
status: 'active',
}),
},
]
: []),
...(row.status === 'active'
? [
{
key: 'partner-suspend',
label: t('暂停合作'),
onClick: () =>
setOperation({
kind: 'partner-status',
row,
status: 'suspended',
}),
},
]
: []),
...(row.status !== 'terminated'
? [
{
key: 'partner-terminate',
label: t('终止合作'),
danger: true,
onClick: () =>
setOperation({
kind: 'partner-status',
row,
status: 'terminated',
}),
},
]
: []),
],
}}
>
<Button
type='link'
size='small'
icon={<ChevronDown size={14} aria-hidden />}
iconPlacement='end'
>
{t('更多')}
</Button>
</Dropdown>
</div>
</TableRowActions>
),
},
],
@@ -1173,84 +1151,62 @@ function AdminPage() {
},
{
title: t('操作'),
width: 300,
width: 155,
render: (_, row) => (
<div className='commission-row-actions'>
<TableRowActions
items={[
row.status === 'protected' && {
key: 'extend',
label: t('延期'),
onClick: () =>
setOperation({ kind: 'assignment-extend', row }),
},
[
'protected',
'protected_extended',
'pending_conversion',
].includes(row.status) && {
key: 'convert',
label: t('转正'),
onClick: () =>
setOperation({ kind: 'assignment-convert', row }),
},
row.status === 'pending_conversion' && {
key: 'reject',
label: t('驳回'),
onClick: () =>
setOperation({ kind: 'assignment-reject', row }),
},
row.status === 'formal' && {
key: 'transfer',
label: t('转移'),
onClick: () =>
setOperation({ kind: 'assignment-transfer', row }),
},
[
'formal',
'protected',
'protected_extended',
'pending_conversion',
].includes(row.status) && {
key: 'terminate',
label: t('终止'),
danger: true,
onClick: () =>
setOperation({ kind: 'assignment-terminate', row }),
},
]}
>
<Button
type='link'
size='small'
onClick={() =>
setOperation({ kind: 'assignment-history', row })
}
type='link'
size='small'
>
{t('历史')}
</Button>
{row.status === 'protected' && (
<Button
onClick={() =>
setOperation({ kind: 'assignment-extend', row })
}
type='link'
size='small'
>
{t('延期')}
</Button>
)}
{[
'protected',
'protected_extended',
'pending_conversion',
].includes(row.status) && (
<Button
onClick={() =>
setOperation({ kind: 'assignment-convert', row })
}
type='link'
size='small'
>
{t('转正')}
</Button>
)}
{row.status === 'pending_conversion' && (
<Button
onClick={() =>
setOperation({ kind: 'assignment-reject', row })
}
type='link'
size='small'
>
{t('驳回')}
</Button>
)}
{row.status === 'formal' && (
<Button
onClick={() =>
setOperation({ kind: 'assignment-transfer', row })
}
type='link'
size='small'
>
{t('转移')}
</Button>
)}
{[
'formal',
'protected',
'protected_extended',
'pending_conversion',
].includes(row.status) && (
<Button
onClick={() =>
setOperation({ kind: 'assignment-terminate', row })
}
type='link'
size='small'
danger
>
{t('终止')}
</Button>
)}
</div>
</TableRowActions>
),
},
],
@@ -1284,7 +1240,8 @@ function AdminPage() {
)
.map(
(id) =>
entityNames.channels.get(Number(id)) || `#${id}`,
entityNames.channels.get(Number(id)) ||
formatIdReference(id),
)
.join('、')
: row.source_type === 'model'
@@ -6,11 +6,40 @@
--igf-ink: var(--text-primary);
--igf-muted: var(--text-secondary);
--igf-line: var(--border-subtle);
--igf-surface: var(--surface-card);
--igf-accent: var(--ui-color-primary);
--igf-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
--igf-danger: var(--ui-color-danger);
--igf-warning: var(--ui-color-warning);
--igf-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
background: var(--igf-surface);
}
.igf-form-scroll {
flex: 1 1 auto;
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
padding: 16px;
}
/* Keep disabled generation actions grounded in the same surface and border token. */
.image-generation-form .igf-generate .ant-btn:disabled,
.image-generation-form .igf-generate .ant-btn[disabled] {
border: 1px solid var(--igf-line);
background: var(--igf-fill);
box-shadow: none;
color: var(--igf-muted);
cursor: not-allowed;
opacity: 1;
}
.image-generation-form .igf-generate .ant-btn:disabled:hover,
.image-generation-form .igf-generate .ant-btn[disabled]:hover {
border-color: var(--igf-line);
background: var(--igf-fill);
box-shadow: none;
color: var(--igf-muted);
}
.image-generation-form button:focus-visible,
@@ -152,6 +181,13 @@
gap: 6px;
}
.igf-generate-wrap {
flex: 0 0 auto;
padding: 16px 16px max(16px, env(safe-area-inset-bottom));
border-top: 1px solid var(--igf-line);
background: var(--igf-surface);
}
.igf-quote {
min-height: 18px;
color: var(--igf-muted);
@@ -140,7 +140,7 @@ const hasImageTaskType = (dataTransfer) =>
const Section = ({ title, extra, children, className = '' }) => (
<div
className={`mb-4 rounded-3xl border border-white/[0.45] bg-white/[0.28] p-3 backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.045] ${className}`}
className={`mb-4 rounded-3xl border border-[var(--igf-line)] bg-white/[0.28] p-3 backdrop-blur-xl dark:bg-white/[0.045] ${className}`}
>
{title || extra ? (
<div className='flex items-center justify-between gap-2 mb-2'>
@@ -383,12 +383,14 @@ const ImageGenerationForm = ({ creation }) => {
loading={submitting}
onClick={handleSubmit}
disabled={isButtonDisabled}
className='!rounded-2xl !shadow-lg !shadow-brand/20 hover:!shadow-xl hover:!shadow-brand/25 !transition-all'
className='!rounded-2xl !transition-colors'
style={{
background: isButtonDisabled
? 'var(--ui-color-fill-1)'
: 'linear-gradient(135deg, var(--brand-gradient-from) 0%, var(--brand-primary) 52%, var(--brand-gradient-to) 100%)',
border: 'none',
border: isButtonDisabled
? '1px solid var(--igf-line)'
: '1px solid transparent',
color: isButtonDisabled ? 'var(--ui-color-text-3)' : 'white',
height: '48px',
fontSize: '15px',
@@ -538,328 +540,337 @@ const ImageGenerationForm = ({ creation }) => {
return (
<div
className={`image-generation-form relative flex h-full flex-col overflow-y-auto overflow-x-hidden rounded-[28px] border border-white/[0.55] bg-white/[0.42] p-4 shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-2xl backdrop-saturate-150 transition-colors app-scrollbar dark:border-white/10 dark:bg-neutral-950/[0.40] dark:shadow-[0_24px_80px_rgba(0,0,0,0.35)]${dropActive ? ' is-drop-active' : ''}`}
className={`image-generation-form relative flex h-full min-h-0 flex-col overflow-hidden rounded-[28px] border border-[var(--igf-line)] bg-white/[0.42] shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-2xl backdrop-saturate-150 transition-colors dark:bg-neutral-950/[0.40] dark:shadow-[0_24px_80px_rgba(0,0,0,0.35)]${dropActive ? ' is-drop-active' : ''}`}
onDragEnter={handleDragEnter}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
>
{/* 标题 */}
<div className='mb-5 rounded-3xl border border-white/60 bg-white/[0.50] p-4 shadow-sm backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.05]'>
<div className='flex items-center justify-between gap-2'>
<div className='flex-1 min-w-0'>
<div className='mb-2 inline-flex items-center gap-2 rounded-full border border-brand/25 bg-brand/10 px-2.5 py-1 text-[11px] font-medium text-brand-deep dark:border-brand/25 dark:bg-brand/15 dark:text-brand-from'>
<Sparkles size={12} />
{t('AI 图片创作')}
<div className='igf-form-scroll app-scrollbar'>
{/* 标题 */}
<div className='mb-5 rounded-3xl border border-white/60 bg-white/[0.50] p-4 shadow-sm backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.05]'>
<div className='flex items-center justify-between gap-2'>
<div className='flex-1 min-w-0'>
<div className='mb-2 inline-flex items-center gap-2 rounded-full border border-brand/25 bg-brand/10 px-2.5 py-1 text-[11px] font-medium text-brand-deep dark:border-brand/25 dark:bg-brand/15 dark:text-brand-from'>
<Sparkles size={12} />
{t('AI 图片创作')}
</div>
<Title
heading={4}
style={{ margin: 0 }}
className='text-gray-900 dark:text-white'
>
{t('图片生成')}
</Title>
<Text
type='secondary'
size='small'
className='text-gray-500 dark:text-gray-400 mt-1 block truncate'
>
{formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')}
</Text>
</div>
<Title
heading={4}
style={{ margin: 0 }}
className='text-gray-900 dark:text-white'
>
{t('图片生成')}
</Title>
<div className='flex items-center gap-1'>
{!formBodyHidden && (
<Button
icon={<ActionRotateCcw size={12} />}
size='small'
theme='borderless'
onClick={handleReset}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
>
{t('重置')}
</Button>
)}
{isMobile && (
<Button
icon={
mobileCollapsed ? (
<ActionChevronDown size={14} />
) : (
<ActionChevronUp size={14} />
)
}
size='small'
theme='borderless'
onClick={() => setMobileCollapsed(!mobileCollapsed)}
className='!text-gray-500'
>
{mobileCollapsed ? t('展开') : t('收起')}
</Button>
)}
</div>
</div>
</div>
{/* 移动端折叠时只显示生成按钮 + 简略 */}
{formBodyHidden && (
<div className='mt-2'>
{renderGenerateArea()}
<Text
type='secondary'
type='tertiary'
size='small'
className='text-gray-500 dark:text-gray-400 mt-1 block truncate'
className='block mt-2 text-center'
>
{formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')}
{prompt
? prompt.length > 50
? prompt.slice(0, 50) + '...'
: prompt
: t('点击展开编辑参数')}
</Text>
</div>
<div className='flex items-center gap-1'>
{!formBodyHidden && (
<Button
icon={<ActionRotateCcw size={12} />}
size='small'
theme='borderless'
onClick={handleReset}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
>
{t('重置')}
</Button>
)}
{isMobile && (
<Button
icon={
mobileCollapsed ? (
<ActionChevronDown size={14} />
) : (
<ActionChevronUp size={14} />
)
}
size='small'
theme='borderless'
onClick={() => setMobileCollapsed(!mobileCollapsed)}
className='!text-gray-500'
>
{mobileCollapsed ? t('展开') : t('收起')}
</Button>
)}
</div>
</div>
</div>
)}
{/* 移动端折叠时只显示生成按钮 + 简略 */}
{formBodyHidden && (
<div className='mt-2'>
{renderGenerateArea()}
<Text type='tertiary' size='small' className='block mt-2 text-center'>
{prompt
? prompt.length > 50
? prompt.slice(0, 50) + '...'
: prompt
: t('点击展开编辑参数')}
</Text>
</div>
)}
{!formBodyHidden && (
<>
{/* 模型选择 */}
<Section title={t('选择模型')}>{renderModelSection()}</Section>
{!formBodyHidden && (
<>
{/* 模型选择 */}
<Section title={t('选择模型')}>{renderModelSection()}</Section>
{/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? (
<Section title={t('生成方式')}>
<OptionGroup
options={modeOptions.map((o) => o.mode)}
value={formData.mode}
onChange={setMode}
ariaLabel={t('生成方式')}
optionDisabledReasons={Object.fromEntries(
modeOptions
.filter((o) => o.disabled)
.map((o) => [o.mode, t(o.reason || '当前不可用')]),
)}
renderOption={(mode) => {
const Icon = MODE_ICONS[mode] || Type;
return (
<span className='igf-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</Section>
) : null}
{/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? (
<Section title={t('生成方式')}>
<OptionGroup
options={modeOptions.map((o) => o.mode)}
value={formData.mode}
onChange={setMode}
ariaLabel={t('生成方式')}
optionDisabledReasons={Object.fromEntries(
modeOptions
.filter((o) => o.disabled)
.map((o) => [o.mode, t(o.reason || '当前不可用')]),
)}
renderOption={(mode) => {
const Icon = MODE_ICONS[mode] || Type;
return (
<span className='igf-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</Section>
) : null}
{/* 提示词 + 模板 + 历史 */}
<Section
title={t('提示词')}
extra={
<div className='flex items-center gap-2'>
{/* AI 优化提示词 —— 按钮始终可点击,handler 内判断并 Toast 解释原因 */}
<button
type='button'
onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')}
className={[
'app-action-button',
[
'flex items-center gap-1 text-[10px] transition-colors',
optimizing
? 'text-brand-from'
: 'text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={
textModels?.length
? t('AI 优化提示词 (使用 {{m}})', {
m: textModels[0].model_name,
})
: t('AI 优化提示词')
}
>
<Sparkles
size={10}
className={optimizing ? 'animate-pulse' : ''}
/>
<span>{optimizing ? t('优化中...') : t('AI 优化')}</span>
</button>
{promptHistory.length > 0 && (
<Dropdown
trigger='click'
position='bottomRight'
render={
<Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((p, idx) => (
<Dropdown.Item key={idx} onClick={() => setPrompt(p)}>
<div
style={{
maxWidth: 320,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
title={p}
>
{p}
</div>
</Dropdown.Item>
))}
</Dropdown.Menu>
{/* 提示词 + 模板 + 历史 */}
<Section
title={t('提示词')}
extra={
<div className='flex items-center gap-2'>
{/* AI 优化提示词 —— 按钮始终可点击,handler 内判断并 Toast 解释原因 */}
<button
type='button'
onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')}
className={[
'app-action-button',
[
'flex items-center gap-1 text-[10px] transition-colors',
optimizing
? 'text-brand-from'
: 'text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={
textModels?.length
? t('AI 优化提示词 (使用 {{m}})', {
m: textModels[0].model_name,
})
: t('AI 优化提示词')
}
>
<button
type='button'
className='app-action-button flex items-center gap-1 text-[10px] text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
<Sparkles
size={10}
className={optimizing ? 'animate-pulse' : ''}
/>
<span>{optimizing ? t('优化中...') : t('AI 优化')}</span>
</button>
{promptHistory.length > 0 && (
<Dropdown
trigger='click'
position='bottomRight'
render={
<Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((p, idx) => (
<Dropdown.Item
key={idx}
onClick={() => setPrompt(p)}
>
<div
style={{
maxWidth: 320,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
title={p}
>
{p}
</div>
</Dropdown.Item>
))}
</Dropdown.Menu>
}
>
<ActionHistory size={10} />
<span>{t('历史')}</span>
</button>
</Dropdown>
)}
<span className='flex items-center gap-1 text-[10px] text-gray-400'>
{IS_MAC ? (
<Command size={10} />
) : (
<span>{I18N_TECHNICAL_TEXT.CTRL}</span>
<button
type='button'
className='app-action-button flex items-center gap-1 text-[10px] text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
>
<ActionHistory size={10} />
<span>{t('历史')}</span>
</button>
</Dropdown>
)}
<span>+</span>
<span>{I18N_TECHNICAL_TEXT.ENTER}</span>
<span>{t('生成')}</span>
</span>
</div>
}
>
<TextArea
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
className='[&_.ant-input-textarea]:!rounded-2xl [&_.ant-input-textarea]:!border-white/[0.55] [&_.ant-input-textarea]:!bg-white/[0.55] [&_.ant-input-textarea]:!shadow-inner dark:[&_.ant-input-textarea]:!border-white/10 dark:[&_.ant-input-textarea]:!bg-white/[0.06] [&_.ant-input-textarea:hover]:!border-brand/30 [&_.ant-input-textarea:focus]:!border-brand'
/>
<div className='flex flex-wrap items-center gap-1.5 mt-2'>
<div className='flex items-center gap-1 text-[10px] text-gray-400 mr-1'>
<Sparkles size={10} />
<span>{t('快速模板')}</span>
</div>
{PROMPT_TEMPLATES.map((tpl) => (
<Tag
key={tpl.label}
size='small'
color='grey'
onClick={() => handleApplyTemplate(tpl)}
className='!cursor-pointer !rounded-full !border-white/50 !bg-white/[0.45] !backdrop-blur hover:!bg-brand/10 dark:!border-white/10 dark:!bg-white/[0.06] dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-colors'
>
{t(tpl.label)}
</Tag>
))}
</div>
</Section>
{/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */}
{selectedModel && imageSlots.length > 0 ? (
<Section
title={t('参考图片')}
extra={
<Text type='tertiary' className='!text-[10px]'>
{t('可从右侧历史拖拽图片到这里')}
</Text>
<span className='flex items-center gap-1 text-[10px] text-gray-400'>
{IS_MAC ? (
<Command size={10} />
) : (
<span>{I18N_TECHNICAL_TEXT.CTRL}</span>
)}
<span>+</span>
<span>{I18N_TECHNICAL_TEXT.ENTER}</span>
<span>{t('生成')}</span>
</span>
</div>
}
>
<div className='igf-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
const value = slot
? {
previewUrl: slot.previewUrl,
status: entry.active
? slot.status || 'ready'
: 'unused',
error: slot.error,
}
: null;
return (
<ImageSlot
key={`ref-${entry.index}-${slot?.id || 'empty'}`}
label={slotLabel(entry)}
value={value}
onPick={(file) => pickImage(entry.index, file)}
onRemove={() => removeImage(entry.index)}
onRetry={() => retryImage(entry.index, slot)}
/>
);
})}
</div>
{hasUnusedImage ? (
<div className='igf-muted igf-note' role='note'>
{t('置灰的图片当前不会提交,切回支持的模型或模式后自动恢复')}
<TextArea
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
className='[&_.ant-input-textarea]:!rounded-2xl [&_.ant-input-textarea]:!border-white/[0.55] [&_.ant-input-textarea]:!bg-white/[0.55] [&_.ant-input-textarea]:!shadow-inner dark:[&_.ant-input-textarea]:!border-white/10 dark:[&_.ant-input-textarea]:!bg-white/[0.06] [&_.ant-input-textarea:hover]:!border-brand/30 [&_.ant-input-textarea:focus]:!border-brand'
/>
<div className='flex flex-wrap items-center gap-1.5 mt-2'>
<div className='flex items-center gap-1 text-[10px] text-gray-400 mr-1'>
<Sparkles size={10} />
<span>{t('快速模板')}</span>
</div>
) : null}
{PROMPT_TEMPLATES.map((tpl) => (
<Tag
key={tpl.label}
size='small'
color='grey'
onClick={() => handleApplyTemplate(tpl)}
className='!cursor-pointer !rounded-full !border-white/50 !bg-white/[0.45] !backdrop-blur hover:!bg-brand/10 dark:!border-white/10 dark:!bg-white/[0.06] dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-colors'
>
{t(tpl.label)}
</Tag>
))}
</div>
</Section>
) : null}
{/* 尺寸 + 常用参数(画质 / 数量等) */}
{selectedModel && (sizeParam || dockParams.length > 0) ? (
<Section title={sizeParam ? t('尺寸') : t('生成参数')}>
{sizeParam ? (
<ImageSizePicker
param={sizeParam}
value={formData.params?.size}
onChange={(v) => updateParam('size', v)}
/>
) : null}
{dockParams.length > 0 ? (
<ParamRenderer
className={sizeParam ? 'igf-dock-params' : ''}
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='dock'
constraints={constraints}
/>
) : null}
</Section>
) : null}
{/* 高级选项 */}
{selectedModel && advancedParams.length > 0 ? (
<Section>
<button
type='button'
onClick={() => setShowAdvanced(!showAdvanced)}
aria-expanded={showAdvanced}
className='app-action-button flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
{/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */}
{selectedModel && imageSlots.length > 0 ? (
<Section
title={t('参考图片')}
extra={
<Text type='tertiary' className='!text-[10px]'>
{t('可从右侧历史拖拽图片到这里')}
</Text>
}
>
<ActionSettings size={12} />
<span>{t('高级选项')}</span>
{showAdvanced ? (
<ActionChevronUp size={12} />
) : (
<ActionChevronDown size={12} />
)}
</button>
<Collapsible isOpen={showAdvanced} keepDOM>
<div className='pt-3'>
<div className='igf-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
const value = slot
? {
previewUrl: slot.previewUrl,
status: entry.active
? slot.status || 'ready'
: 'unused',
error: slot.error,
}
: null;
return (
<ImageSlot
key={`ref-${entry.index}-${slot?.id || 'empty'}`}
label={slotLabel(entry)}
value={value}
onPick={(file) => pickImage(entry.index, file)}
onRemove={() => removeImage(entry.index)}
onRetry={() => retryImage(entry.index, slot)}
/>
);
})}
</div>
{hasUnusedImage ? (
<div className='igf-muted igf-note' role='note'>
{t(
'置灰的图片当前不会提交,切回支持的模型或模式后自动恢复',
)}
</div>
) : null}
</Section>
) : null}
{/* 尺寸 + 常用参数(画质 / 数量等) */}
{selectedModel && (sizeParam || dockParams.length > 0) ? (
<Section title={sizeParam ? t('尺寸') : t('生成参数')}>
{sizeParam ? (
<ImageSizePicker
param={sizeParam}
value={formData.params?.size}
onChange={(v) => updateParam('size', v)}
/>
) : null}
{dockParams.length > 0 ? (
<ParamRenderer
className={sizeParam ? 'igf-dock-params' : ''}
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='advanced'
placement='dock'
constraints={constraints}
/>
</div>
</Collapsible>
</Section>
) : null}
) : null}
</Section>
) : null}
{/* 生成按钮 + 估价 */}
<div className='sticky bottom-0 -mx-4 mt-auto bg-transparent px-4 pt-4 pb-1'>
{renderGenerateArea()}
</div>
</>
{/* 高级选项 */}
{selectedModel && advancedParams.length > 0 ? (
<Section>
<button
type='button'
onClick={() => setShowAdvanced(!showAdvanced)}
aria-expanded={showAdvanced}
className='app-action-button flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
>
<ActionSettings size={12} />
<span>{t('高级选项')}</span>
{showAdvanced ? (
<ActionChevronUp size={12} />
) : (
<ActionChevronDown size={12} />
)}
</button>
<Collapsible isOpen={showAdvanced} keepDOM>
<div className='pt-3'>
<ParamRenderer
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='advanced'
constraints={constraints}
/>
</div>
</Collapsible>
</Section>
) : null}
</>
)}
</div>
{!formBodyHidden && (
<div className='igf-generate-wrap'>{renderGenerateArea()}</div>
)}
</div>
);
@@ -203,6 +203,22 @@
overflow: hidden;
}
/* Override antd Collapse defaults so the advanced panel shares the input cards' line. */
.vip-advanced .ant-collapse {
border: 0;
border-radius: inherit;
background: transparent;
}
.vip-advanced .ant-collapse-item {
border-bottom: 0;
}
.vip-advanced .ant-collapse-header:focus-visible {
outline: 2px solid var(--vip-accent);
outline-offset: -2px;
}
.vip-advanced .ant-collapse-header {
margin: 0;
padding: 12px 16px;
@@ -24,6 +24,7 @@ import {
Trash2 as ActionTrash2,
AlertCircle as ActionAlertCircle,
} from '@/components/common/icons/ActionIcons';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import React, { useState, useEffect } from 'react';
import {
Table,
@@ -239,69 +240,63 @@ const VideoTaskQueue = ({
{
title: t('操作'),
dataIndex: 'operate',
width: !isCompact ? 220 : 180,
width: 168,
fixed: 'right',
render: (text, record) => {
const normalizedStatus = normalizeVideoTaskStatus(record.status);
return (
<Space>
{/* 播放和下载按钮:仅根据状态显示,视频URL在点击时才获取 */}
<TableRowActions
items={[
normalizedStatus === 'success' && {
key: 'download',
label: t('下载'),
onClick: () => onDownload(record),
icon: <ActionDownload size={14} />,
},
(normalizedStatus === 'success' ||
normalizedStatus === 'failure') &&
canRegenerateVideoTask(record) && {
key: 'regenerate',
label: t('再生成'),
onClick: () => onRegenerate && onRegenerate(record),
icon: <ActionRefreshCw size={14} />,
},
{
key: 'delete',
label: t('删除'),
onClick: () => {
Modal.warning({
title: t('确定删除此任务?'),
content: t('删除后将无法恢复'),
icon: (
<ActionAlertCircle
size={24}
style={{ color: '#f59e0b' }}
/>
),
okText: t('确定'),
cancelText: t('取消'),
onOk: () => onDelete(record.task_id),
centered: true,
okButtonProps: { type: 'danger' },
});
},
icon: <ActionTrash2 size={14} />,
danger: true,
},
]}
>
{normalizedStatus === 'success' && (
<>
<Button
size='small'
type='tertiary'
icon={<ActionPlay size={14} />}
onClick={() => onPlay && onPlay(record)}
>
{!isCompact ? t('播放') : ''}
</Button>
<Button
size='small'
type='tertiary'
icon={<ActionDownload size={14} />}
onClick={() => onDownload(record)}
>
{!isCompact ? t('下载') : ''}
</Button>
</>
<Button
size='small'
type='tertiary'
icon={<ActionPlay size={14} />}
onClick={() => onPlay && onPlay(record)}
>
{t('播放')}
</Button>
)}
{/* 再生成按钮 - 对所有已完成或失败的任务显示 */}
{(normalizedStatus === 'success' ||
normalizedStatus === 'failure') &&
canRegenerateVideoTask(record) && (
<Button
size='small'
type='primary'
icon={<ActionRefreshCw size={14} />}
onClick={() => onRegenerate && onRegenerate(record)}
>
{!isCompact ? t('再生成') : ''}
</Button>
)}
<Button
size='small'
type='danger'
icon={<ActionTrash2 size={14} />}
onClick={() => {
Modal.warning({
title: t('确定删除此任务?'),
content: t('删除后将无法恢复'),
icon: (
<ActionAlertCircle size={24} style={{ color: '#f59e0b' }} />
),
okText: t('确定'),
cancelText: t('取消'),
onOk: () => onDelete(record.task_id),
centered: true,
okButtonProps: { type: 'danger' },
});
}}
>
{!isCompact ? t('删除') : ''}
</Button>
</Space>
</TableRowActions>
);
},
},
+4 -3
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import {
@@ -2340,8 +2341,8 @@ const ExpertPlatform = () => {
className={`expert-diagnose-model ${row.success ? 'is-ok' : 'is-blocked'}`}
>
<strong>
{row.channel_name || `#${row.channel_id}`}
<em>{`#${row.channel_id}`}</em>
{row.channel_name || formatIdReference(row.channel_id)}
<em>{formatIdReference(row.channel_id)}</em>
</strong>
<small>
{row.success
@@ -2392,7 +2393,7 @@ const ExpertPlatform = () => {
}
optionList={channels.map((channel) => ({
value: channel.id,
label: `#${channel.id} · ${channel.name}`,
label: `${formatIdReference(channel.id)} · ${channel.name}`,
}))}
placeholder={t('选择已启用渠道')}
/>
+2 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatPercent } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import React, { useState, useEffect } from 'react';
@@ -455,7 +456,7 @@ const ChannelMonitor = () => {
: 'var(--ui-color-danger)',
}}
>
{channel.uptime.toFixed(2)}%
{formatPercent(channel.uptime, 2)}
</span>
</div>
<div
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatPercent } from '../../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
import React from 'react';
@@ -220,7 +221,10 @@ const ChannelMonitorView = ({ channelStatus, onRefresh }) => {
>
{renderSparkline(channel.uptime || 0)}
<Text type='success' strong>
{((channel.uptime || 0) * 100).toFixed(1)}%
{formatPercent(
Number(channel.uptime || 0) * 100,
1,
)}
</Text>
</div>
</div>
+8 -18
View File
@@ -34,11 +34,7 @@ import {
} from '@/components/ui';
import { API } from '../../helpers/api';
import { showError, getLogo, getSystemName } from '../../helpers';
import {
setUserData,
savePostLoginRedirect,
consumePostLoginRedirect,
} from '../../helpers/data';
import { setUserData } from '../../helpers/data';
import { updateAPI } from '../../helpers/api';
import { finishLogin } from '../../helpers/loginFlow';
import { UserContext } from '../../context/User';
@@ -219,14 +215,10 @@ const OrgLogin = () => {
}
};
// 与 /login 对齐的入口参数处理:?redirect= 写回本地存储(新标签页打开也能回跳),
// ?expired=true 提示会话过期后从 URL 清除(避免刷新重复提示)。
const expiryShown = useRef(false);
useEffect(() => {
const redirect = searchParams.get('redirect');
if (redirect) {
savePostLoginRedirect(redirect);
}
if (searchParams.get('expired')) {
if (searchParams.get('expired') && !expiryShown.current) {
expiryShown.current = true;
showError(t('未登录或登录已过期,请重新登录'));
const nextParams = new URLSearchParams(searchParams);
nextParams.delete('expired');
@@ -283,9 +275,8 @@ const OrgLogin = () => {
userDispatch,
navigate,
t,
// 消费被保护页跳来时保存的回跳地址(尊重深链意图,同时避免残留值
// 影响之后的个人登录);无保存值则进企业工作台
redirectOverride: consumePostLoginRedirect('/org/workbench'),
enterprise: true,
redirect: searchParams.get('redirect'),
});
}
};
@@ -416,9 +407,8 @@ const OrgLogin = () => {
userDispatch,
navigate,
t,
successMessage: '',
// 首登改密路径同样消费保存的回跳地址,默认进企业工作台
redirectOverride: consumePostLoginRedirect('/org/workbench'),
enterprise: true,
redirect: searchParams.get('redirect'),
});
} else {
showError(res.data.message);
+2 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../helpers/safeDisplay';
import {
Search as ActionSearch,
RefreshCw as ActionRefreshCw,
@@ -306,7 +307,7 @@ const OrgAudit = ({ orgId }) => {
title: t('操作者'),
dataIndex: 'operator_name',
width: 130,
render: (name, record) => name || `User#${record.operator_id}`,
render: (name, record) => formatUserReference(name, record.operator_id),
},
{
title: t('操作类型'),
+17 -8
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
Plus as ActionPlus,
@@ -106,10 +107,14 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
if (!orgId) return;
setLoading(true);
try {
const options = {
headers: getOrgHeaders(orgId),
requestGroup: new AbortController(),
};
const [b, d, p] = await Promise.all([
API.get('/api/org/budget', { headers: getOrgHeaders(orgId) }),
API.get('/api/org/dept', { headers: getOrgHeaders(orgId) }),
API.get('/api/org/project', { headers: getOrgHeaders(orgId) }),
API.get('/api/org/budget', options),
API.get('/api/org/dept', options),
API.get('/api/org/project', options),
]);
if (b.data.success) {
// 新后端返回 {items, enforcement_enabled, engine_enabled};兼容旧后端直接返回数组。
@@ -122,7 +127,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
if (d.data.success) setDepts(d.data.data || []);
if (p.data.success) setProjects(p.data.data || []);
} catch (err) {
showError(err.message);
if (!err?.isAxiosError) showError(err);
} finally {
setLoading(false);
}
@@ -139,7 +144,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
const st = r.subject_type;
if (r.subject_exists !== undefined) {
return {
name: r.subject_name || `#${r.subject_id}`,
name: r.subject_name || formatIdReference(r.subject_id),
exists: !!r.subject_exists,
disabled: r.subject_status === 2,
};
@@ -147,7 +152,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
if (st === 'department') {
const d = depts.find((x) => x.id === r.subject_id);
return {
name: d?.name || `#${r.subject_id}`,
name: d?.name || formatIdReference(r.subject_id),
exists: !!d,
disabled: d?.status === 2,
};
@@ -155,13 +160,17 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
if (st === 'project') {
const p = projects.find((x) => x.id === r.subject_id);
return {
name: p?.name || `#${r.subject_id}`,
name: p?.name || formatIdReference(r.subject_id),
exists: !!p,
disabled: p?.status === 2,
};
}
// 旧后端下成员/密钥无从解析,按存在处理,避免误标「已删除」
return { name: `#${r.subject_id}`, exists: true, disabled: false };
return {
name: formatIdReference(r.subject_id),
exists: true,
disabled: false,
};
},
[depts, projects],
);
+4 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
Plus as ActionPlus,
@@ -186,7 +187,9 @@ const OrgDepartments = ({ orgId }) => {
const deptName = useCallback(
(id) =>
id ? list.find((d) => d.id === id)?.name || `#${id}` : t('顶级部门'),
id
? list.find((d) => d.id === id)?.name || formatIdReference(id)
: t('顶级部门'),
[list, t],
);
+11 -5
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatUserReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
Check as ActionCheck,
@@ -213,7 +215,8 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
const nameMap = useMemo(() => {
const m = {};
members.forEach((x) => {
m[x.id] = x.remark || x.display_name || x.username || `#${x.id}`;
m[x.id] =
x.remark || x.display_name || x.username || formatIdReference(x.id);
});
return m;
}, [members]);
@@ -273,7 +276,7 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
{
title: t('成员'),
dataIndex: 'display_name',
render: (v, r) => r.remark || v || r.username || `#${r.id}`,
render: (v, r) => r.remark || v || r.username || formatIdReference(r.id),
},
{
title: t('已用额度'),
@@ -299,7 +302,8 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
{
title: t('成员'),
dataIndex: 'display_name',
render: (v, r) => v || r.username || `#${r.user_id}`,
render: (v, r) =>
formatUserReference(v || r.username, r.user_id, t('未知用户')),
},
{
title: t('消耗'),
@@ -437,8 +441,10 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
>
<div className='min-w-0'>
<Text>
{nameMap[r.requester_id] || `#${r.requester_id}`} ·{' '}
{t('提额')} {renderQuota(parseDelta(r.payload), 2)}
{nameMap[r.requester_id] ||
formatIdReference(r.requester_id)}{' '}
· {t('提额')}{' '}
{renderQuota(parseDelta(r.payload), 2)}
</Text>
<div>
<Text type='tertiary' size='small'>
+16 -6
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatPercent } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons';
@@ -414,13 +416,15 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
title: t('技能'),
dataIndex: 'name',
render: (name, record) =>
name || record.canonical_id || `#${record.skill_id}`,
name ||
record.canonical_id ||
formatIdReference(record.skill_id),
},
{ title: t('调用次数'), dataIndex: 'request_count' },
{
title: t('占比'),
dataIndex: 'share_percent',
render: (share) => `${(share || 0).toFixed(1)}%`,
render: (share) => formatPercent(share, 1),
},
{
title: t('提示词 token'),
@@ -545,13 +549,16 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
<span>
{t('首次交付通过率')}:{' '}
{row.data_sufficient
? `${(row.first_delivery_pass_rate * 100).toFixed(1)}%`
? formatPercent(
Number(row.first_delivery_pass_rate) * 100,
1,
)
: t('数据不足')}
</span>
<span>
{t('退回率')}:{' '}
{row.data_sufficient
? `${(row.return_rate * 100).toFixed(1)}%`
? formatPercent(Number(row.return_rate) * 100, 1)
: t('数据不足')}
</span>
<span>
@@ -574,14 +581,17 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
title: t('首次交付通过率'),
render: (_, row) =>
row.data_sufficient
? `${(row.first_delivery_pass_rate * 100).toFixed(1)}%`
? formatPercent(
Number(row.first_delivery_pass_rate) * 100,
1,
)
: t('数据不足'),
},
{
title: t('退回率'),
render: (_, row) =>
row.data_sufficient
? `${(row.return_rate * 100).toFixed(1)}%`
? formatPercent(Number(row.return_rate) * 100, 1)
: t('数据不足'),
},
{
+6 -2
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatPercent } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import {
@@ -1887,7 +1889,7 @@ const OrgKnowledge = ({ orgId, canAuditContent = false }) => {
label:
member.display_name ||
member.username ||
`#${member.id}`,
formatIdReference(member.id),
}))}
/>
<Select
@@ -1959,7 +1961,9 @@ const OrgKnowledge = ({ orgId, canAuditContent = false }) => {
<div className='knowledge-hit-body'>
<div className='knowledge-hit-title'>
<strong>{hit.source_label}</strong>
<span>{(hit.score * 100).toFixed(1)}%</span>
<span>
{formatPercent(Number(hit.score) * 100, 1)}
</span>
</div>
<div className='knowledge-hit-meta'>
{hit.base_name && <span>{hit.base_name}</span>}
+10 -3
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import {
@@ -486,7 +487,10 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
const key = log.user_id ?? 'unknown';
if (!groups.has(key)) {
groups.set(key, {
name: log.display_name || log.username || `User#${log.user_id}`,
name: formatUserReference(
log.display_name || log.username,
log.user_id,
),
rows: [],
});
}
@@ -595,7 +599,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
members.forEach((m) => {
opts.push({
value: m.user_id,
label: m.display_name || m.username || `User#${m.user_id}`,
label: formatUserReference(m.display_name || m.username, m.user_id),
});
});
return opts;
@@ -616,7 +620,10 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
: t('仅本人');
if (canViewTeamUsage && af.userId) {
const m = members.find((x) => String(x.user_id) === String(af.userId));
member = m ? m.display_name || m.username : `User#${af.userId}`;
member = formatUserReference(
m?.display_name || m?.username,
m?.user_id ?? af.userId,
);
}
const time =
af.startTimestamp && af.endTimestamp
+60 -51
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatUserReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
UserPlus as ActionUserPlus,
@@ -30,7 +32,7 @@ import {
Form,
Toast,
Tag,
Popconfirm,
Modal,
Banner,
Typography,
Tooltip,
@@ -40,7 +42,8 @@ import { API } from '../../helpers/api';
import { showError, collectPagedItems } from '../../helpers';
import OrgPageHeader from './components/OrgPageHeader';
import OrgPanel from './components/OrgPanel';
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { OrgListCard } from './components/OrgListCard';
import OrgModal from './components/OrgModal';
import DeptTreeSelect from './components/DeptTreeSelect';
import {
@@ -327,7 +330,13 @@ const OrgMemberAccounts = ({
title: t('成员'),
render: (_, r) => (
<div className='flex items-center gap-2'>
<span>{r.display_name || r.username || `#${r.user_id}`}</span>
<span>
{formatUserReference(
r.display_name || r.username,
r.user_id,
t('未知用户'),
)}
</span>
{r.created_by_org_id !== r.organization_id && (
<Tooltip content={t('个人平台账号(非本企业托管)')}>
<Tag size='small' color='blue'>
@@ -351,8 +360,8 @@ const OrgMemberAccounts = ({
width: 120,
render: (v) =>
v ? (
<Tooltip content={deptFullNameMap[v] || `#${v}`}>
<span>{deptNameMap[v] || `#${v}`}</span>
<Tooltip content={deptFullNameMap[v] || formatIdReference(v)}>
<span>{deptNameMap[v] || formatIdReference(v)}</span>
</Tooltip>
) : (
<span className='text-gray-400'>{t('未分配')}</span>
@@ -382,7 +391,7 @@ const OrgMemberAccounts = ({
},
{
title: t('操作'),
width: 260,
width: 110,
render: (_, r) => {
const managed = r.created_by_org_id === r.organization_id;
// 与后端 model.ResetManagedMemberPassword 的分级拦截保持一致
@@ -396,53 +405,53 @@ const OrgMemberAccounts = ({
}
const canReset = !resetBlockedReason;
return (
<OrgRowActions>
{deptEnabled && (
<Button
type='link'
onClick={() => {
<TableRowActions
items={[
deptEnabled && {
key: 'department',
label: t('分配部门'),
onClick: () => {
setDeptAssignFor(r);
setDeptAssignVal(r.department_id || 0);
}}
>
{t('分配部门')}
</Button>
)}
{canReset ? (
<Popconfirm
title={t('重置该账号密码?')}
content={
managed
? t('将生成一次性临时密码,并要求首次登录改密')
: t(
'该成员为个人平台账号,重置后其平台登录密码同步失效,请将临时密码安全告知本人',
)
}
onConfirm={() => resetPassword(r)}
>
<Button type='link'>{t('重置密码')}</Button>
</Popconfirm>
) : (
<Tooltip content={resetBlockedReason}>
<Button type='link' disabled>
{t('重置密码')}
</Button>
</Tooltip>
)}
{r.status === 1 && r.role !== 'owner' && (
<Popconfirm
title={t('确认离职回收该成员?')}
content={t(
'将禁用其企业成员身份与全部企业 Token,保留历史,不删除用户',
)}
onConfirm={() => offboard(r.id)}
>
<Button type='link' danger>
{t('离职回收')}
</Button>
</Popconfirm>
)}
</OrgRowActions>
},
},
{
key: 'reset-password',
label: t('重置密码'),
disabled: !canReset,
title: resetBlockedReason || undefined,
onClick: () =>
Modal.confirm({
title: t('重置该账号密码?'),
content: managed
? t('将生成一次性临时密码,并要求首次登录改密')
: t(
'该成员为个人平台账号,重置后其平台登录密码同步失效,请将临时密码安全告知本人',
),
okText: t('确认'),
cancelText: t('取消'),
onOk: () => resetPassword(r),
}),
},
r.status === 1 &&
r.role !== 'owner' && {
key: 'offboard',
label: t('离职回收'),
danger: true,
onClick: () =>
Modal.confirm({
title: t('确认离职回收该成员?'),
content: t(
'将禁用其企业成员身份与全部企业 Token,保留历史,不删除用户',
),
okText: t('确认'),
cancelText: t('取消'),
okButtonProps: { danger: true },
onOk: () => offboard(r.id),
}),
},
]}
/>
);
},
},
+54 -59
View File
@@ -30,7 +30,7 @@ import {
Input,
Select,
Tag,
Popconfirm,
Modal,
Toast,
Tooltip,
Switch,
@@ -42,7 +42,8 @@ import QuotaInput from '../../components/common/ui/QuotaInput';
import OrgPageHeader from './components/OrgPageHeader';
import OrgPanel from './components/OrgPanel';
import { Alert as AntAlert, Tabs as AntTabs } from 'antd';
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { OrgListCard } from './components/OrgListCard';
import OrgModal from './components/OrgModal';
import OrgMemberAccounts from './OrgMemberAccounts';
@@ -572,7 +573,7 @@ const OrgMembers = ({
if (canWrite) {
memberColumns.push({
title: t('操作'),
width: 260,
width: 110,
fixed: 'right',
render: (_, record) => {
if (record.role === 'owner') {
@@ -580,11 +581,13 @@ const OrgMembers = ({
}
const isSelf = Number(record.user_id) === currentUserId;
return (
<OrgRowActions>
<Tooltip content={t('设置该成员的个人额度上限')}>
<Button
type='link'
onClick={() => {
<TableRowActions
items={[
{
key: 'quota',
label: t('配额'),
title: t('设置该成员的个人额度上限'),
onClick: () => {
setQuotaMemberId(record.id);
setQuotaMemberName(
record.display_name || record.username || '',
@@ -592,15 +595,13 @@ const OrgMembers = ({
setQuotaLimit(record.quota_limit || 0);
setQuotaPeriod(record.quota_period || 'none');
setQuotaModalVisible(true);
}}
>
{t('配额')}
</Button>
</Tooltip>
<Tooltip content={t('设置该成员可用的模型范围')}>
<Button
type='link'
onClick={async () => {
},
},
{
key: 'models',
label: t('模型'),
title: t('设置该成员可用的模型范围'),
onClick: async () => {
setModelLimitsMemberId(record.id);
setModelLimitsMemberName(
record.display_name || record.username || '',
@@ -629,22 +630,15 @@ const OrgMembers = ({
/* ignore */
}
setLoadingOrgModels(false);
}}
>
{t('模型')}
</Button>
</Tooltip>
<Tooltip
content={
isSelf
},
},
{
key: 'groups',
label: t('分组'),
title: isSelf
? t('不能修改自己的可调用分组')
: t('设置该成员可调用的分组')
}
>
<Button
type='link'
disabled={isSelf}
onClick={() => {
: t('设置该成员可调用的分组'),
onClick: () => {
if (isSelf) return;
setGroupsMemberId(record.id);
setGroupsMemberName(
@@ -652,16 +646,15 @@ const OrgMembers = ({
);
setSelectedMemberGroups(parseMemberGroups(record));
setGroupsModalVisible(true);
}}
>
{t('分组')}
</Button>
</Tooltip>
{orgRole === 'owner' && record.role === 'admin' && (
<Tooltip content={t('设置该管理员的细粒度权限')}>
<Button
type='link'
onClick={() => {
},
disabled: isSelf,
},
orgRole === 'owner' &&
record.role === 'admin' && {
key: 'permissions',
label: t('权限'),
title: t('设置该管理员的细粒度权限'),
onClick: () => {
setPermMemberId(record.id);
setPermMemberName(
record.display_name || record.username || '',
@@ -685,23 +678,25 @@ const OrgMembers = ({
smart_router_manage: !!perms.smart_router_manage,
});
setPermModalVisible(true);
}}
>
{t('权限')}
</Button>
</Tooltip>
)}
<Tooltip content={t('从企业中移除该成员')}>
<Popconfirm
title={t('确定移除该成员?移除后该成员将失去企业访问权限。')}
onConfirm={() => handleRemove(record.id)}
>
<Button type='link' danger>
{t('移除')}
</Button>
</Popconfirm>
</Tooltip>
</OrgRowActions>
},
},
{
key: 'remove',
label: t('移除'),
danger: true,
onClick: () =>
Modal.confirm({
title: t(
'确定移除该成员?移除后该成员将失去企业访问权限。',
),
okText: t('确认'),
cancelText: t('取消'),
okButtonProps: { danger: true },
onOk: () => handleRemove(record.id),
}),
},
]}
/>
);
},
});
+104 -106
View File
@@ -24,6 +24,7 @@ import {
OctagonX as ActionOctagonX,
Code2 as ActionCode2,
} from '@/components/common/icons/ActionIcons';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import {
Button,
@@ -217,118 +218,115 @@ const OrgPrivateSkills = ({ orgId }) => {
currentUserId > 0 && Number(row.version?.created_by) === currentUserId;
const isReviewer =
currentUserId > 0 && Number(row.review?.reviewer_id) === currentUserId;
return (
<div className='flex flex-wrap gap-2'>
<Button
size='small'
disabled={row.definition.emergency_stopped}
onClick={() => {
setEditingSkill(row.definition);
setForm({
...blankSkill,
canonical_id: row.definition.canonical_id,
});
setEditorVisible(true);
}}
>
{t('新版本')}
</Button>
<Button size='small' onClick={() => openHistory(row.definition)}>
{t('历史版本')}
</Button>
<Button
size='small'
disabled={!versionId}
onClick={() => {
// Clear residue from a previous version's test before reopening.
setEvidence({ model: '', input: '' });
setEvidenceVersion(versionId);
}}
>
{t('执行模型实测')}
</Button>
<Button
size='small'
disabled={!versionId || row.review?.status !== 'pending' || isAuthor}
onClick={() =>
action(`/api/org/skills/private/versions/${versionId}/review/start`)
}
>
{isAuthor && row.review?.status === 'pending'
const [primaryAction, ...moreActions] = [
{
key: 'new-version',
label: t('新版本'),
onClick: () => {
setEditingSkill(row.definition);
setForm({
...blankSkill,
canonical_id: row.definition.canonical_id,
});
setEditorVisible(true);
},
disabled: row.definition.emergency_stopped,
},
{
key: 'history',
label: t('历史版本'),
onClick: () => openHistory(row.definition),
},
{
key: 'runtime',
label: t('执行模型实测'),
onClick: () => {
// Clear residue from a previous version's test before reopening.
setEvidence({ model: '', input: '' });
setEvidenceVersion(versionId);
},
disabled: !versionId,
},
{
key: 'claim',
label:
isAuthor && row.review?.status === 'pending'
? t('待他人审核')
: t('领取审核')}
</Button>
<Button
size='small'
icon={<ActionFileCheck2 size={14} />}
disabled={
!versionId || row.review?.status !== 'reviewing' || !isReviewer
}
onClick={() =>
: t('领取审核'),
onClick: () =>
action(`/api/org/skills/private/versions/${versionId}/review/start`),
disabled: !versionId || row.review?.status !== 'pending' || isAuthor,
},
{
key: 'approve',
label: t('通过'),
onClick: () =>
action(
`/api/org/skills/private/versions/${versionId}/review/decision`,
{ approved: true, conclusion: { decision: 'approved' } },
),
disabled:
!versionId || row.review?.status !== 'reviewing' || !isReviewer,
icon: <ActionFileCheck2 size={14} />,
},
{
key: 'reject',
label: t('驳回'),
onClick: () =>
action(
`/api/org/skills/private/versions/${versionId}/review/decision`,
{ approved: false, conclusion: { decision: 'rejected' } },
),
disabled:
!versionId || row.review?.status !== 'reviewing' || !isReviewer,
danger: true,
},
{
key: 'publish',
label: t('发布'),
onClick: () =>
action(`/api/org/skills/private/versions/${versionId}/publish`),
disabled: !versionId || row.review?.status !== 'approved',
},
{
key: 'rollback',
label: t('回滚'),
onClick: () =>
askReason(t('回滚到当前列表版本'), (reason) =>
action(
`/api/org/skills/private/versions/${versionId}/review/decision`,
{ approved: true, conclusion: { decision: 'approved' } },
)
}
>
{t('通过')}
</Button>
<Button
size='small'
type='danger'
disabled={
!versionId || row.review?.status !== 'reviewing' || !isReviewer
}
onClick={() =>
`/api/org/skills/private/${row.definition.id}/versions/${versionId}/rollback`,
{ reason },
),
),
disabled: !versionId,
icon: <ActionRotateCcw size={14} />,
},
{
key: 'stop',
label: t('紧急停用'),
onClick: () =>
askReason(t('紧急停用 Skill'), (reason) =>
action(
`/api/org/skills/private/versions/${versionId}/review/decision`,
{ approved: false, conclusion: { decision: 'rejected' } },
)
}
>
{t('驳回')}
</Button>
`/api/org/skills/private/${row.definition.id}/emergency-stop`,
{ reason },
),
),
disabled: row.definition.emergency_stopped,
icon: <ActionOctagonX size={14} />,
danger: true,
},
];
return (
<TableRowActions items={moreActions}>
<Button
size='small'
disabled={!versionId || row.review?.status !== 'approved'}
onClick={() =>
action(`/api/org/skills/private/versions/${versionId}/publish`)
}
type='link'
disabled={primaryAction.disabled}
onClick={primaryAction.onClick}
>
{t('发布')}
{primaryAction.label}
</Button>
<Button
size='small'
icon={<ActionRotateCcw size={14} />}
disabled={!versionId}
onClick={() =>
askReason(t('回滚到当前列表版本'), (reason) =>
action(
`/api/org/skills/private/${row.definition.id}/versions/${versionId}/rollback`,
{ reason },
),
)
}
>
{t('回滚')}
</Button>
<Button
size='small'
type='danger'
icon={<ActionOctagonX size={14} />}
disabled={row.definition.emergency_stopped}
onClick={() =>
askReason(t('紧急停用 Skill'), (reason) =>
action(
`/api/org/skills/private/${row.definition.id}/emergency-stop`,
{ reason },
),
)
}
>
{t('紧急停用')}
</Button>
</div>
</TableRowActions>
);
};
const openCreateEditor = () => {
@@ -500,7 +498,7 @@ const OrgPrivateSkills = ({ orgId }) => {
},
{
title: t('操作'),
width: 430,
width: 170,
render: (_, row) => renderSkillActions(row),
},
]}
+5 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
Pencil as ActionPencil,
@@ -44,7 +45,10 @@ const { Text } = Typography;
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
const memberName = (m) =>
m.remark || m.display_name || m.username || `#${m.org_member_id}`;
m.remark ||
m.display_name ||
m.username ||
formatIdReference(m.org_member_id);
// 我的项目(阶段一):项目经理(项目负责人/项目管理员)自助管理项目成员与项目名。
const OrgProjectManage = ({ orgId }) => {
+36 -26
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
Plus as ActionPlus,
@@ -36,7 +37,8 @@ import {
import { API } from '../../helpers/api';
import { showError, collectPagedItems } from '../../helpers';
import OrgPageHeader from './components/OrgPageHeader';
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { OrgListCard } from './components/OrgListCard';
import OrgModal from './components/OrgModal';
import OrgScopedLimitButtons from './components/OrgScopedLimitButtons';
@@ -105,7 +107,7 @@ const OrgProjects = ({ orgId }) => {
const memberNameMap = useMemo(() => {
const m = {};
members.forEach((mem) => {
m[mem.id] = mem.display_name || mem.username || `#${mem.id}`;
m[mem.id] = mem.display_name || mem.username || formatIdReference(mem.id);
});
return m;
}, [members]);
@@ -303,12 +305,11 @@ const OrgProjects = ({ orgId }) => {
return members
.filter((mem) => !inProject.has(mem.id))
.map((mem) => ({
label: mem.display_name || mem.username || `#${mem.id}`,
label: mem.display_name || mem.username || formatIdReference(mem.id),
value: mem.id,
}));
}, [members, projectMembers]);
// 列宽与渲染对齐原型 EnterpriseProjects(150/350/120/140/300,scroll.x 1060);
const columns = [
{
title: t('项目编码'),
@@ -351,27 +352,36 @@ const OrgProjects = ({ orgId }) => {
},
{
title: t('操作'),
width: 300,
width: 168,
render: (_, record) => (
<OrgRowActions>
<OrgScopedLimitButtons
orgId={orgId}
record={record}
apiBase='/api/org/project'
scopeLabel='项目'
onSaved={fetchList}
variant='link'
/>
<Button type='link' onClick={() => openMembers(record)}>
{t('成员')}
</Button>
<Button type='link' onClick={() => openTokens(record)}>
{t('密钥')}
</Button>
<Button type='link' onClick={() => openEdit(record)}>
{t('编辑')}
</Button>
</OrgRowActions>
<OrgScopedLimitButtons
orgId={orgId}
record={record}
apiBase='/api/org/project'
scopeLabel='项目'
onSaved={fetchList}
renderActions={(limitItems) => (
<TableRowActions
items={[
...limitItems,
{
key: 'members',
label: t('成员'),
onClick: () => openMembers(record),
},
{
key: 'tokens',
label: t('密钥'),
onClick: () => openTokens(record),
},
]}
>
<Button type='link' size='small' onClick={() => openEdit(record)}>
{t('编辑')}
</Button>
</TableRowActions>
)}
/>
),
},
];
@@ -491,7 +501,7 @@ const OrgProjects = ({ orgId }) => {
{
title: t('成员'),
dataIndex: 'org_member_id',
render: (v) => memberNameMap[v] || `#${v}`,
render: (v) => memberNameMap[v] || formatIdReference(v),
},
{
title: t('角色'),
@@ -550,7 +560,7 @@ const OrgProjects = ({ orgId }) => {
</Tag>
) : (
<Tag color='blue' size='small'>
{projectNameMap[v] || `#${v}`}
{projectNameMap[v] || formatIdReference(v)}
</Tag>
),
},
+6 -2
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../helpers/safeDisplay';
import {
Copy as ActionCopy,
Search as ActionSearch,
@@ -250,7 +251,10 @@ const OrgPromptRecords = ({ orgId }) => {
() => [
{ value: '', label: t('全部成员') },
...members.map((member) => {
const name = member.name || member.username || `User#${member.user_id}`;
const name = formatUserReference(
member.name || member.username,
member.user_id,
);
return {
value: member.member_id,
label:
@@ -271,7 +275,7 @@ const OrgPromptRecords = ({ orgId }) => {
member?.remark ||
member?.display_name ||
record.username ||
`User#${record.user_id}`
formatUserReference(record.name || record.username, record.user_id)
);
};
+2 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
@@ -1013,7 +1014,7 @@ const OrgSettings = ({ orgId, orgRole }) => {
value={transferTargetId}
onChange={(v) => setTransferTargetId(v)}
optionList={members.map((m) => ({
label: `${m.user_name || m.username || 'User#' + m.user_id} (${m.role})`,
label: `${formatUserReference(m.user_name || m.username, m.user_id, t('未知用户'))} (${m.role})`,
value: m.user_id,
}))}
/>
+6 -2
View File
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { formatUserReference } from '../../helpers/safeDisplay';
import {
EyeOff as ActionEyeOff,
@@ -512,7 +514,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
key: 'creator_name',
dataIndex: 'creator_name',
width: 140,
render: (name, record) => name || `User#${record.user_id}`,
render: (name, record) => formatUserReference(name, record.user_id),
},
]
: []),
@@ -1348,7 +1350,9 @@ const EditTokenModal = ({
(libraryRes.data.data || [])
.filter((policy) => policy.enabled)
.map((policy) => ({
label: nameById.get(policy.skill_id) || `#${policy.skill_id}`,
label:
nameById.get(policy.skill_id) ||
formatIdReference(policy.skill_id),
value: policy.skill_id,
})),
);
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import {
ChevronRight as ActionChevronRight,
@@ -774,7 +775,11 @@ const FlowInner = ({
) : (
<div className='space-y-1'>
{sheetMembers.map((m) => {
const name = m.display_name || m.username || `#${m.user_id}`;
const name = formatUserReference(
m.display_name || m.username,
m.user_id,
t('未知用户'),
);
return (
<div
key={m.user_id}
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatPercent } from '../../../helpers/safeDisplay';
import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -93,11 +94,16 @@ const DeltaBadge = ({ cur, prev, t }) => {
if (!prev || prev <= 0) {
return <small>{t('无上期对比')}</small>;
}
const pct = ((cur - prev) / prev) * 100;
const up = pct >= 0;
const pct = Number.isFinite(Number(cur))
? ((Number(cur) - Number(prev)) / Number(prev)) * 100
: null;
const up = pct !== null && pct >= 0;
return (
<small className={up ? 'is-up' : 'is-down'}>
{up ? '↑' : '↓'} {Math.abs(pct).toFixed(1)}%<em>{t('较上期')}</em>
{pct === null
? '-'
: `${up ? '↑' : '↓'} ${formatPercent(Math.abs(pct), 1)}`}
<em>{t('较上期')}</em>
</small>
);
};
@@ -432,12 +438,14 @@ const OrgAnalyticsPanel = ({
width: 300,
render: (_, r) => {
const pct =
breakdownTotal > 0 ? ((r.quota || 0) / breakdownTotal) * 100 : 0;
breakdownTotal > 0
? ((Number(r.quota) || 0) / breakdownTotal) * 100
: null;
return (
<div className='oc-ea-cost-share'>
<div>
<strong>{renderQuota(r.quota || 0, 2)}</strong>
<span>{pct.toFixed(1)}%</span>
<span>{formatPercent(pct, 1)}</span>
</div>
<Progress
percent={Math.round(pct)}
@@ -59,7 +59,7 @@ const OrgScopedLimitButtons = ({
apiBase,
scopeLabel,
onSaved,
variant = 'default',
renderActions,
}) => {
const { t } = useTranslation();
@@ -171,46 +171,47 @@ const OrgScopedLimitButtons = ({
return (
<>
<Tooltip
content={t(
'设置该{{scope}}成员默认可用的模型范围(与成员/项目/部门限制取交集)',
{ scope: t(scopeLabel) },
)}
>
<Button
{...(variant === 'link'
? { type: 'link' }
: {
size: 'small',
theme: 'light',
type: modelConfigured ? 'primary' : 'tertiary',
icon: <ActionLayers size={14} />,
})}
onClick={openModelModal}
>
{t('模型')}
</Button>
</Tooltip>
<Tooltip
content={t(
'设置该{{scope}}成员默认可调用的分组(与成员/项目/部门限制取交集)',
{ scope: t(scopeLabel) },
)}
>
<Button
{...(variant === 'link'
? { type: 'link' }
: {
size: 'small',
theme: 'light',
type: groupConfigured ? 'primary' : 'tertiary',
icon: <ActionLayers size={14} />,
})}
onClick={openGroupsModal}
>
{t('分组')}
</Button>
</Tooltip>
{renderActions ? (
renderActions([
{ key: 'models', label: t('模型'), onClick: openModelModal },
{ key: 'groups', label: t('分组'), onClick: openGroupsModal },
])
) : (
<>
<Tooltip
content={t(
'设置该{{scope}}成员默认可用的模型范围(与成员/项目/部门限制取交集)',
{ scope: t(scopeLabel) },
)}
>
<Button
size='small'
theme='light'
type={modelConfigured ? 'primary' : 'tertiary'}
icon={<ActionLayers size={14} />}
onClick={openModelModal}
>
{t('模型')}
</Button>
</Tooltip>
<Tooltip
content={t(
'设置该{{scope}}成员默认可调用的分组(与成员/项目/部门限制取交集)',
{ scope: t(scopeLabel) },
)}
>
<Button
size='small'
theme='light'
type={groupConfigured ? 'primary' : 'tertiary'}
icon={<ActionLayers size={14} />}
onClick={openGroupsModal}
>
{t('分组')}
</Button>
</Tooltip>
</>
)}
{/* 模型限制 Modal */}
<OrgModal
@@ -19,12 +19,10 @@ For commercial licensing, please contact support@quantumnous.com
import { useMemo } from 'react';
import { theme } from 'antd';
import { useActualTheme } from '../../../context/Theme';
import { brandAccentFromToken } from '../../../components/ui/UiThemeProvider';
/**
* 消耗明细页(/org/logs)主题桥:只从 Ant token 推导页面局部变量,挂在页面根节点 style 上。
* - --oc-brand:原型 --brand(页签、额度、统计图标等强调色),浅色 / 深色 / 自定义主色三态跟随 token。
* - --oc-brand 继承页面作用域的品牌强调色。
* - --oc-stat-brand-bg:统计图标浅底(原型 #b9650810 = 品牌色 6.3% 透明度)。
* - --ur-progress-done:任务进度满格描边(原型 strokeColor = var(--brand))。
* - --oc-task-{success|failure|pending}-{text|bg|border}:绘图与视频“本页统计”语义色(Ant success / error / warning)。
@@ -32,10 +30,8 @@ import { brandAccentFromToken } from '../../../components/ui/UiThemeProvider';
*/
export function useOrgLogsThemeStyle() {
const { token } = theme.useToken();
const dark = useActualTheme() === 'dark';
return useMemo(
() => ({
'--oc-brand': brandAccentFromToken(token.colorPrimary, dark),
'--oc-stat-brand-bg':
'color-mix(in srgb, var(--oc-brand) 6.3%, transparent)',
'--ur-progress-done': 'var(--oc-brand)',
@@ -49,7 +45,7 @@ export function useOrgLogsThemeStyle() {
'--oc-task-pending-bg': token.colorWarningBg,
'--oc-task-pending-border': token.colorWarningBorder,
}),
[token, dark],
[token],
);
}
+31 -22
View File
@@ -38,7 +38,7 @@ import {
} from 'lucide-react';
import OrgStatCard from '../components/OrgStatCard';
import OrgStateBlock from '../components/OrgStateBlock';
import { OrgRowActions } from '../components/OrgListCard';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { renderQuota } from '../../../helpers/render';
import { deptFundApi } from './fundApi';
import { FUND_STATE, buildFundTree } from './fundFormat';
@@ -193,30 +193,39 @@ const DeptFundsPanel = ({ orgId, deptId, deptName, refreshKey }) => {
},
{
title: t('操作'),
width: 210,
width: 168,
fixed: 'right',
render: (_, r) => (
<OrgRowActions>
<TableRowActions
items={
canTransfer
? [
r.account && {
key: 'ledger',
label: t('流水'),
onClick: () =>
setLedgerAccount({ id: r.account.id, name: r.name }),
},
{
key: 'recall',
label: t('回收'),
onClick: () => setTransfer({ mode: 'recall', row: r }),
},
]
: []
}
>
{canTransfer && (
<>
<Button
size='small'
type='link'
disabled={centerDisabled || r.dept_status === 2}
onClick={() => setTransfer({ mode: 'allocate', row: r })}
>
{t('分配')}
</Button>
<Button
size='small'
type='link'
onClick={() => setTransfer({ mode: 'recall', row: r })}
>
{t('回收')}
</Button>
</>
<Button
size='small'
type='link'
disabled={centerDisabled || r.dept_status === 2}
onClick={() => setTransfer({ mode: 'allocate', row: r })}
>
{t('分配')}
</Button>
)}
{r.account && (
{!canTransfer && r.account && (
<Button
size='small'
type='link'
@@ -227,7 +236,7 @@ const DeptFundsPanel = ({ orgId, deptId, deptName, refreshKey }) => {
{t('流水')}
</Button>
)}
</OrgRowActions>
</TableRowActions>
),
},
];
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../../helpers/safeDisplay';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -157,7 +158,7 @@ const FundLedgerSheet = ({ visible, account, fetchLedger, onClose }) => {
? t('平台管理员')
: isConsume(r) || !r.operator_user_id
? t('系统')
: v || `#${r.operator_user_id}`;
: v || formatIdReference(r.operator_user_id);
return (
<span className='block max-w-[120px] truncate' title={name}>
{name}
+31 -22
View File
@@ -35,7 +35,7 @@ import OrgPanel from '../components/OrgPanel';
import OrgStatCard from '../components/OrgStatCard';
import OrgStateBlock from '../components/OrgStateBlock';
import OrgModal from '../components/OrgModal';
import { OrgRowActions } from '../components/OrgListCard';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { showError, showSuccess } from '../../../helpers/utils';
import { renderQuota } from '../../../helpers/render';
import { orgFundApi } from './fundApi';
@@ -279,32 +279,41 @@ const OrgDeptFunds = ({ orgId }) => {
},
{
title: t('操作'),
width: 220,
width: 168,
fixed: 'right',
render: (_, r) => {
const isArchived = r.account?.status === FUND_ACCOUNT_STATUS.ARCHIVED;
return (
<OrgRowActions>
<TableRowActions
items={
canTransfer && !isArchived
? [
r.account && {
key: 'ledger',
label: t('流水'),
onClick: () =>
setLedgerAccount({ id: r.account.id, name: r.name }),
},
{
key: 'recall',
label: t('回收'),
onClick: () => setTransfer({ mode: 'recall', row: r }),
},
]
: []
}
>
{canTransfer && !isArchived && (
<>
<Button
size='small'
type='link'
disabled={r.dept_status === 2}
onClick={() => setTransfer({ mode: 'allocate', row: r })}
>
{t('分配')}
</Button>
<Button
size='small'
type='link'
onClick={() => setTransfer({ mode: 'recall', row: r })}
>
{t('回收')}
</Button>
</>
<Button
size='small'
type='link'
disabled={r.dept_status === 2}
onClick={() => setTransfer({ mode: 'allocate', row: r })}
>
{t('分配')}
</Button>
)}
{r.account && (
{(!canTransfer || isArchived) && r.account && (
<Button
size='small'
type='link'
@@ -315,7 +324,7 @@ const OrgDeptFunds = ({ orgId }) => {
{t('流水')}
</Button>
)}
</OrgRowActions>
</TableRowActions>
);
},
},
+4 -3
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatPercent } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import {
@@ -366,7 +367,7 @@ const GroupMonitor = () => {
className='text-sm font-medium'
style={{ color: getUptimeColor(value) }}
>
{(value || 0).toFixed(1)}%
{formatPercent(value || 0, 1)}
</span>
</div>
),
@@ -511,7 +512,7 @@ const GroupMonitor = () => {
<div
className={`service-uptime-badge px-4 py-2 rounded-xl text-sm font-bold ${getUptimeClass(uptimePercent)}`}
>
{uptimePercent.toFixed(2)}%
{formatPercent(uptimePercent, 2)}
</div>
</div>
</div>
@@ -591,7 +592,7 @@ const GroupMonitor = () => {
<div
className={`service-uptime-badge px-3 py-1.5 rounded-lg text-xs font-bold ${getUptimeClass(uptimePercent)}`}
>
{uptimePercent.toFixed(2)}%
{formatPercent(uptimePercent, 2)}
</div>
</div>
<div className='text-center'>
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatPercent } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons';
@@ -544,7 +545,7 @@ const GroupMonitorAdmin = () => {
className='text-3xl font-bold'
style={{ color: getHealthColor(overview.average_uptime) }}
>
{overview.average_uptime.toFixed(1)}%
{formatPercent(overview.average_uptime, 1)}
</div>
<div className='text-gray-500 mt-1'>{t('平均可用率')}</div>
</Card>
@@ -659,7 +660,7 @@ const GroupMonitorAdmin = () => {
color: getHealthColor(group.uptime_percent),
}}
>
{group.uptime_percent.toFixed(1)}%
{formatPercent(group.uptime_percent, 1)}
</div>
<div className='text-xs text-gray-500'>
{t('可用率')}
@@ -708,7 +709,7 @@ const GroupMonitorAdmin = () => {
color: getHealthColor(group.uptime_percent),
}}
>
{group.uptime_percent.toFixed(1)}%
{formatPercent(group.uptime_percent, 1)}
</div>
<div className='stat-box-label'>{t('可用率')}</div>
</div>
+33 -10
View File
@@ -32,6 +32,10 @@ import {
import { useTranslation } from 'react-i18next';
import i18next from 'i18next';
import { colord } from 'colord';
import {
resolveBrandPalette,
resolveGradientLabel,
} from '../../../helpers/brandPalette';
import { API, showError, showSuccess } from '../../../helpers';
import { StatusContext } from '../../../context/Status';
import { PRESETS, DEFAULT_PRESET_KEY } from '../../../styles/presets';
@@ -1327,6 +1331,16 @@ function t_alpha(pct) {
* 让用户能直观对比两组色板互不影响。 */
function PreviewMini({ palette, colorMode, t }) {
const isDark = colorMode === 'dark';
const previewSurface = isDark ? '#101014' : '#f6f8fb';
const interaction = resolveBrandPalette(
palette['brand-primary'],
isDark,
previewSurface,
);
const bubbleStops = ['from', 'via', 'to'].map(
(stop) => palette[`brand-gradient-${stop}`],
);
const bubbleLabel = resolveGradientLabel(bubbleStops, previewSurface);
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{/* —— 前景:按钮 / 气泡 / 强调色 —— */}
@@ -1335,7 +1349,7 @@ function PreviewMini({ palette, colorMode, t }) {
padding: 16,
borderRadius: 10,
border: '1px solid var(--ui-color-border)',
background: isDark ? '#101014' : '#f6f8fb',
background: previewSurface,
display: 'flex',
alignItems: 'center',
gap: 16,
@@ -1346,36 +1360,45 @@ function PreviewMini({ palette, colorMode, t }) {
style={{
padding: '8px 16px',
borderRadius: 8,
color: '#fff',
color: interaction.onSolid,
fontWeight: 500,
fontSize: 13,
background: `linear-gradient(135deg, ${palette['brand-gradient-from']} 0%, ${palette['brand-gradient-via']} 50%, ${palette['brand-gradient-to']} 100%)`,
boxShadow: `0 4px 12px ${palette['brand-primary-soft'] || 'rgba(0,0,0,0.1)'}`,
background: interaction.normal,
}}
>
{t('主按钮')}
</div>
<a
<span
style={{
color: palette['brand-primary'],
color: interaction.selectionText,
textDecoration: 'underline',
fontSize: 13,
}}
>
{t('链接示例')}
</a>
</span>
<div
style={{
padding: '8px 14px',
borderRadius: '14px 14px 4px 14px',
color: '#fff',
fontSize: 12,
background: `linear-gradient(135deg, ${palette['brand-gradient-from']} 0%, ${palette['brand-gradient-via']} 50%, ${palette['brand-gradient-to']} 100%)`,
background: `linear-gradient(135deg, ${bubbleStops[0]} 0%, ${bubbleStops[1]} 50%, ${bubbleStops[2]} 100%)`,
}}
>
{t('聊天气泡')}
<span
style={{
color: bubbleLabel.color,
...(bubbleLabel.background && {
background: bubbleLabel.background,
borderRadius: 4,
padding: '1px 4px',
}),
}}
>
{t('聊天气泡')}
</span>
</div>
<div
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import { Trans } from 'react-i18next';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import React, {
useCallback,
useEffect,
@@ -593,7 +594,40 @@ export default function SettingsPaymentGatewayPayPal(props) {
{
title: t('操作'),
render: (_, row) => (
<div className='flex flex-wrap gap-2'>
<TableRowActions
items={[
{
key: 'reconcile',
label: t('触发对账'),
onClick: () => reconcileOperationOrder(row.trade_no),
disabled: !row.third_trade_no,
},
{
key: 'expire',
label: t('确认未付款并过期'),
onClick: () => {
setExpireOrder(row);
setForceExpire(false);
setForceExpireConfirmed(false);
setExpireReason(t('确认该订单未完成 PayPal 支付'));
},
danger: true,
},
{
key: 'force-expire',
label: t('强制过期'),
onClick: () => {
setExpireOrder(row);
setForceExpire(true);
setForceExpireConfirmed(false);
setExpireReason(
t('管理员确认远端状态无法核验,强制关闭该 PayPal 订单'),
);
},
danger: true,
},
]}
>
<Button
htmlType='button'
onClick={() => inspectOperationOrder(row.trade_no)}
@@ -602,45 +636,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
>
{t('查询远端状态')}
</Button>
<Button
htmlType='button'
onClick={() => reconcileOperationOrder(row.trade_no)}
disabled={!row.third_trade_no}
type='link'
size='small'
>
{t('触发对账')}
</Button>
<Button
htmlType='button'
onClick={() => {
setExpireOrder(row);
setForceExpire(false);
setForceExpireConfirmed(false);
setExpireReason(t('确认该订单未完成 PayPal 支付'));
}}
type='link'
size='small'
danger
>
{t('确认未付款并过期')}
</Button>
<Button
htmlType='button'
onClick={() => {
setExpireOrder(row);
setForceExpire(true);
setForceExpireConfirmed(false);
setExpireReason(
t('管理员确认远端状态无法核验,强制关闭该 PayPal 订单'),
);
}}
type='link'
size='small'
>
{t('强制过期')}
</Button>
</div>
</TableRowActions>
),
},
],
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
@@ -364,7 +365,7 @@ export default function ModelCostSettings() {
() =>
channels.map((c) => ({
value: String(c.id),
label: `#${c.id} ${c.name}${c.status === 1 ? '' : t('(已禁用)')}`,
label: `${formatIdReference(c.id)} ${c.name}${c.status === 1 ? '' : t('(已禁用)')}`,
})),
[channels, t],
);
@@ -1996,7 +1997,8 @@ export default function ModelCostSettings() {
columns={[
{
title: t('渠道'),
render: (_, r) => `#${r.channel_id} ${r.channel_name}`,
render: (_, r) =>
`${formatIdReference(r.channel_id)} ${r.channel_name}`,
},
{ title: t('模型(上游名)'), dataIndex: 'model_name' },
{
+2 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../../helpers/safeDisplay';
// 系统设置 →「WeyAi」页签 →「账号接入」子页签(方案 M8;M21 起从「系统设置」页签搬到这里)。只对超级管理员展示;
// 这些 key 在后端登记为 root-only(setting/console_setting/admin_delegation.go)。
@@ -338,7 +339,7 @@ function OrgSelect({
const selectedValues = (value || []).map((item) => `${item}`);
const options = selectedValues.map((item) => ({
value: item,
label: orgLabels[item] || `#${item}`,
label: orgLabels[item] || formatIdReference(item),
}));
const seen = new Set(selectedValues);
results.forEach((org) => {
@@ -23,14 +23,14 @@ For commercial licensing, please contact support@quantumnous.com
// root 和被下放了「WeyAi」页签的管理员都能用。
import { Trans } from 'react-i18next';
import { TableRowActions } from '@/components/common/table/TableToolbar';
import React, { useCallback, useEffect, useState } from 'react';
import {
Banner,
Button,
Card,
Popconfirm,
Modal,
Select,
Space,
Spin,
Table,
Tag,
@@ -264,7 +264,48 @@ const SettingsWeyAiContent = () => {
title: t('操作'),
width: 300,
render: (_, item, index) => (
<Space wrap>
<TableRowActions
items={[
item.status === 'published' && {
key: 'offline',
label: t('下架'),
onClick: () => setStatus(item, 'offline'),
disabled: busyId === item.id,
},
item.status !== 'published' && {
key: 'publish',
label: t('发布'),
onClick: () => setStatus(item, 'published'),
disabled: busyId === item.id,
},
{
key: 'up',
label: t('上移'),
onClick: () => move(index, -1),
disabled: index === 0,
},
{
key: 'down',
label: t('下移'),
onClick: () => move(index, 1),
disabled: index === items.length - 1,
},
{
key: 'delete',
label: t('删除'),
danger: true,
onClick: () =>
Modal.confirm({
title: t('确定删除这个条目?'),
content: t('删除后客户端不再显示;它的文件 7 天后清理'),
okText: t('确认'),
cancelText: t('取消'),
okButtonProps: { danger: true },
onOk: () => remove(item),
}),
},
]}
>
<Button
onClick={() => setEditor({ visible: true, item })}
type='link'
@@ -272,53 +313,7 @@ const SettingsWeyAiContent = () => {
>
{t('编辑')}
</Button>
{item.status === 'published' ? (
<Button
loading={busyId === item.id}
onClick={() => setStatus(item, 'offline')}
type='link'
size='small'
>
{t('下架')}
</Button>
) : (
<Button
loading={busyId === item.id}
onClick={() => setStatus(item, 'published')}
type='link'
size='small'
>
{t('发布')}
</Button>
)}
<Button
disabled={index === 0}
aria-label={t('上移')}
onClick={() => move(index, -1)}
type='link'
size='small'
>
{t('上移')}
</Button>
<Button
disabled={index === items.length - 1}
aria-label={t('下移')}
onClick={() => move(index, 1)}
type='link'
size='small'
>
{t('下移')}
</Button>
<Popconfirm
title={t('确定删除这个条目?')}
content={t('删除后客户端不再显示;它的文件 7 天后清理')}
onConfirm={() => remove(item)}
>
<Button type='link' size='small' danger>
{t('删除')}
</Button>
</Popconfirm>
</Space>
</TableRowActions>
),
},
];
@@ -22,6 +22,7 @@ For commercial licensing, please contact support@quantumnous.com
// 也会带上这里写的内容。客户端读公开接口 GET /api/weyai/desktop/release-notes,
// 未登录也能看到;草稿只在这里可见。root 和被下放了「WeyAi」页签的管理员都能用。
import { TableRowActions } from '@/components/common/table/TableToolbar';
import React, { useCallback, useEffect, useState } from 'react';
import {
Banner,
@@ -30,7 +31,6 @@ import {
Empty,
Input,
Modal,
Popconfirm,
Space,
Switch,
Table,
@@ -197,7 +197,37 @@ const SettingsWeyAiReleaseNotes = () => {
title: t('操作'),
width: 240,
render: (_, note) => (
<Space>
<TableRowActions
items={[
note.status === 'published' && {
key: 'withdraw',
label: t('撤回'),
onClick: () => setStatus(note, 'draft'),
disabled: busyId === note.id,
},
note.status !== 'published' && {
key: 'publish',
label: t('发布'),
onClick: () => setStatus(note, 'published'),
disabled: busyId === note.id,
},
{
key: 'delete',
label: t('删除'),
disabled: busyId === note.id,
danger: true,
onClick: () =>
Modal.confirm({
title: t('确定删除这条版本说明吗?'),
content: t('删除后客户端不再显示这个版本的说明'),
okText: t('确认'),
cancelText: t('取消'),
okButtonProps: { danger: true },
onOk: () => remove(note),
}),
},
]}
>
<Button
onClick={() => setDraft({ ...note })}
type='link'
@@ -205,40 +235,7 @@ const SettingsWeyAiReleaseNotes = () => {
>
{t('编辑')}
</Button>
{note.status === 'published' ? (
<Button
loading={busyId === note.id}
onClick={() => setStatus(note, 'draft')}
type='link'
size='small'
>
{t('撤回')}
</Button>
) : (
<Button
loading={busyId === note.id}
onClick={() => setStatus(note, 'published')}
type='link'
size='small'
>
{t('发布')}
</Button>
)}
<Popconfirm
title={t('确定删除这条版本说明吗?')}
content={t('删除后客户端不再显示这个版本的说明')}
onConfirm={() => remove(note)}
>
<Button
disabled={busyId === note.id}
type='link'
size='small'
danger
>
{t('删除')}
</Button>
</Popconfirm>
</Space>
</TableRowActions>
),
},
];
+2 -1
View File
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatIdReference } from '../../helpers/safeDisplay';
import { ConsolePageActions } from '../../components/console/ConsolePageContainer';
import React, { useCallback, useEffect, useRef, useState } from 'react';
@@ -1286,7 +1287,7 @@ const SkillPlatform = () => {
{ value: 0, label: t('自动路由(按模型自动选择渠道)') },
...testChannels.map((channel) => ({
value: channel.id,
label: `#${channel.id} ${channel.name}`,
label: `${formatIdReference(channel.id)} ${channel.name}`,
})),
]}
/>
+226 -224
View File
@@ -16,27 +16,28 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { formatUserReference } from '../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import {
Ban as ActionBan,
ShieldCheck as ActionShieldCheck,
CalendarClock as ActionCalendarClock,
Pencil as ActionPencil,
Plus as ActionPlus,
CreditCard as ActionCreditCard,
} from '@/components/common/icons/ActionIcons';
import {
ConsoleCard,
ConsoleSearchBar,
ConsoleSearchActions,
ConsoleFilterField,
ConsoleFilterGrid,
ConsoleListTable,
} from '../../components/console/ConsolePrimitives';
import { ConsolePageActions } from '../../components/console/ConsolePageContainer';
import ConsoleCollection from '../../components/console/ConsoleCollection';
import { TableRowActions } from '../../components/common/table/TableToolbar';
import { useIsMobile } from '../../hooks/common/useIsMobile';
import { createCardProPagination } from '../../helpers/utils';
import { Button as AntButton } from 'antd';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { CreditCard, Search, Sparkles, History } from 'lucide-react';
import { CreditCard, Search, History } from 'lucide-react';
import {
Button,
Checkbox,
@@ -45,10 +46,8 @@ import {
Input,
InputNumber,
Modal,
Popconfirm,
Select,
Space,
Table,
Tag,
TextArea,
Timeline,
@@ -125,6 +124,7 @@ const RemainingTag = ({ endDate, status, t }) => {
const Subscription = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const isMobile = useIsMobile();
const admin = isAdmin();
// 列表数据
@@ -355,7 +355,7 @@ const Subscription = () => {
return (
<div className='flex flex-col'>
<span className='font-medium'>
{display || username || `User#${r.user_id}`}
{formatUserReference(display || username, r.user_id)}
</span>
<span className='text-xs text-gray-400'>
#{r.user_id}
@@ -423,234 +423,230 @@ const Subscription = () => {
},
{
title: t('操作'),
width: 300,
key: 'actions',
width: 140,
fixed: 'right',
render: (_, r) => (
<Space spacing={4} wrap>
<Button size='small' theme='borderless' onClick={() => openDetail(r)}>
<TableRowActions
items={[
admin && {
key: 'edit',
label: t('编辑'),
onClick: () => openEdit(r),
},
admin &&
r.status !== 'canceled' &&
r.status !== 'banned' && {
key: 'extend',
label: t('延长'),
onClick: () => openExtend(r),
},
admin &&
r.status === 'active' && {
key: 'grant',
label: t('补发'),
onClick: () =>
Modal.confirm({
title: t('确认手动补发今日额度?'),
onOk: () => doGrant(r),
}),
},
admin &&
r.status === 'banned' && {
key: 'unban',
label: t('解封'),
onClick: () => openUnban(r),
},
admin &&
r.status !== 'banned' && {
key: 'ban',
label: t('封禁'),
danger: true,
onClick: () => openBan(r),
},
]}
>
<Button type='link' size='small' onClick={() => openDetail(r)}>
{t('详情')}
</Button>
{admin && r.status !== 'banned' && (
<Button
size='small'
theme='borderless'
type='danger'
icon={<ActionBan size={12} />}
onClick={() => openBan(r)}
>
{t('封禁')}
</Button>
)}
{admin && r.status === 'banned' && (
<Button
size='small'
theme='borderless'
type='primary'
icon={<ActionShieldCheck size={12} />}
onClick={() => openUnban(r)}
>
{t('解封')}
</Button>
)}
{admin && r.status !== 'canceled' && r.status !== 'banned' && (
<Button
size='small'
theme='borderless'
icon={<ActionCalendarClock size={12} />}
onClick={() => openExtend(r)}
>
{t('延长')}
</Button>
)}
{admin && (
<Button
size='small'
theme='borderless'
icon={<ActionPencil size={12} />}
onClick={() => openEdit(r)}
>
{t('编辑')}
</Button>
)}
{admin && r.status === 'active' && (
<Popconfirm
title={t('确认手动补发今日额度?')}
onConfirm={() => doGrant(r)}
>
<Button
size='small'
theme='borderless'
icon={<Sparkles size={12} />}
>
{t('补发')}
</Button>
</Popconfirm>
)}
</Space>
</TableRowActions>
),
},
];
return (
<div className='console-content'>
{/* 筛选区 */}
<ConsoleSearchBar formProps={{ layout: 'inline' }}>
<div className='console-search-fields'>
<Input
prefix={<Search size={14} />}
placeholder={t('搜索用户名/昵称/订单号')}
value={keyword}
onChange={setKeyword}
onEnterPress={handleSearch}
style={{ width: 240 }}
/>
<InputNumber
placeholder={t('用户ID')}
value={userId}
onChange={setUserId}
min={0}
style={{ width: 110 }}
hideButtons
/>
<Select
placeholder={t('套餐类型')}
value={planTypes}
onChange={(v) => {
setPage(1);
setPlanTypes(v || []);
}}
multiple
maxTagCount={2}
style={{ width: 160 }}
optionList={[
{ label: t('周卡'), value: 'weekly' },
{ label: t('月卡'), value: 'monthly' },
{ label: t('季卡'), value: 'quarterly' },
]}
/>
<Select
placeholder={t('档位')}
value={tiers}
onChange={(v) => {
setPage(1);
setTiers(v || []);
}}
multiple
maxTagCount={2}
style={{ width: 140 }}
optionList={[
{ label: 'Lite', value: 'lite' },
{ label: 'Pro', value: 'pro' },
]}
/>
<Select
placeholder={t('状态')}
value={statuses}
onChange={(v) => {
setPage(1);
setStatuses(v || []);
}}
multiple
maxTagCount={2}
style={{ width: 180 }}
optionList={[
{ label: t('active'), value: 'active' },
{ label: t('expired'), value: 'expired' },
{ label: t('canceled'), value: 'canceled' },
{ label: t('banned'), value: 'banned' },
]}
/>
<DatePicker
type='dateRange'
value={endDateRange}
onChange={(d) => {
setPage(1);
setEndDateRange(d || null);
}}
placeholder={[t('到期开始'), t('到期结束')]}
style={{ width: 280 }}
density='compact'
/>
<ConsoleSearchActions
<ConsoleCollection
searchArea={
<ConsoleFilterGrid
onReset={handleReset}
onSearch={handleSearch}
loading={loading}
/>
{admin && (
<ConsolePageActions>
<Button
theme='solid'
type='primary'
icon={<ActionPlus size={14} />}
onClick={openCreate}
>
{t('新建会员')}
</Button>
<Button
type='tertiary'
icon={<ActionCreditCard size={14} />}
onClick={() => navigate('/console/setting?tab=membership')}
>
{t('会员管理')}
</Button>
</ConsolePageActions>
)}
</div>
</ConsoleSearchBar>
{/* 快捷筛选 */}
<div className='flex flex-wrap items-center gap-2 mb-4'>
<span className='text-xs text-gray-500'>{t('快捷筛选')}:</span>
<Tag
color={quickFilter === 'expiring3' ? 'red' : 'white'}
type={quickFilter === 'expiring3' ? 'solid' : 'ghost'}
className='cursor-pointer'
onClick={() => applyQuickFilter('expiring3')}
>
{t('3 天内到期')}
</Tag>
<Tag
color={quickFilter === 'expiring7' ? 'orange' : 'white'}
type={quickFilter === 'expiring7' ? 'solid' : 'ghost'}
className='cursor-pointer'
onClick={() => applyQuickFilter('expiring7')}
>
{t('7 天内到期')}
</Tag>
<Tag
color={quickFilter === 'overdue' ? 'grey' : 'white'}
type={quickFilter === 'overdue' ? 'solid' : 'ghost'}
className='cursor-pointer'
onClick={() => applyQuickFilter('overdue')}
>
{t('已过期未处理')}
</Tag>
</div>
{/* 表格 */}
<ConsoleCard>
<Table
>
<ConsoleFilterField
label={t('搜索关键字')}
id='subscription-keyword'
>
<Input
id='subscription-keyword'
prefix={<Search size={14} />}
placeholder={t('搜索用户名/昵称/订单号')}
value={keyword}
onChange={setKeyword}
onEnterPress={handleSearch}
/>
</ConsoleFilterField>
<ConsoleFilterField label={t('用户ID')} id='subscription-user-id'>
<InputNumber
id='subscription-user-id'
placeholder={t('用户ID')}
value={userId}
onChange={setUserId}
min={0}
hideButtons
/>
</ConsoleFilterField>
<ConsoleFilterField
label={t('套餐类型')}
id='subscription-plan-type'
>
<Select
id='subscription-plan-type'
placeholder={t('套餐类型')}
value={planTypes}
onChange={(v) => {
setPage(1);
setPlanTypes(v || []);
}}
multiple
maxTagCount={2}
optionList={[
{ label: t('周卡'), value: 'weekly' },
{ label: t('月卡'), value: 'monthly' },
{ label: t('季卡'), value: 'quarterly' },
]}
/>
</ConsoleFilterField>
<ConsoleFilterField label={t('档位')} id='subscription-tier'>
<Select
id='subscription-tier'
placeholder={t('档位')}
value={tiers}
onChange={(v) => {
setPage(1);
setTiers(v || []);
}}
multiple
maxTagCount={2}
optionList={[
{ label: 'Lite', value: 'lite' },
{ label: 'Pro', value: 'pro' },
]}
/>
</ConsoleFilterField>
<ConsoleFilterField label={t('状态')} id='subscription-status'>
<Select
id='subscription-status'
placeholder={t('状态')}
value={statuses}
onChange={(v) => {
setPage(1);
setStatuses(v || []);
}}
multiple
maxTagCount={2}
optionList={[
{ label: t('active'), value: 'active' },
{ label: t('expired'), value: 'expired' },
{ label: t('canceled'), value: 'canceled' },
{ label: t('banned'), value: 'banned' },
]}
/>
</ConsoleFilterField>
<ConsoleFilterField
label={t('到期时间')}
id='subscription-end-date'
>
<DatePicker
id={{
start: 'subscription-end-date',
end: 'subscription-end-date-end',
}}
type='dateRange'
value={endDateRange}
onChange={(d) => {
setPage(1);
setEndDateRange(d || null);
}}
placeholder={[t('到期开始'), t('到期结束')]}
density='compact'
/>
</ConsoleFilterField>
</ConsoleFilterGrid>
}
actionsArea={
<div className='console-list-tools'>
<div
className='console-list-quick-filters'
role='group'
aria-label={t('快捷筛选')}
>
{[
['expiring3', t('3 天内到期')],
['expiring7', t('7 天内到期')],
['overdue', t('已过期未处理')],
].map(([key, label]) => (
<AntButton
key={key}
type={quickFilter === key ? 'primary' : 'default'}
aria-pressed={quickFilter === key}
onClick={() => applyQuickFilter(key)}
>
{label}
</AntButton>
))}
</div>
{admin && (
<div className='console-list-tool-actions'>
<Button
icon={<ActionCreditCard size={14} />}
onClick={() => navigate('/console/setting?tab=membership')}
>
{t('会员管理')}
</Button>
<Button
type='primary'
icon={<ActionPlus size={14} />}
onClick={openCreate}
>
{t('新建会员')}
</Button>
</div>
)}
</div>
}
paginationArea={createCardProPagination({
currentPage: page,
pageSize,
total,
onPageChange: setPage,
onPageSizeChange: (size) => {
setPage(1);
setPageSize(size);
},
showSizeChanger: false,
isMobile,
t,
})}
>
<ConsoleListTable
columns={columns}
dataSource={list}
loading={loading}
rowKey='id'
pagination={{
currentPage: page,
total,
pageSize,
onPageChange: setPage,
onPageSizeChange: (size) => {
setPage(1);
setPageSize(size);
},
showTotal: true,
showSizeChanger: false,
}}
scroll={{ x: 1300 }}
size='middle'
empty={t('暂无订阅数据')}
pagination={false}
/>
</ConsoleCard>
</ConsoleCollection>
{/* 封禁弹窗 */}
<BanModal
@@ -978,7 +974,10 @@ const BanModal = ({ visible, row, onCancel, onDone, t }) => {
<div className='text-sm text-gray-500'>
{t('用户')}:
<span className='font-medium text-gray-900 dark:text-white'>
{row.display_name || row.username || `User#${row.user_id}`}
{formatUserReference(
row.display_name || row.username,
row.user_id,
)}
</span>
<span className='ml-2 text-xs text-gray-400'>#{row.user_id}</span>
</div>
@@ -1366,7 +1365,10 @@ const DetailDrawer = ({ visible, row, loading, auditLogs, onClose, t }) => {
<div className='flex justify-between'>
<span className='text-gray-500'>{t('用户')}</span>
<span>
{row.display_name || row.username || `User#${row.user_id}`}
{formatUserReference(
row.display_name || row.username,
row.user_id,
)}
<span className='ml-2 text-xs text-gray-400'>#{row.user_id}</span>
</span>
</div>
+167 -645
View File
@@ -1,673 +1,195 @@
/*
Copyright (C) 2025 QuantumNous
/* Copyright (C) 2025 QuantumNous */
Video Tutorial Component Styles
*/
/* ===== 容器 ===== */
.video-tutorial {
.tutorial-container .video-tutorial {
display: grid;
grid-template-columns: minmax(0, 1fr) 300px;
gap: 24px;
align-items: start;
}
.video-player-section,
.video-list-section {
min-width: 0;
}
.tutorial-container .video-player-card {
border: 1px solid var(--tt-border);
border-radius: 12px;
overflow: hidden;
box-shadow: none;
}
.video-player-card > .ant-card-body {
padding: 0;
}
.video-player-wrapper {
aspect-ratio: 16 / 9;
background: var(--tt-muted);
display: flex;
flex-direction: column;
gap: 28px;
align-items: center;
justify-content: center;
}
.video-player {
display: block;
width: 100%;
height: 100%;
aspect-ratio: 16 / 9;
object-fit: contain;
}
.video-info {
padding: 24px;
}
.video-info h4.ant-typography {
margin: 0 0 8px;
font-size: 20px;
}
.video-description {
line-height: 1.7;
overflow-wrap: anywhere;
}
.video-meta {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.video-meta-item {
display: inline-flex;
align-items: center;
gap: 6px;
color: var(--tt-secondary);
font-size: 12px;
}
.video-list {
display: grid;
gap: 12px;
}
.video-list-section h5.ant-typography {
margin: 0 0 16px;
font-size: 16px;
}
.video-list-item {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
padding: 12px;
text-align: left;
font: inherit;
color: var(--tt-text);
background: var(--tt-surface);
border: 1px solid var(--tt-border);
border-radius: 8px;
cursor: pointer;
}
.video-list-item:hover,
.video-list-item.active {
border-color: var(--tt-accent);
background: var(--tt-soft);
}
.video-list-thumbnail {
position: relative;
width: 88px;
aspect-ratio: 16 / 10;
flex-shrink: 0;
border-radius: 6px;
background: var(--tt-muted);
overflow: hidden;
}
/* 装饰性背景元素 */
.video-tutorial::before {
content: '';
.video-list-thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
}
.video-thumbnail-placeholder {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
color: var(--tt-accent);
}
.video-list-index {
position: absolute;
top: -20px;
right: -20px;
width: 200px;
height: 200px;
background: radial-gradient(
circle,
color-mix(in srgb, var(--brand-primary) 8%, transparent) 0%,
transparent 70%
);
border-radius: 50%;
pointer-events: none;
z-index: -1;
top: 3px;
left: 4px;
font-size: 10px;
padding: 0 4px;
border-radius: 3px;
background: var(--tt-surface);
color: var(--tt-text);
}
.video-tutorial::after {
content: '';
.video-list-duration {
position: absolute;
bottom: 20%;
left: -30px;
width: 150px;
height: 150px;
background: radial-gradient(
circle,
rgba(236, 72, 153, 0.06) 0%,
transparent 70%
);
border-radius: 50%;
pointer-events: none;
z-index: -1;
bottom: 3px;
right: 4px;
font-size: 10px;
padding: 0 4px;
border-radius: 3px;
background: var(--tt-surface);
color: var(--tt-text);
}
.video-list-info {
display: grid;
gap: 4px;
min-width: 0;
}
.video-list-name {
font-size: 13px;
}
.video-list-desc {
font-size: 12px;
}
.video-tips {
grid-column: 1 / -1;
}
.tutorial-container .video-tips-card {
background: var(--tt-muted);
border: 1px solid var(--tt-border);
border-radius: 8px;
box-shadow: none;
}
.video-tips-content {
display: flex;
align-items: flex-start;
gap: 12px;
}
.video-tutorial-loading,
.video-tutorial-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 450px;
text-align: center;
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 3%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 3%, transparent)
);
border-radius: 24px;
border: 2px dashed color-mix(in srgb, var(--brand-primary) 20%, transparent);
}
/* ===== 视频播放器区域 ===== */
.video-player-section {
width: 100%;
}
.video-player-card {
border-radius: 16px !important;
overflow: hidden;
border: 1px solid var(--ui-color-border) !important;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.video-player-wrapper {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 宽高比 */
background: #000;
}
.video-player {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain;
}
/* 视频错误状态 */
.video-error {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
color: white;
z-index: 5;
}
@keyframes errorPulse {
0%,
100% {
opacity: 0.4;
transform: scale(1);
}
50% {
opacity: 0.6;
transform: scale(1.05);
}
}
.video-retry-btn {
padding: 12px 32px;
background: linear-gradient(
135deg,
var(--brand-primary),
var(--brand-gradient-via)
);
border: none;
border-radius: 14px;
color: white;
font-weight: 600;
font-size: 14px;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
overflow: hidden;
}
.video-retry-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(
90deg,
transparent,
rgba(255, 255, 255, 0.3),
transparent
);
transition: left 0.5s ease;
}
.video-retry-btn:hover::before {
left: 100%;
}
.video-retry-btn:hover {
transform: translateY(-3px) scale(1.02);
box-shadow: 0 12px 28px
color-mix(in srgb, var(--brand-primary) 50%, transparent);
}
/* 视频信息 */
.video-info {
padding: 28px;
background: linear-gradient(
135deg,
rgba(255, 255, 255, 0.8),
rgba(255, 255, 255, 0.6)
);
backdrop-filter: blur(10px);
position: relative;
}
.video-info::before {
content: '🎬';
position: absolute;
top: 24px;
right: 24px;
font-size: 32px;
opacity: 0.15;
}
.video-title {
margin-bottom: 10px !important;
color: var(--ui-color-text-0);
font-size: 20px !important;
font-weight: 600 !important;
background: linear-gradient(135deg, #1a1a2e, #374151);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.video-description {
margin-bottom: 18px;
line-height: 1.7;
color: var(--ui-color-text-1);
}
.video-meta {
display: flex;
gap: 24px;
flex-wrap: wrap;
}
.video-meta-item {
display: flex;
align-items: center;
gap: 8px;
color: var(--ui-color-text-2);
font-size: 13px;
padding: 6px 14px;
background: color-mix(in srgb, var(--brand-primary) 6%, transparent);
border-radius: 20px;
transition: all 0.3s ease;
}
.video-meta-item:hover {
background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
transform: translateY(-1px);
}
/* ===== 视频列表 ===== */
.video-list-section {
width: 100%;
position: relative;
}
.video-list-title {
margin-bottom: 20px !important;
padding-left: 8px;
display: flex;
align-items: center;
gap: 10px;
font-size: 18px !important;
}
.video-list-title::before {
content: '';
width: 4px;
height: 20px;
background: linear-gradient(
135deg,
var(--brand-primary),
var(--brand-gradient-via)
);
border-radius: 2px;
}
.video-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 18px;
}
.video-list-item {
display: flex;
gap: 16px;
padding: 16px;
background: linear-gradient(
135deg,
rgba(255, 255, 255, 0.9),
rgba(255, 255, 255, 0.7)
);
backdrop-filter: blur(10px);
border: 2px solid color-mix(in srgb, var(--brand-primary) 10%, transparent);
border-radius: 18px;
cursor: pointer;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
overflow: hidden;
}
/* 列表项悬停装饰 */
.video-list-item::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 100%;
background: linear-gradient(
135deg,
var(--brand-primary),
var(--brand-gradient-via)
);
transform: scaleY(0);
transition: transform 0.3s ease;
border-radius: 0 4px 4px 0;
}
.video-list-item:hover::before {
transform: scaleY(1);
}
.video-list-item:hover {
background: linear-gradient(
135deg,
rgba(255, 255, 255, 0.95),
rgba(249, 250, 251, 0.9)
);
border-color: color-mix(in srgb, var(--brand-primary) 25%, transparent);
transform: translateY(-4px) translateX(4px);
box-shadow:
0 12px 32px color-mix(in srgb, var(--brand-primary) 12%, transparent),
0 4px 12px rgba(0, 0, 0, 0.06);
}
.video-list-item.active {
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 12%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 8%, transparent)
);
border-color: color-mix(in srgb, var(--brand-primary) 40%, transparent);
box-shadow:
0 8px 24px color-mix(in srgb, var(--brand-primary) 20%, transparent),
inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.video-list-item.active::before {
transform: scaleY(1);
background: linear-gradient(135deg, var(--brand-primary), #ec4899);
}
/* 正在播放标识 */
.video-list-item.active::after {
content: '▶';
position: absolute;
top: 8px;
right: 8px;
width: 24px;
height: 24px;
background: linear-gradient(
135deg,
var(--brand-primary),
var(--brand-gradient-via)
);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
color: white;
animation: playingPulse 1.5s ease-in-out infinite;
}
@keyframes playingPulse {
0%,
100% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.1);
opacity: 0.8;
}
}
.video-list-thumbnail {
position: relative;
width: 110px;
height: 66px;
flex-shrink: 0;
padding: 56px 24px;
border: 1px solid var(--tt-border);
border-radius: 12px;
overflow: hidden;
background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
background: var(--tt-surface);
text-align: center;
}
.video-list-thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.4s ease;
}
.video-list-item:hover .video-list-thumbnail img {
transform: scale(1.08);
}
.video-thumbnail-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: rgba(255, 255, 255, 0.4);
font-size: 24px;
}
.video-list-index {
position: absolute;
top: 6px;
left: 6px;
width: 22px;
height: 22px;
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 90%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 90%, transparent)
);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 11px;
font-weight: 700;
color: white;
box-shadow: 0 2px 8px
color-mix(in srgb, var(--brand-primary) 40%, transparent);
}
.video-list-duration {
position: absolute;
bottom: 6px;
right: 6px;
padding: 3px 8px;
background: rgba(0, 0, 0, 0.85);
border-radius: 6px;
font-size: 11px;
font-weight: 500;
color: white;
letter-spacing: 0.5px;
}
.video-list-info {
flex: 1;
min-width: 0;
.video-error {
display: flex;
flex-direction: column;
justify-content: center;
gap: 6px;
align-items: center;
gap: 12px;
padding: 24px;
text-align: center;
}
.video-list-name {
line-height: 1.5;
font-weight: 600 !important;
color: var(--ui-color-text-0) !important;
transition: color 0.3s ease;
}
.video-list-item:hover .video-list-name {
color: var(--brand-primary) !important;
}
.video-list-item.active .video-list-name {
color: var(--brand-primary) !important;
}
.video-list-desc {
line-height: 1.4;
font-size: 12px;
}
/* ===== 提示卡片 ===== */
.video-tips {
margin-top: 8px;
}
.video-tips-card {
border-radius: 20px !important;
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 6%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 6%, transparent),
rgba(236, 72, 153, 0.04)
) !important;
border: 2px solid color-mix(in srgb, var(--brand-primary) 15%, transparent) !important;
position: relative;
overflow: hidden;
transition: all 0.3s ease;
}
.video-tips-card:hover {
border-color: color-mix(
in srgb,
var(--brand-primary) 25%,
transparent
) !important;
transform: translateY(-2px);
box-shadow: 0 8px 24px
color-mix(in srgb, var(--brand-primary) 10%, transparent);
}
.video-tips-card::before {
content: '';
position: absolute;
top: -50%;
right: -10%;
width: 200px;
height: 200px;
background: radial-gradient(
circle,
color-mix(in srgb, var(--brand-primary) 8%, transparent) 0%,
transparent 70%
);
pointer-events: none;
}
.video-tips-content {
display: flex;
align-items: flex-start;
gap: 18px;
position: relative;
z-index: 1;
}
.video-tips-icon {
font-size: 32px;
line-height: 1;
animation: tipBounce 2s ease-in-out infinite;
}
@keyframes tipBounce {
0%,
100% {
transform: translateY(0);
@media (max-width: 1000px) {
.tutorial-container .video-tutorial {
grid-template-columns: minmax(0, 1fr);
}
50% {
transform: translateY(-4px);
}
}
.video-tips-content strong {
color: var(--brand-primary);
font-size: 15px;
}
/* ===== 响应式 ===== */
@media (max-width: 768px) {
.video-tutorial::before,
.video-tutorial::after {
display: none;
}
.video-list {
grid-template-columns: 1fr;
gap: 12px;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.video-list-item {
padding: 14px;
border-radius: 14px;
}
@media (max-width: 600px) {
.video-list {
grid-template-columns: minmax(0, 1fr);
}
.video-list-thumbnail {
width: 90px;
height: 54px;
border-radius: 10px;
}
.video-info {
padding: 20px;
padding: 16px;
}
.video-info::before {
display: none;
.video-info h4.ant-typography {
font-size: 18px;
}
.video-title {
font-size: 17px !important;
}
.video-player-card {
border-radius: 18px !important;
}
.video-tips-content {
gap: 14px;
}
.video-tips-icon {
font-size: 26px;
.video-tutorial-loading,
.video-tutorial-empty {
padding: 40px 16px;
}
}
/* ===== 深色模式 ===== */
html.dark .video-tutorial-loading,
html.dark .video-tutorial-empty {
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 5%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 5%, transparent)
);
border-color: color-mix(in srgb, var(--brand-primary) 15%, transparent);
}
html.dark .video-player-card {
background: var(--ui-color-bg-1);
border-color: color-mix(
in srgb,
var(--brand-primary) 20%,
transparent
) !important;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
html.dark .video-info {
background: linear-gradient(
135deg,
rgba(30, 30, 40, 0.8),
rgba(25, 25, 35, 0.6)
);
}
html.dark .video-title {
background: linear-gradient(135deg, #e5e7eb, #d1d5db);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
html.dark .video-meta-item {
background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
html.dark .video-meta-item:hover {
background: color-mix(in srgb, var(--brand-primary) 20%, transparent);
}
html.dark .video-list-item {
background: linear-gradient(
135deg,
rgba(30, 30, 40, 0.9),
rgba(25, 25, 35, 0.7)
);
border-color: color-mix(in srgb, var(--brand-primary) 15%, transparent);
}
html.dark .video-list-item:hover {
background: linear-gradient(
135deg,
rgba(40, 40, 55, 0.9),
rgba(35, 35, 50, 0.8)
);
border-color: color-mix(in srgb, var(--brand-primary) 30%, transparent);
box-shadow:
0 12px 32px rgba(0, 0, 0, 0.3),
0 4px 12px rgba(0, 0, 0, 0.2);
}
html.dark .video-list-item.active {
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 18%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 15%, transparent)
);
border-color: color-mix(in srgb, var(--brand-primary) 40%, transparent);
}
html.dark .video-tips-card {
background: linear-gradient(
135deg,
color-mix(in srgb, var(--brand-primary) 10%, transparent),
color-mix(in srgb, var(--brand-gradient-via) 10%, transparent)
) !important;
border-color: color-mix(
in srgb,
var(--brand-primary) 25%,
transparent
) !important;
}
html.dark .video-tips-content strong {
color: var(--brand-gradient-from);
}
+16 -12
View File
@@ -21,7 +21,8 @@ import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useState, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { Typography, Card, Empty, Spin, Toast } from '@/components/ui';
import { Typography, Card, Spin, Toast } from '@/components/ui';
import { Button, Empty } from 'antd';
import { IconPlayCircle, IconClock, IconFile } from '@/components/ui/icons';
import { API } from '../../../helpers';
import './VideoTutorial.css';
@@ -114,14 +115,15 @@ const VideoTutorial = () => {
return (
<div className='video-tutorial-empty'>
<Empty
image={
<IconPlayCircle
size='extra-large'
style={{ fontSize: 64, color: 'var(--ui-color-text-3)' }}
/>
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={
<>
<Title heading={5}>{t('暂无视频教程')}</Title>
<Paragraph type='secondary'>
{t('管理员还没有上传视频教程,请查看图文教程')}
</Paragraph>
</>
}
title={t('暂无视频教程')}
description={t('管理员还没有上传视频教程,请查看图文教程')}
/>
</div>
);
@@ -139,12 +141,12 @@ const VideoTutorial = () => {
<div className='video-error'>
<IconPlayCircle size='extra-large' />
<Text type='danger'>{t('视频加载失败')}</Text>
<button
<Button
className='video-retry-btn'
onClick={refreshVideoUrl}
>
{t('点击重试')}
</button>
</Button>
</div>
) : (
<video
@@ -200,9 +202,11 @@ const VideoTutorial = () => {
</Title>
<div className='video-list'>
{videos.map((video, index) => (
<div
<button
type='button'
key={video.id}
className={`video-list-item ${currentVideo?.id === video.id ? 'active' : ''}`}
aria-pressed={currentVideo?.id === video.id}
onClick={() => handleSelectVideo(video)}
>
<div className='video-list-thumbnail'>
@@ -239,7 +243,7 @@ const VideoTutorial = () => {
</Text>
)}
</div>
</div>
</button>
))}
</div>
</div>
+63 -74
View File
@@ -19,9 +19,11 @@ For commercial licensing, please contact support@quantumnous.com
import { Trans } from 'react-i18next';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import React, { useState, useContext, useRef } from 'react';
import React, { useState, useContext, useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
import { Button as AntButton, Tooltip } from 'antd';
import { X as ActionClose } from '@/components/common/icons/ActionIcons';
import {
Typography,
Button,
@@ -40,7 +42,6 @@ import {
IconCode,
IconSend,
IconSearch,
IconClose,
IconVideo,
IconArticle,
} from '@/components/ui/icons';
@@ -62,6 +63,35 @@ const Tutorial = () => {
const [activeOS, setActiveOS] = useState('windows');
const [activeTutorialTab, setActiveTutorialTab] = useState('video'); // 默认视频教程
const scrollContainerRef = useRef(null);
const [activeStep, setActiveStep] = useState(0);
useEffect(() => {
if (activeTutorialTab !== 'steps') return;
const sections = scrollContainerRef.current?.querySelectorAll(
'.tutorial-step-section',
);
if (!sections?.length) return;
let frame;
// Capture scrolling from the shared layout as well as the document.
const update = () => {
cancelAnimationFrame(frame);
frame = requestAnimationFrame(() => {
let current = 0;
sections.forEach((section, index) => {
if (section.getBoundingClientRect().top <= 200) current = index;
});
setActiveStep(current);
});
};
update();
document.addEventListener('scroll', update, true);
window.addEventListener('resize', update);
return () => {
cancelAnimationFrame(frame);
document.removeEventListener('scroll', update, true);
window.removeEventListener('resize', update);
};
}, [activeTutorialTab]);
// 处理关闭教程
const handleClose = () => {
@@ -86,31 +116,26 @@ const Tutorial = () => {
key: 'create-key',
title: t('创建密钥'),
icon: <IconKey />,
color: 'var(--brand-gradient-via)',
},
{
key: 'view-models',
title: t('查看可用模型'),
icon: <IconSearch />,
color: 'var(--brand-gradient-to)',
},
{
key: 'recharge',
title: t('充值'),
icon: <IconCreditCard />,
color: 'var(--brand-primary)',
},
{
key: 'install-client',
title: t('安装客户端'),
icon: <IconCode />,
color: 'var(--brand-gradient-from)',
},
{
key: 'start-journey',
title: t('开启之旅'),
icon: <IconSend />,
color: 'var(--brand-primary-hover)',
},
];
@@ -153,13 +178,7 @@ const Tutorial = () => {
const createKeyStep = (
<div className='tutorial-step-content'>
<div className='tutorial-step-header'>
<div
className='tutorial-step-icon'
style={{
background:
'linear-gradient(135deg, var(--brand-gradient-via), var(--brand-gradient-to))',
}}
>
<div className='tutorial-step-icon'>
<IconKey size='large' />
</div>
<div>
@@ -240,13 +259,7 @@ const Tutorial = () => {
const viewModelsStep = (
<div className='tutorial-step-content'>
<div className='tutorial-step-header'>
<div
className='tutorial-step-icon'
style={{
background:
'linear-gradient(135deg, var(--brand-gradient-to), var(--brand-primary-hover))',
}}
>
<div className='tutorial-step-icon'>
<IconSearch size='large' />
</div>
<div>
@@ -321,13 +334,7 @@ const Tutorial = () => {
const rechargeStep = (
<div className='tutorial-step-content'>
<div className='tutorial-step-header'>
<div
className='tutorial-step-icon'
style={{
background:
'linear-gradient(135deg, var(--brand-primary), var(--brand-gradient-via))',
}}
>
<div className='tutorial-step-icon'>
<IconCreditCard size='large' />
</div>
<div>
@@ -407,13 +414,7 @@ const Tutorial = () => {
const installClientStep = (
<div className='tutorial-step-content'>
<div className='tutorial-step-header'>
<div
className='tutorial-step-icon'
style={{
background:
'linear-gradient(135deg, var(--brand-gradient-from), var(--brand-gradient-via))',
}}
>
<div className='tutorial-step-icon'>
<IconCode size='large' />
</div>
<div>
@@ -561,13 +562,7 @@ source ~/.bashrc`,
const startJourneyStep = (
<div className='tutorial-step-content'>
<div className='tutorial-step-header'>
<div
className='tutorial-step-icon'
style={{
background:
'linear-gradient(135deg, var(--brand-primary-hover), var(--brand-primary))',
}}
>
<div className='tutorial-step-icon'>
<IconSend size='large' />
</div>
<div>
@@ -686,27 +681,22 @@ source ~/.bashrc`,
{
component: createKeyStep,
title: t('创建密钥'),
color: 'var(--brand-gradient-via)',
},
{
component: viewModelsStep,
title: t('查看可用模型'),
color: 'var(--brand-gradient-to)',
},
{
component: rechargeStep,
title: t('充值'),
color: 'var(--brand-primary)',
},
{
component: installClientStep,
title: t('安装客户端'),
color: 'var(--brand-gradient-from)',
},
{
component: startJourneyStep,
title: t('开启之旅'),
color: 'var(--brand-primary-hover)',
},
];
@@ -724,14 +714,15 @@ source ~/.bashrc`,
const stepsTutorial = (
<div className='tutorial-scroll-wrapper'>
{/* 顶部快速导航 */}
<div className='tutorial-quick-nav'>
<nav className='tutorial-quick-nav' aria-label={t('图文教程')}>
<div className='tutorial-directory-title'>{t('快速上手')}</div>
<div className='tutorial-quick-nav-inner'>
{visibleSteps.map((step, index) => (
<a
key={step.key}
href={`#tutorial-step-${index}`}
className='tutorial-quick-nav-item'
style={{ '--step-color': step.color }}
className={`tutorial-quick-nav-item${activeStep === index ? ' active' : ''}`}
aria-current={activeStep === index ? 'step' : undefined}
onClick={(e) => {
e.preventDefault();
const element = document.getElementById(
@@ -739,9 +730,15 @@ source ~/.bashrc`,
);
if (element && scrollContainerRef.current) {
element.scrollIntoView({
behavior: 'smooth',
behavior: window.matchMedia(
'(prefers-reduced-motion: reduce)',
).matches
? 'instant'
: 'smooth',
block: 'start',
});
element.focus({ preventScroll: true });
setActiveStep(index);
}
}}
>
@@ -754,29 +751,26 @@ source ~/.bashrc`,
<span className='tutorial-scroll-hint-icon'>↓</span>
<span>{t('向下滚动查看所有步骤')}</span>
</div>
</div>
</nav>
{/* 可滚动的内容区域 */}
<div className='tutorial-scroll-container' ref={scrollContainerRef}>
<div className='tutorial-all-steps'>
{visibleStepComponents.map((step, index) => (
<div
<section
key={`step-wrapper-${index}`}
id={`tutorial-step-${index}`}
className='tutorial-step-section'
aria-label={step.title}
tabIndex={-1}
>
<div className='tutorial-step-divider'>
<div
className='tutorial-step-badge'
style={{
background: `linear-gradient(135deg, ${step.color}, color-mix(in srgb, ${step.color} 85%, transparent))`,
}}
>
<div className='tutorial-step-badge'>
{step.number} / {allStepComponents.length}
</div>
</div>
{step.component}
</div>
</section>
))}
</div>
@@ -814,20 +808,15 @@ source ~/.bashrc`,
{t('5 分钟快速上手,开启您的 AI 之旅')}
</Paragraph>
</div>
<Button
type='tertiary'
theme='borderless'
icon={<IconClose />}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
handleClose();
}}
className='tutorial-close-btn'
size='large'
>
{t('关闭教程')}
</Button>
<Tooltip title={t('关闭教程')}>
<AntButton
type='text'
icon={<ActionClose size={16} aria-hidden />}
aria-label={t('关闭教程')}
onClick={handleClose}
className='tutorial-close-btn'
/>
</Tooltip>
</div>
{/* 教程类型切换 Tab */}
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -23,6 +23,7 @@ import {
Copy as ActionCopy,
Link as ActionLink,
} from '@/components/common/icons/ActionIcons';
import { formatPercent } from '../../helpers/safeDisplay';
import React, { useState, useEffect, useContext, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -327,7 +328,7 @@ const Invite = () => {
title: t('返佣比例'),
dataIndex: 'rebate_rate',
key: 'rebate_rate',
render: (text) => `${((text || 0) * 100).toFixed(0)}%`,
render: (text) => formatPercent((Number(text) || 0) * 100, 0),
},
{
title: t('模型'),
@@ -429,7 +430,7 @@ const Invite = () => {
{item.label === t('\u9080\u8bf7\u4eba\u6570') &&
stats.rebate_rate > 0 && (
<span className='rounded-full bg-amber-50 px-2.5 py-1 text-xs font-semibold text-amber-700 dark:bg-amber-500/[0.10] dark:text-amber-300'>
{(stats.rebate_rate * 100).toFixed(0)}%
{formatPercent((Number(stats.rebate_rate) || 0) * 100, 0)}
</span>
)}
</div>
+1 -1
View File
@@ -77,7 +77,7 @@ html.dark .usage-record-page {
);
--ur-pending-text: var(--ui-color-warning);
/* 在线原型深色:使用记录页签(选中文字与下划线)用品牌色 #f2ad41,其余主色为 #d1963a */
--ur-tab-accent: #f2ad41;
--ur-tab-accent: var(--brand-accent);
}
/* 页签:纯文字,主色 2px 下划线,页签间距 28px */
+28 -33
View File
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { TableRowActions } from '@/components/common/table/TableToolbar';
import { useTranslation } from 'react-i18next';
import TableEmpty from '../../components/common/table/TableEmpty';
import TableToolbar from '../../components/common/table/TableToolbar';
@@ -183,7 +184,32 @@ export default function InsightsPanel({ value, onChange, disabled, error }) {
const index = value.articles.findIndex((a) => a.id === item.id);
const move = (offset) => onChange(moveArticle(value, item.id, offset));
return (
<div className='website-insights-row-actions'>
<TableRowActions
items={[
{
key: 'up',
label: t('上移'),
title: sortable ? undefined : '请在全部分类且无搜索时调整顺序',
disabled: disabled || !sortable || index <= 0,
onClick: () => move(-1),
},
{
key: 'down',
label: t('下移'),
title: sortable ? undefined : '请在全部分类且无搜索时调整顺序',
disabled:
disabled || !sortable || index >= value.articles.length - 1,
onClick: () => move(1),
},
{
key: 'delete',
label: t('删除'),
danger: true,
disabled,
onClick: () => deleteArticle(item),
},
]}
>
<Button
type='link'
size='small'
@@ -194,38 +220,7 @@ export default function InsightsPanel({ value, onChange, disabled, error }) {
>
{t('编辑')}
</Button>
<Button
type='link'
size='small'
aria-label={`上移${item.title}`}
title={sortable ? undefined : '请在全部分类且无搜索时调整顺序'}
disabled={disabled || !sortable || index <= 0}
onClick={() => move(-1)}
>
{t('上移')}
</Button>
<Button
type='link'
size='small'
aria-label={`下移${item.title}`}
title={sortable ? undefined : '请在全部分类且无搜索时调整顺序'}
disabled={
disabled || !sortable || index >= value.articles.length - 1
}
onClick={() => move(1)}
>
{t('下移')}
</Button>
<Button
type='link'
size='small'
danger
disabled={disabled}
onClick={() => deleteArticle(item)}
>
{t('删除')}
</Button>
</div>
</TableRowActions>
);
},
},