feat: Merge branch 'ui-optimization' into weiyuan

This commit is contained in:
zhanjunhao
2026-11-20 10:21:27 +08:00
190 changed files with 5519 additions and 5693 deletions
+100 -71
View File
@@ -16,24 +16,25 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
formatCurrency,
formatNumber,
formatUserReference,
toFiniteNumber,
} 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 { 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,
@@ -43,7 +44,14 @@ import {
Spin,
Typography,
} from '@/components/ui';
import { Search } from 'lucide-react';
import {
Search,
Eye as ActionEye,
Check as ActionCheck,
X as ActionX,
Ban as ActionBan,
RotateCw as ActionRotateCw,
} from '@/components/common/icons/ActionIcons';
import { API, showError, showSuccess } from '../../helpers';
import {
INVOICE_STATUS,
@@ -63,6 +71,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 +127,13 @@ const AdminInvoice = () => {
setSearchKeyword(keyword);
};
const handleReset = () => {
setPage(1);
setKeyword('');
setSearchKeyword('');
setStatusFilter('');
};
const handleStatusFilterChange = (value) => {
setPage(1);
setStatusFilter(value || '');
@@ -258,7 +274,7 @@ const AdminInvoice = () => {
displayName ||
username || (
<span className='text-gray-400'>
{t('用户 #{{id}}', { id: record.user_id })}
{formatUserReference(null, record.user_id)}
</span>
)
);
@@ -281,7 +297,7 @@ const AdminInvoice = () => {
title: t('金额'),
dataIndex: 'amount',
width: 90,
render: (v) => `¥${Number(v).toFixed(2)}`,
render: (v) => formatCurrency(v),
},
{
title: t('状态'),
@@ -301,6 +317,7 @@ const AdminInvoice = () => {
},
{
title: t('操作'),
key: 'actions',
width: 200,
fixed: 'right',
render: (_, record) => (
@@ -379,60 +396,63 @@ const AdminInvoice = () => {
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}
/>
</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 +530,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>
@@ -524,7 +547,7 @@ const AdminInvoice = () => {
<div>
<Text className='text-gray-400 text-sm'>{t('开票金额')}</Text>
<div className='font-bold text-amber-600'>
¥{Number(detailData.amount).toFixed(2)}
{formatCurrency(detailData.amount)}
</div>
</div>
<div>
@@ -582,16 +605,22 @@ const AdminInvoice = () => {
i18nKey='关联充值记录 ({{length}} 笔,合计 ¥{{value}})'
values={{
length: detailData.topup_list.length,
value: detailData.topup_list
.reduce((s, item) => s + (item.money || 0), 0)
.toFixed(2),
value: formatNumber(
detailData.topup_list.reduce(
(sum, item) =>
sum + (toFiniteNumber(item.money) ?? 0),
0,
),
2,
'0.00',
),
}}
/>
</Text>
<Table
<ConsoleListTable
dataSource={detailData.topup_list}
rowKey='id'
pagination={false}
pagination={{ pageSize: 10 }}
size='small'
columns={[
{ title: 'ID', dataIndex: 'id', width: 60 },
@@ -611,7 +640,7 @@ const AdminInvoice = () => {
title: t('金额'),
dataIndex: 'money',
width: 90,
render: (v) => `¥${Number(v).toFixed(2)}`,
render: (v) => formatCurrency(v),
},
]}
/>
+4 -3
View File
@@ -43,6 +43,7 @@ import {
import { API } from '../../helpers/api';
import { showError, copy } from '../../helpers';
import { renderQuota } from '../../helpers/render';
import { formatCurrency, toFiniteNumber } from '../../helpers/safeDisplay';
const paymentMethodMap = {
wechat: '微信',
@@ -72,8 +73,8 @@ const payPalSettlementStateMap = {
};
const formatUSDMinor = (value) => {
if (value === null || value === undefined) return '-';
return `$${(Number(value) / 100).toFixed(2)}`;
const minor = toFiniteNumber(value);
return minor === null ? '-' : formatCurrency(minor / 100, '$');
};
import { Descriptions } from 'antd';
@@ -298,7 +299,7 @@ const AdminOrder = () => {
title: t('支付金额'),
dataIndex: 'money',
width: 90,
render: (v) => (v ? `¥${Number(v).toFixed(2)}` : '-'),
render: (v) => (v ? formatCurrency(v) : '-'),
},
{
title: t('支付方式'),
+2
View File
@@ -852,7 +852,9 @@ const AdminOrganizations = () => {
},
{
title: t('操作'),
key: 'actions',
width: 380,
fixed: 'right',
render: (_, record) => (
<div className='console-module-row-actions'>
{isAdmin() && (
+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>
))}
+8 -2
View File
@@ -33,6 +33,7 @@ export default function LatestTierPanel({
columns,
onExport,
refreshToken,
toolbarActions,
}) {
const { t } = useTranslation();
const generation = useRef(0);
@@ -42,7 +43,7 @@ export default function LatestTierPanel({
const activeContext = useRef(context);
activeContext.current = context;
const exportRequest = useRef(null);
const [query, setQuery] = useState({ status: 'all', page: 1 });
const [query, setQuery] = useState({ status: 'all', page: 1, pageSize: 10 });
const [state, setState] = useState({
items: [],
total: 0,
@@ -142,16 +143,21 @@ export default function LatestTierPanel({
partners={[]}
searchableText={() => ''}
onExport={exportAll}
toolbarActions={toolbarActions}
server={{
...visible,
page: query.page,
pageSize: query.pageSize,
exporting,
onChange: (next) => {
generation.current++;
exportRequest.current = null;
setExporting(false);
setState((old) => ({ ...old, items: [], busy: true, error: '' }));
setQuery(next);
setQuery((current) => ({
...next,
pageSize: next.pageSize ?? current.pageSize,
}));
},
}}
/>
+116 -120
View File
@@ -21,13 +21,13 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Empty, Input, Select } from 'antd';
import { Table } from '@/components/ui';
import { Search } from '@/components/common/icons/ActionIcons';
import { Download, Search } from '@/components/common/icons/ActionIcons';
import {
ConsoleCard,
ConsoleSearchBar,
ConsoleSearchActions,
ConsoleFilterGrid,
ConsoleTabs,
} from '../../components/console/ConsolePrimitives';
import { ConsoleCollectionSearch } from '../../components/console/ConsoleCollection';
import { filterCommissionRows, matchesStatus } from './listFilters';
export default function ListPanel({
@@ -37,6 +37,7 @@ export default function ListPanel({
partners,
searchableText,
onExport,
toolbarActions,
context,
server,
}) {
@@ -46,6 +47,7 @@ export default function ListPanel({
const [scopedIds, setScopedIds] = useState(context?.ids || null);
const [status, setStatus] = useState('all');
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const set = (key, value) =>
setDraft((current) => ({ ...current, [key]: value }));
const tabSets = {
@@ -130,7 +132,6 @@ export default function ListPanel({
setScopedIds(null);
setPage(1);
};
const [filtersOpen, setFiltersOpen] = useState(false);
return (
<div className={`commission-list commission-list--${section}`}>
{tabSets[section] && (
@@ -175,124 +176,107 @@ export default function ListPanel({
</Button>
</div>
)}
<Button
className='commission-filter-toggle'
aria-expanded={filtersOpen}
onClick={() => setFiltersOpen((value) => !value)}
>
{t(filtersOpen ? '隐藏操作项' : '显示操作项')}
</Button>
<ConsoleSearchBar
className={`commission-filter-card${filtersOpen ? ' is-open' : ''}`}
>
<form
onSubmit={(event) => {
event.preventDefault();
query();
}}
<ConsoleCollectionSearch className='commission-filter-card'>
<ConsoleFilterGrid
onReset={reset}
onSearch={query}
loading={server?.busy}
>
<div className='console-search-fields'>
<label className='console-search-field commission-search-field'>
<span>{t('搜索')}</span>
<Input
prefix={<Search size={16} aria-hidden />}
value={draft.query}
onChange={(event) => set('query', event.target.value)}
allowClear
placeholder={t(placeholders[section])}
aria-label={t(placeholders[section])}
/>
</label>
{typeOptions && (
<label className='console-search-field commission-search-field'>
<span>{t('搜索')}</span>
<Input
prefix={<Search size={16} aria-hidden />}
value={draft.query}
onChange={(event) => set('query', event.target.value)}
allowClear
placeholder={t(placeholders[section])}
aria-label={t(placeholders[section])}
<span>{t('类型筛选')}</span>
<Select
aria-label={t('类型筛选')}
value={draft.type}
onChange={(value) => set('type', value)}
options={[
{
value: '',
label: t(
section === 'assignments'
? '全部客户类型'
: section === 'tiers'
? '全部来源'
: '全部类型',
),
},
...typeOptions.map(([value, label]) => ({
value,
label: t(label),
})),
]}
/>
</label>
{typeOptions && (
<label className='console-search-field commission-search-field'>
<span>{t('类型筛选')}</span>
<Select
aria-label={t('类型筛选')}
value={draft.type}
onChange={(value) => set('type', value)}
options={[
{
value: '',
label: t(
section === 'assignments'
? '全部客户类型'
: section === 'tiers'
? '全部来源'
: '全部类型',
),
},
...typeOptions.map(([value, label]) => ({
value,
label: t(label),
})),
]}
/>
</label>
)}
{section === 'partners' && (
<label className='console-search-field commission-search-field'>
<span>{t('状态筛选')}</span>
<Select
aria-label={t('状态筛选')}
value={draft.status || ''}
onChange={(value) => set('status', value)}
options={[
'',
'draft',
'active',
'suspended',
'terminated',
].map((value, i) => ({
)}
{section === 'partners' && (
<label className='console-search-field commission-search-field'>
<span>{t('状态筛选')}</span>
<Select
aria-label={t('状态筛选')}
value={draft.status || ''}
onChange={(value) => set('status', value)}
options={['', 'draft', 'active', 'suspended', 'terminated'].map(
(value, i) => ({
value,
label: t(
['全部状态', '草稿', '生效中', '已暂停', '已终止'][i],
),
}))}
/>
</label>
)}
{['assignments', 'bills', 'adjustments'].includes(section) && (
<label className='console-search-field commission-search-field'>
<span>{t('合作伙伴筛选')}</span>
<Select
aria-label={t('合作伙伴筛选')}
showSearch={{ optionFilterProp: 'label' }}
value={draft.partner}
onChange={(value) => set('partner', value)}
options={[
{ value: '', label: t('全部合作伙伴') },
...partners.map((row) => ({
value: row.id,
label: row.name,
})),
]}
/>
</label>
)}
</div>
<ConsoleSearchActions
onReset={reset}
searchLabel='查询'
loading={server?.busy}
/>
</form>
</ConsoleSearchBar>
}),
)}
/>
</label>
)}
{['assignments', 'bills', 'adjustments'].includes(section) && (
<label className='console-search-field commission-search-field'>
<span>{t('合作伙伴筛选')}</span>
<Select
aria-label={t('合作伙伴筛选')}
showSearch={{ optionFilterProp: 'label' }}
value={draft.partner}
onChange={(value) => set('partner', value)}
options={[
{ value: '', label: t('全部合作伙伴') },
...partners.map((row) => ({
value: row.id,
label: row.name,
})),
]}
/>
</label>
)}
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<ConsoleCard className='commission-card commission-list-card'>
<div className='commission-filter-end'>
<div className='console-list-tools commission-filter-end'>
<span>
{t('共 {{count}} 条', {
count: server ? server.total : filtered.length,
})}
</span>
{onExport && (
<Button
loading={server?.exporting}
disabled={!!server?.busy}
onClick={() => onExport(filtered)}
>
{t('导出')}
</Button>
)}
<div className='console-list-tool-actions'>
{onExport && (
<Button
icon={<Download size={16} />}
loading={server?.exporting}
disabled={!!server?.busy}
onClick={() => onExport(filtered)}
>
{t('导出')}
</Button>
)}
{toolbarActions}
</div>
</div>
<Table
rowKey='id'
@@ -309,18 +293,30 @@ export default function ListPanel({
dataSource={filtered}
size='middle'
scroll={{ x: 'max-content' }}
pagination={{
size: 'small',
pageSize: server ? 100 : 10,
total: server ? server.total : filtered.length,
current: server ? server.page : page,
onChange: (next) => {
setPage(next);
server?.onChange({ ...filters, status, page: next });
},
showSizeChanger: false,
showTotal: (total) => t('共 {{total}} 条', { total }),
}}
pagination={
(server ? server.total : filtered.length)
? {
size: 'small',
pageSize: server ? server.pageSize : pageSize,
total: server ? server.total : filtered.length,
currentPage: server ? server.page : page,
onPageChange: (next) => {
setPage(next);
server?.onChange({ ...filters, status, page: next });
},
onPageSizeChange: (nextSize) => {
setPage(1);
setPageSize(nextSize);
server?.onChange({
...filters,
status,
page: 1,
pageSize: nextSize,
});
},
}
: false
}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
+5 -3
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],
@@ -145,12 +147,12 @@ export default function PartnerDetail({
dataSource={assignments.filter(
(item) => item.partner_id === row.id,
)}
pagination={{ pageSize: 5, size: 'small' }}
pagination={{ pageSize: 10 }}
columns={[
{
title: t('客户'),
render: (_, item) =>
item.customer_name || `#${item.subject_id}`,
item.customer_name || formatIdReference(item.subject_id),
},
{
title: t('类型'),
+252 -137
View File
@@ -16,7 +16,13 @@ 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 { ConsoleCollectionSearch } from '@/components/console/ConsoleCollection';
import {
ConsoleFilterField,
ConsoleFilterGrid,
} from '@/components/console/ConsolePrimitives';
import React, {
useCallback,
useEffect,
@@ -42,6 +48,8 @@ import {
} from '@/components/ui';
import {
ArrowLeft as ActionArrowLeft,
Download,
Search,
RefreshCw as ActionRefresh,
} from '@/components/common/icons/ActionIcons';
import {
@@ -146,6 +154,9 @@ export default function PartnerPortal({
const [customerStatus, setCustomerStatus] = useState('all');
const [billMonth, setBillMonth] = useState('all');
const [billStatus, setBillStatus] = useState('all');
const [billPage, setBillPage] = useState(1);
const [customerPage, setCustomerPage] = useState(1);
const [detailPage, setDetailPage] = useState(1);
const loadVersion = useRef(0);
const detailVersion = useRef(0);
const selectedId = useRef(null);
@@ -250,6 +261,7 @@ export default function PartnerPortal({
setDetailLoading(true);
setError('');
setQuery('');
setDetailPage(1);
setAction(null);
setReason('');
setActionError('');
@@ -540,43 +552,85 @@ export default function PartnerPortal({
},
];
const refreshButton = (
<Button
icon={<ActionRefresh size={16} />}
disabled={mutationLoading || detailLoading}
loading={loading}
onClick={() => {
load();
if (selected) open(selected);
}}
>
{t('刷新')}
</Button>
);
const renderBills = () => (
<>
<ConsoleCollectionSearch>
<ConsoleFilterGrid
onReset={() => {
setBillMonth('all');
setBillStatus('all');
setBillPage(1);
}}
onSearch={() => setBillPage(1)}
>
<ConsoleFilterField label={t('账期')} id='partner-bill-month'>
<Select
id='partner-bill-month'
value={billMonth}
onChange={(value) => {
setBillMonth(value);
setBillPage(1);
}}
optionList={[
{ value: 'all', label: t('全部账期') },
...Array.from(new Set(rows.map((row) => row.statement_month)))
.sort()
.reverse()
.map((value) => ({ value, label: value })),
]}
/>
</ConsoleFilterField>
<ConsoleFilterField label={t('状态')} id='partner-bill-status'>
<Select
id='partner-bill-status'
value={billStatus}
onChange={(value) => {
setBillStatus(value);
setBillPage(1);
}}
optionList={[
{ value: 'all', label: t('全部状态') },
...Array.from(new Set(rows.map((row) => row.status))).map(
(value) => ({
value,
label: commissionLabel(t, 'status', value),
}),
),
]}
/>
</ConsoleFilterField>
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<Card className='commission-card partner-portal-card'>
<div className='partner-portal-filters'>
<Select
value={billMonth}
onChange={setBillMonth}
optionList={[
{ value: 'all', label: t('全部账期') },
...Array.from(new Set(rows.map((row) => row.statement_month)))
.sort()
.reverse()
.map((value) => ({ value, label: value })),
]}
/>
<Select
value={billStatus}
onChange={setBillStatus}
optionList={[
{ value: 'all', label: t('全部状态') },
...Array.from(new Set(rows.map((row) => row.status))).map(
(value) => ({
value,
label: commissionLabel(t, 'status', value),
}),
),
]}
/>
<div className='console-list-tools commission-filter-end'>
<Text type='secondary'>
{t('共 {{count}} 张账单', { count: visibleBills.length })}
</Text>
<div className='console-list-tool-actions'>{refreshButton}</div>
</div>
<Table
rowKey='id'
dataSource={visibleBills}
columns={billColumns}
pagination={visibleBills.length > 0 ? { pageSize: 10 } : false}
pagination={
visibleBills.length > 0
? { pageSize: 10, current: billPage, onChange: setBillPage }
: false
}
scroll={{ x: 1120 }}
empty={
<Empty
@@ -699,19 +753,46 @@ export default function PartnerPortal({
<Card className='commission-card partner-portal-card'>
<Tabs defaultActiveKey='usage' key={selected.id}>
<Tabs.TabPane tab={t('单笔消耗明细')} itemKey='usage'>
<Input
className='partner-portal-detail-search'
value={query}
onChange={setQuery}
placeholder={t('搜索客户、模型、计费记录或档位')}
showClear
/>
<ConsoleCollectionSearch>
<ConsoleFilterGrid
onReset={() => {
setQuery('');
setDetailPage(1);
}}
onSearch={() => setDetailPage(1)}
>
<ConsoleFilterField
label={t('搜索关键字')}
id='partner-bill-detail-query'
>
<Input
id='partner-bill-detail-query'
prefix={<Search size={16} />}
value={query}
onChange={(value) => {
setQuery(value);
setDetailPage(1);
}}
placeholder={t('搜索客户、模型、计费记录或档位')}
showClear
/>
</ConsoleFilterField>
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<Table
rowKey='id'
dataSource={detailItems}
columns={BillingColumns(t, money, formatDateTime)}
scroll={{ x: 1800 }}
pagination={detailItems.length > 0 ? { pageSize: 10 } : false}
pagination={
detailItems.length > 0
? {
pageSize: 10,
current: detailPage,
onChange: setDetailPage,
}
: false
}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
@@ -887,7 +968,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>
@@ -924,96 +1005,136 @@ export default function PartnerPortal({
);
const renderCustomers = () => (
<Card className='commission-card partner-portal-card'>
<Alert
showIcon
type='info'
description={t(
'仅展示本伙伴保护期及正式归属期间的信息。转移或终止后的客户消费不在可见范围内。',
)}
/>
<div className='partner-portal-filters'>
<Input
value={customerQuery}
onChange={setCustomerQuery}
showClear
placeholder={t('搜索客户名称或编号')}
<>
<Card className='commission-card partner-portal-card'>
<Alert
showIcon
type='info'
description={t(
'仅展示本伙伴保护期及正式归属期间的信息。转移或终止后的客户消费不在可见范围内。',
)}
/>
<Select
value={customerStatus}
onChange={setCustomerStatus}
optionList={[
{ value: 'all', label: t('全部状态') },
...Array.from(new Set(customers.map((row) => row.status))).map(
(value) => ({
value,
label: commissionLabel(t, 'status', value),
}),
),
</Card>
<ConsoleCollectionSearch>
<ConsoleFilterGrid
onReset={() => {
setCustomerQuery('');
setCustomerStatus('all');
setCustomerPage(1);
}}
onSearch={() => setCustomerPage(1)}
>
<ConsoleFilterField
label={t('搜索关键字')}
id='partner-customer-query'
>
<Input
id='partner-customer-query'
prefix={<Search size={16} />}
value={customerQuery}
onChange={(value) => {
setCustomerQuery(value);
setCustomerPage(1);
}}
showClear
placeholder={t('搜索客户名称或编号')}
/>
</ConsoleFilterField>
<ConsoleFilterField label={t('状态')} id='partner-customer-status'>
<Select
id='partner-customer-status'
value={customerStatus}
onChange={(value) => {
setCustomerStatus(value);
setCustomerPage(1);
}}
optionList={[
{ value: 'all', label: t('全部状态') },
...Array.from(new Set(customers.map((row) => row.status))).map(
(value) => ({
value,
label: commissionLabel(t, 'status', value),
}),
),
]}
/>
</ConsoleFilterField>
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<Card className='commission-card partner-portal-card'>
<div className='console-list-tools commission-filter-end'>
<Text type='secondary'>
{t('共 {{count}} 条归属记录', { count: visibleCustomers.length })}
</Text>
<div className='console-list-tool-actions'>{refreshButton}</div>
</div>
<Table
rowKey='id'
dataSource={visibleCustomers}
pagination={
visibleCustomers.length > 0
? {
pageSize: 10,
current: customerPage,
onChange: setCustomerPage,
}
: false
}
scroll={{ x: 1100 }}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={t('暂无客户')}
/>
}
columns={[
{
title: t('客户'),
render: (_, row) => (
<b>
{row.customer_name ||
row.subject_name ||
`${commissionLabel(t, 'subjectType', row.subject_type)} ${formatIdReference(row.subject_id)}`}
</b>
),
},
{
title: t('类型'),
dataIndex: 'subject_type',
render: (value) => commissionLabel(t, 'subjectType', value),
},
{ title: t('归属状态'), dataIndex: 'status', render: tag },
{
title: t('正式归属起点'),
dataIndex: 'formal_at',
render: formatDateTime,
},
{ title: t('保护期开始'), dataIndex: 'started_at', render: date },
{
title: t('保护期至'),
render: (_, row) => date(protectionUntil(row)),
},
{
title: t('保护期剩余天数'),
render: (_, row) =>
PROTECTED.includes(row.status)
? Math.max(
0,
Math.ceil(
(protectionUntil(row) - Date.now() / 1000) / 86400,
),
)
: '—',
},
{
title: t('归属结束'),
dataIndex: 'ended_at',
render: formatDateTime,
},
]}
/>
<Text type='secondary'>
{t('共 {{count}} 条归属记录', { count: visibleCustomers.length })}
</Text>
</div>
<Table
rowKey='id'
dataSource={visibleCustomers}
pagination={visibleCustomers.length > 0 ? { pageSize: 10 } : false}
scroll={{ x: 1100 }}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={t('暂无客户')}
/>
}
columns={[
{
title: t('客户'),
render: (_, row) => (
<b>
{row.customer_name ||
row.subject_name ||
`${commissionLabel(t, 'subjectType', row.subject_type)} #${row.subject_id}`}
</b>
),
},
{
title: t('类型'),
dataIndex: 'subject_type',
render: (value) => commissionLabel(t, 'subjectType', value),
},
{ title: t('归属状态'), dataIndex: 'status', render: tag },
{
title: t('正式归属起点'),
dataIndex: 'formal_at',
render: formatDateTime,
},
{ title: t('保护期开始'), dataIndex: 'started_at', render: date },
{
title: t('保护期至'),
render: (_, row) => date(protectionUntil(row)),
},
{
title: t('保护期剩余天数'),
render: (_, row) =>
PROTECTED.includes(row.status)
? Math.max(
0,
Math.ceil(
(protectionUntil(row) - Date.now() / 1000) / 86400,
),
)
: '—',
},
{
title: t('归属结束'),
dataIndex: 'ended_at',
render: formatDateTime,
},
]}
/>
</Card>
</Card>
</>
);
const renderEstimate = () => (
@@ -1057,7 +1178,7 @@ export default function PartnerPortal({
className='partner-portal-estimate-table'
rowKey='statement_month'
dataSource={realtime}
pagination={false}
pagination={realtime.length ? { pageSize: 10 } : false}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
@@ -1236,7 +1357,7 @@ export default function PartnerPortal({
title={t(pageTitle)}
subtitle={
selected ? (
`${t('账单号')} #${selected.id} · ${selected.statement_month}`
`${t('账单号')} ${formatIdReference(selected.id)} · ${selected.statement_month}`
) : (
<>
{t(subtitles[active])}
@@ -1254,7 +1375,7 @@ export default function PartnerPortal({
{!embedded && (
<Text type='secondary'>
{selected
? `${t('账单号')} #${selected.id} · ${selected.statement_month}`
? `${t('账单号')} ${formatIdReference(selected.id)} · ${selected.statement_month}`
: t(subtitles[active])}
{!selected &&
['overview', 'estimate'].includes(active) &&
@@ -1268,6 +1389,7 @@ export default function PartnerPortal({
{selected && (
<>
<Button
icon={<Download size={16} />}
disabled={detailLoading || mutationLoading}
onClick={() =>
exportDetails(items, adjustments, selected, t)
@@ -1303,17 +1425,10 @@ export default function PartnerPortal({
)}
</>
)}
<Button
icon={<ActionRefresh size={16} />}
disabled={mutationLoading || detailLoading}
loading={loading}
onClick={() => {
load();
if (selected) open(selected);
}}
>
{t('刷新')}
</Button>
{(selected ||
!loaded ||
!['bills', 'customers'].includes(active)) &&
refreshButton}
</div>
</div>
{error && <Alert showIcon type='error' description={error} />}
@@ -1347,7 +1462,7 @@ export default function PartnerPortal({
style={themeStyle}
className='commission-modal partner-portal-modal'
visible={!!action}
title={`${t(action === 'reject' ? '驳回账单' : '确认账单')} · #${selected?.id || ''}`}
title={`${t(action === 'reject' ? '驳回账单' : '确认账单')} · ${formatIdReference(selected?.id)}`}
confirmLoading={mutationLoading}
closeOnEsc={!mutationLoading}
maskClosable={!mutationLoading}
+177 -171
View File
@@ -16,6 +16,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
formatCurrency,
formatIdReference,
formatPercent,
toFiniteNumber,
} from '../../helpers/safeDisplay';
import React, {
useCallback,
@@ -56,7 +62,6 @@ import {
PencilLine,
ScrollText,
ShieldAlert,
ChevronDown,
} from 'lucide-react';
import Dashboard from './Dashboard';
import ListPanel from './ListPanel';
@@ -65,20 +70,18 @@ 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 {
Download,
History,
Link,
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,
@@ -91,7 +94,8 @@ const { Title, Text } = Typography;
const emptyState = (description) => (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={description} />
);
const money = (value) => `¥${(Number(value || 0) / 1e6).toFixed(2)}`;
const money = (value) =>
formatCurrency((toFiniteNumber(value) ?? 0) / 1e6, '¥', 2, '¥0.00');
const protectionUntil = (row) =>
Number(row.extended_until || row.protected_until || 0);
const date = (value) =>
@@ -194,7 +198,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,
@@ -216,7 +220,7 @@ function TierSummary({ items }) {
rowKey='id'
size='small'
dataSource={groups}
pagination={false}
pagination={groups.length ? { pageSize: 10 } : false}
columns={[
{ title: t('客户'), dataIndex: 'customer' },
{ title: t('分佣档位'), dataIndex: 'tier' },
@@ -224,7 +228,7 @@ function TierSummary({ items }) {
{
title: t('比例'),
dataIndex: 'rate_bps',
render: (value) => `${Number(value || 0) / 100}%`,
render: (value) => formatPercent(Number(value || 0) / 100, 2),
},
{ title: t('调用笔数'), dataIndex: 'count' },
{ title: t('有效销售额'), dataIndex: 'sales', render: money },
@@ -240,7 +244,7 @@ function PaymentTable({ payments, admin = false }) {
<Table
rowKey='id'
dataSource={payments}
pagination={false}
pagination={payments.length ? { pageSize: 10 } : false}
empty={emptyState(t('暂无付款记录'))}
columns={[
{ title: t('打款日期'), dataIndex: 'paid_at', render: formatDateTime },
@@ -288,7 +292,7 @@ function AdminStatementDetail({
<Button onClick={onBack} type='text'>
{t('返回账单列表')}
</Button>
<div className='commission-detail-actions'>
<div className='commission-detail-actions console-list-tool-actions'>
{(status === 'estimated' || status === 'checking') && (
<Button
icon={<RefreshCw size={16} />}
@@ -305,7 +309,9 @@ function AdminStatementDetail({
(status === 'estimated' || status === 'checking') && (
<Button onClick={onFee}>{t('录入手续费')}</Button>
)}
<Button onClick={onExport}>{t('导出明细')}</Button>
<Button icon={<Download size={16} />} onClick={onExport}>
{t('导出明细')}
</Button>
{status === 'pending_confirmation' && (
<Button onClick={onDeadline}>{t('修改确认截止日期')}</Button>
)}
@@ -448,9 +454,7 @@ function AdminStatementDetail({
rowKey='id'
columns={itemColumns}
dataSource={items}
pagination={{
pageSize: 10,
}}
pagination={items.length ? { pageSize: 10 } : false}
scroll={{ x: 1800 }}
empty={emptyState(t('暂无计费明细'))}
/>
@@ -466,7 +470,7 @@ function AdminStatementDetail({
<Table
rowKey='id'
dataSource={operations}
pagination={false}
pagination={operations.length ? { pageSize: 10 } : false}
empty={emptyState(t('暂无操作记录'))}
columns={[
{
@@ -522,7 +526,7 @@ function AdminStatementDetail({
<Table
rowKey='id'
dataSource={adjustments}
pagination={false}
pagination={adjustments.length ? { pageSize: 10 } : false}
empty={emptyState(t('暂无调整单'))}
columns={[
...AdjustmentColumns(t, money),
@@ -894,7 +898,7 @@ function AdminPage() {
type='link'
size='small'
>
{t('查看详情')}
{t('详情')}
</Button>
),
},
@@ -930,7 +934,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 +996,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 +1063,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>
),
},
],
@@ -1092,7 +1082,7 @@ function AdminPage() {
? t('企业组织')
: t('个人用户'))
}
reference={`${commissionLabel(t, 'subjectType', row.subject_type)} #${row.subject_id}`}
reference={`${commissionLabel(t, 'subjectType', row.subject_type)} ${formatIdReference(row.subject_id)}`}
/>
),
},
@@ -1284,7 +1274,8 @@ function AdminPage() {
)
.map(
(id) =>
entityNames.channels.get(Number(id)) || `#${id}`,
entityNames.channels.get(Number(id)) ||
formatIdReference(id),
)
.join('、')
: row.source_type === 'model'
@@ -1297,7 +1288,7 @@ function AdminPage() {
{
title: t('比例'),
dataIndex: 'rate_bps',
render: (v) => `${(Number(v || 0) / 100).toFixed(2)}%`,
render: (v) => formatPercent(Number(v) / 100, 2),
},
{
title: t('生效时间'),
@@ -1515,6 +1506,88 @@ function AdminPage() {
);
XLSX.writeFile(workbook, `commission-${key}-${month}.xlsx`);
};
const listToolbarActions = (
<>
<Button icon={<RefreshCw size={16} />} onClick={load}>
{t('刷新')}
</Button>
{active === 'partners' && (
<Button
icon={<Plus size={16} />}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOperation({ kind: 'partner-create' });
setError('');
}}
type='primary'
>
{t('新建伙伴档案')}
</Button>
)}
{active === 'assignments' && (
<Button
icon={<Plus size={16} />}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOperation({ kind: 'assignment-create' });
setError('');
}}
type='primary'
>
{t('建立保护归属')}
</Button>
)}
{active === 'tiers' && (
<Button
icon={<Plus size={16} />}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOperation({ kind: 'tier-create' });
setError('');
}}
type='primary'
>
{t('新增档位')}
</Button>
)}
{active === 'adjustments' && (
<Button
icon={<Plus size={16} />}
onClick={() => {
setAdjustmentStatementId(null);
setAdjustmentPicker(true);
}}
type='primary'
>
{t('新增调整单')}
</Button>
)}
{active === 'tiers' && (
<>
<Button
icon={<Link size={16} />}
onClick={() => setOperation({ kind: 'tier-binding' })}
>
{t('绑定等级档位')}
</Button>
<Button
icon={<History size={16} />}
onClick={() => setOperation({ kind: 'tier-history' })}
>
{t('绑定历史')}
</Button>
</>
)}
{active === 'bills' && (
<Button icon={<Download size={16} />} onClick={exportStatements}>
{t('导出 Excel')}
</Button>
)}
</>
);
const tableFor = (key) =>
key === 'tiers' ? (
<LatestTierPanel
@@ -1522,6 +1595,7 @@ function AdminPage() {
columns={columns.tiers}
onExport={(rows) => exportRows('tiers', rows)}
refreshToken={data}
toolbarActions={listToolbarActions}
/>
) : (
<ListPanel
@@ -1533,6 +1607,7 @@ function AdminPage() {
searchableText={rowText}
onExport={(rows) => exportRows(key, rows)}
context={listContext}
toolbarActions={listToolbarActions}
/>
);
return (
@@ -1575,80 +1650,11 @@ function AdminPage() {
}}
/>
)}
<Button icon={<RefreshCw size={16} />} onClick={load}>
{t('刷新')}
</Button>
{active === 'partners' && (
<Button
icon={<Plus size={16} />}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOperation({ kind: 'partner-create' });
setError('');
}}
type='primary'
>
{t('新建伙伴档案')}
{(active === 'overview' || selectedStatement) && (
<Button icon={<RefreshCw size={16} />} onClick={load}>
{t('刷新')}
</Button>
)}
{active === 'assignments' && (
<Button
icon={<Plus size={16} />}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOperation({ kind: 'assignment-create' });
setError('');
}}
type='primary'
>
{t('建立保护归属')}
</Button>
)}
{active === 'tiers' && (
<Button
icon={<Plus size={16} />}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOperation({ kind: 'tier-create' });
setError('');
}}
type='primary'
>
{t('新增档位')}
</Button>
)}
{active === 'adjustments' && (
<Button
icon={<Plus size={16} />}
onClick={() => {
setAdjustmentStatementId(null);
setAdjustmentPicker(true);
}}
type='primary'
>
{t('新增调整单')}
</Button>
)}
{active === 'tiers' && (
<>
<Button
onClick={() => setOperation({ kind: 'tier-binding' })}
>
{t('绑定等级档位')}
</Button>
<Button
onClick={() => setOperation({ kind: 'tier-history' })}
>
{t('绑定历史')}
</Button>
</>
)}
{active === 'bills' && !selectedStatement && (
<Button onClick={exportStatements}>{t('导出 Excel')}</Button>
)}
</div>
</div>
{error && (
+7 -3
View File
@@ -16,11 +16,13 @@ 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.js';
export function latestTierURL(filters = {}, page = 1, snapshot = {}) {
const params = new URLSearchParams({
view: 'latest',
p: String(page),
page_size: '100',
page_size: String(filters.pageSize ?? 100),
});
if (filters.query?.trim()) params.set('q', filters.query.trim());
if (filters.type) params.set('source_type', filters.type);
@@ -39,7 +41,9 @@ export async function fetchAllLatestTiers(fetchJSON, filters = {}) {
let snapshot;
let total;
for (let page = 1; ; page++) {
const result = await fetchJSON(latestTierURL(filters, page, snapshot));
const result = await fetchJSON(
latestTierURL({ ...filters, pageSize: 100 }, page, snapshot),
);
if (!snapshot) {
snapshot = { as_of: result.as_of, revision: result.revision };
total = result.total;
@@ -81,5 +85,5 @@ export function identityOptionLabel(item) {
const name =
item.name || item.display_name || item.username || item.code || '';
const identifier = item.name ? item.code : item.username;
return `${name}${identifier && identifier !== name ? ` · ${identifier}` : ''} (#${item.id})${item.disabled_reason ? ` · ${item.disabled_reason}` : ''}`;
return `${name}${identifier && identifier !== name ? ` · ${identifier}` : ''} (${formatIdReference(item.id)})${item.disabled_reason ? ` · ${item.disabled_reason}` : ''}`;
}
+5 -1
View File
@@ -57,6 +57,9 @@ test('latest all status is omitted and export pins server snapshot across all pa
),
false,
);
const listURL = new URL(latestTierURL({ pageSize: 20 }, 2), 'http://local');
assert.equal(listURL.searchParams.get('page_size'), '20');
assert.equal(listURL.searchParams.get('p'), '2');
const urls = [];
const rows = await fetchAllLatestTiers(
async (url) => {
@@ -69,9 +72,10 @@ test('latest all status is omitted and export pins server snapshot across all pa
revision: 7,
};
},
{ query: '中文', type: 'level' },
{ query: '中文', type: 'level', pageSize: 20 },
);
assert.equal(rows.length, 2);
assert.ok(urls.every((url) => /page_size=100/.test(url)));
assert.match(urls[1], /as_of=123/);
assert.match(urls[1], /revision=7/);
});
+19 -8
View File
@@ -51,6 +51,12 @@ import {
} from './operationForm';
import { pickerEpoch } from './datePicker';
import { API } from '../../helpers';
import {
formatCurrency,
formatIdReference,
formatPercent,
toFiniteNumber,
} from '../../helpers/safeDisplay';
import RemoteIdentitySelect from './RemoteIdentitySelect';
import { fetchAllLatestTiers } from './latestTiers';
import './formSections.css';
@@ -340,7 +346,7 @@ export function OperationsDialog({
style={{ width: '100%' }}
optionList={rows.map((item) => ({
value: item.id,
label: `${name(item)} (#${item.id})`,
label: `${name(item)} (${formatIdReference(item.id)})`,
}))}
/>
</Field>
@@ -848,7 +854,7 @@ export function OperationsDialog({
channel.id,
{
value: channel.id,
label: `${channel.name} (#${channel.id})`,
label: `${channel.name || t('未知渠道')} (${formatIdReference(channel.id)})`,
},
]),
]).values(),
@@ -944,7 +950,7 @@ export function OperationsDialog({
'等级档位',
bindingConfigs.map((item) => ({ ...item, id: item.config_id })),
(item) =>
`${item.name || item.tier_key} · 配置 #${item.config_id}`,
`${item.name || item.tier_key || t('未知档位')} · 配置 ${formatIdReference(item.config_id)}`,
)}
{dateField('effective_from', '绑定生效时间', true)}
<Alert
@@ -975,7 +981,7 @@ export function OperationsDialog({
<Table
rowKey='id'
dataSource={history}
pagination={{ pageSize: 10, showTotal: true }}
pagination={{ pageSize: 10 }}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
@@ -1148,7 +1154,7 @@ export function BillingColumns(t, money, date) {
{
title: t('比例'),
dataIndex: 'rate_bps',
render: (value) => `${Number(value || 0) / 100}%`,
render: (value) => formatPercent(Number(value || 0) / 100, 2),
},
{ title: t('提成金额'), dataIndex: 'commission_uyuan', render: money },
];
@@ -1358,11 +1364,16 @@ export function SettlementDialog({
<Descriptions
row
data={[
{ key: t('账单编号'), value: `#${statement.id}` },
{ key: t('账单编号'), value: formatIdReference(statement.id) },
{ key: t('账期'), value: statement.statement_month || '—' },
{
key: t('应付金额'),
value: `¥${(Number(statement.payable_uyuan || 0) / 1e6).toFixed(2)}`,
value: formatCurrency(
(toFiniteNumber(statement.payable_uyuan) ?? 0) / 1e6,
'¥',
2,
'¥0.00',
),
},
]}
/>
@@ -1449,7 +1460,7 @@ export function SettlementDialog({
onChange={(value) => set('detail_id', value)}
optionList={items.map((item) => ({
value: item.detail_id,
label: `${item.billing_record_id} · ${item.model_name || ''} · ${Number(item.rate_bps || 0) / 100}%`,
label: `${formatIdReference(item.billing_record_id)} · ${item.model_name || t('未知模型')} · ${formatPercent(Number(item.rate_bps) / 100, 2)}`,
}))}
/>
</Field>
+1 -23
View File
@@ -905,8 +905,7 @@
margin-top: 18px;
}
.commission-filter-end {
justify-content: flex-end;
margin-bottom: 18px;
margin-bottom: 16px;
}
.commission-search-field {
display: flex;
@@ -919,17 +918,6 @@
.commission-search-field .ant-select {
width: 100%;
}
.commission-filter-card .console-search-fields {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 16px;
}
.commission-filter-card .console-search-actions {
margin-top: 16px;
}
.commission-filter-toggle.ant-btn {
display: none;
}
.commission-detail-tabs {
margin-top: 18px;
padding: 8px 24px 24px;
@@ -948,19 +936,9 @@
outline-offset: 2px;
}
@media (max-width: 768px) {
.commission-filter-card .console-search-fields {
grid-template-columns: minmax(0, 1fr);
}
.commission-card > .ant-card-body {
padding: 16px;
}
.commission-filter-toggle.ant-btn {
display: inline-flex;
margin-bottom: 16px;
}
.commission-filter-card:not(.is-open) {
display: none;
}
.commission-page-header {
flex-direction: column;
align-items: stretch;
@@ -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;
+5 -4
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, formatNumber } from '../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import {
@@ -2340,12 +2341,12 @@ 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
? `${t('通过')} · ${Number(row.time || 0).toFixed(2)}s`
? `${t('通过')} · ${formatNumber(row.time, 2, '0.00')}s`
: row.message || t('失败')}
</small>
</div>
@@ -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('选择已启用渠道')}
/>
+33 -35
View File
@@ -24,10 +24,15 @@ import {
Copy as ActionCopy,
BookOpen as ActionBookOpen,
HelpCircle as ActionHelpCircle,
Search as ActionSearch,
Plus as ActionPlus,
Search as ActionSearch,
} from '@/components/common/icons/ActionIcons';
import { writeClipboardText } from '../../helpers/clipboard';
import { ConsoleCollectionSearch } from '../../components/console/ConsoleCollection';
import {
ConsoleFilterField,
ConsoleFilterGrid,
} from '../../components/console/ConsolePrimitives';
import TableEmpty from '../../components/common/table/TableEmpty';
import React, { useState, useRef, useEffect, useContext } from 'react';
import Table from '../../components/ui/CenterActionTable';
@@ -892,35 +897,28 @@ const KeyManagement = ({ embedded = false }) => {
<DesensitizeNotice t={t} />
<div className='km-panels'>
<Card className='km-card km-search-card tour-search-input'>
<label className='km-search-label' htmlFor='km-search-input'>
{t('密钥查询')}
</label>
<div className='km-search-row'>
<Input
id='km-search-input'
className='km-search-input'
placeholder={t('搜索密钥名称、Key 或分组')}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
onPressEnter={() => setSearchValue(searchValue)}
allowClear
/>
<Button onClick={() => setSearchValue('')}>{t('重置')}</Button>
<Button
type='primary'
icon={<ActionSearch size={14} />}
onClick={() => setSearchValue(searchValue)}
>
{t('搜索')}
</Button>
</div>
</Card>
<ConsoleCollectionSearch className='km-card km-search-card tour-search-input'>
<ConsoleFilterGrid
onReset={() => setSearchValue('')}
onSearch={() => setSearchValue(searchValue.trim())}
>
<ConsoleFilterField label={t('密钥查询')} id='km-search-input'>
<Input
id='km-search-input'
prefix={<ActionSearch size={14} />}
placeholder={t('搜索密钥名称、Key 或分组')}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
allowClear
/>
</ConsoleFilterField>
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<Card className='km-card km-list-card'>
<div className='km-list-head'>
<div className='km-list-head console-list-tools'>
<h2>{t('密钥列表')}</h2>
<div className='km-list-actions'>
<div className='km-list-actions console-list-tool-actions'>
<Button
type='link'
className='km-contact-link'
@@ -928,14 +926,6 @@ const KeyManagement = ({ embedded = false }) => {
>
{t('创建密钥后不知道怎么用?联系客服')}
</Button>
<Button
type='primary'
icon={<ActionPlus size={16} />}
className='tour-create-btn'
onClick={handleCreate}
>
{t('创建密钥')}
</Button>
<TableColumnSettings
columns={COLUMN_OPTIONS.map((option) => ({
key: option.value,
@@ -945,6 +935,14 @@ const KeyManagement = ({ embedded = false }) => {
defaultValue={COLUMN_OPTIONS.map((option) => option.value)}
onChange={setVisibleColumns}
/>
<Button
type='primary'
icon={<ActionPlus size={16} />}
className='tour-create-btn'
onClick={handleCreate}
>
{t('创建密钥')}
</Button>
</div>
</div>
@@ -9,7 +9,6 @@
.km-page {
--km-page-bg: #f8fafc;
--km-text: rgba(0, 0, 0, 0.88);
--km-label: #6b7789;
--km-search-border: #f0f0f0;
--km-card-border: #e6e9ef;
--km-card-shadow: 0 4px 24px rgba(15, 23, 42, 0.02);
@@ -24,7 +23,6 @@
html.dark .km-page {
--km-page-bg: var(--surface-bg-base);
--km-text: var(--uc-heading);
--km-label: var(--text-secondary);
--km-search-border: var(--border-subtle);
--km-card-border: var(--border-subtle);
--km-card-shadow: none;
@@ -71,28 +69,6 @@ html.dark .km-page {
box-shadow: var(--km-card-shadow);
}
/* 查询标签与消费记录筛选标签一致;输入 620px,输入与按钮 16px,按钮间 8px。 */
.km-search-label {
display: flex;
align-items: center;
height: 21px;
margin-bottom: 8px;
color: var(--km-label);
font-size: 13px;
line-height: 1.5714285714285714;
}
.km-search-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.km-search-row .km-search-input {
width: 620px;
max-width: 100%;
margin-right: 8px;
}
/* 列表卡头:标题 15px/600,与表格 18px(同使用记录表格卡) */
.km-list-head {
display: flex;
@@ -328,10 +304,6 @@ html.dark .km-edit-drawer {
.km-page-standalone .km-content.uc-page {
padding-top: 80px;
}
.km-search-row .km-search-input {
width: 100%;
margin-right: 0;
}
.km-list-head {
align-items: flex-start;
}
+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);
+17 -30
View File
@@ -16,21 +16,24 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
Search as ActionSearch,
RefreshCw as ActionRefreshCw,
} from '@/components/common/icons/ActionIcons';
import { formatUserReference } from '../../helpers/safeDisplay';
import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons';
import TableEmpty from '../../components/common/table/TableEmpty';
import { ConsoleCollectionSearch } from '@/components/console/ConsoleCollection';
import {
ConsoleFilterField,
ConsoleFilterGrid,
} from '@/components/console/ConsolePrimitives';
import React, { useEffect, useState } from 'react';
import { getQuotaPerUnit } from '../../helpers';
import { timestamp2string } from '../../helpers/utils';
import { useTranslation } from 'react-i18next';
import { Form as AntForm, Tabs as AntTabs } from 'antd';
import { Tabs as AntTabs } from 'antd';
import { Table, Select, Button, Tag, Tooltip } from '@/components/ui';
import { API } from '../../helpers/api';
import { useOrgAuditLogs } from '../../hooks/org/useOrgData';
import OrgPageHeader from './components/OrgPageHeader';
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
import { OrgListCard } from './components/OrgListCard';
import OrgPromptRecords from './OrgPromptRecords';
import {
formatQuotaAsCNY,
@@ -306,7 +309,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('操作类型'),
@@ -401,35 +404,20 @@ const OrgAudit = ({ orgId }) => {
const operations = (
<>
<OrgFilterCard
className='oc-audit-filter'
actions={
<>
{/* 重置 = 选择“全部操作”;搜索 = 以当前筛选重新查询(同“刷新”) */}
<Button onClick={() => applyAction('')}>{t('重置')}</Button>
<Button
type='primary'
icon={<ActionSearch size={16} />}
onClick={refresh}
>
{t('搜索')}
</Button>
</>
}
>
<AntForm layout='vertical' requiredMark={false} component='div'>
<AntForm.Item label={t('操作类型')}>
<ConsoleCollectionSearch className='oc-audit-filter'>
<ConsoleFilterGrid onReset={() => applyAction('')} onSearch={refresh}>
<ConsoleFilterField label={t('操作类型')} id='org-audit-action-type'>
<Select
id='org-audit-action-type'
value={actionFilter}
onChange={applyAction}
optionList={actionOptions}
style={{ width: '100%' }}
placeholder={t('全部操作')}
filter
/>
</AntForm.Item>
</AntForm>
</OrgFilterCard>
</ConsoleFilterField>
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<OrgListCard
title={t('操作记录')}
@@ -452,7 +440,6 @@ const OrgAudit = ({ orgId }) => {
pagination={{
currentPage: page,
pageSize,
showSizeChanger: false,
total,
onPageChange: setPage,
onPageSizeChange: (size) => {
+18 -9
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],
);
@@ -473,7 +482,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
columns={columns}
dataSource={list}
loading={loading}
pagination={false}
pagination={{ resetOnDataChange: true }}
rowKey='id'
scroll={{ x: 1040 }}
/>
+21 -36
View File
@@ -335,21 +335,17 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
rowKey='id'
size='small'
loading={loading}
pagination={
total > pageSize || pageSize !== 20
? {
currentPage: page,
pageSize,
total,
onPageChange: (p) => fetchLogs(p),
onPageSizeChange: (size) => {
pageSizeRef.current = size;
setPageSize(size);
fetchLogs(1, appliedFilters, size);
},
}
: false
}
pagination={{
currentPage: page,
pageSize,
total,
onPageChange: (p) => fetchLogs(p),
onPageSizeChange: (size) => {
pageSizeRef.current = size;
setPageSize(size);
fetchLogs(1, appliedFilters, size);
},
}}
empty={
<div className='py-8 text-center'>
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-2'>
@@ -384,10 +380,6 @@ const renderBudgetAmount = (quota) => {
};
const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
const quotaPaginationSizeRef = useRef(null);
useEffect(() => {
quotaPaginationSizeRef.current = null;
}, [orgId]);
const { t } = useTranslation();
const navigate = useNavigate();
const [statusState] = useContext(StatusContext);
@@ -615,23 +607,16 @@ const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
loading={quotaLoading}
rowKey='member_id'
scroll={{ x: 860 }}
pagination={
memberQuotaTotal > memberQuotaPageSize ||
quotaPaginationSizeRef.current !== null
? {
currentPage: memberQuotaPage,
pageSize: memberQuotaPageSize,
total: memberQuotaTotal,
showSizeChanger: false,
onPageChange: (page) => fetchQuota(page, memberQuotaPageSize),
onPageSizeChange: (size) => {
quotaPaginationSizeRef.current = size;
fetchQuota(1, size);
},
showTotal: (n) => t('共 {{total}} 条', { total: n }),
}
: false
}
pagination={{
currentPage: memberQuotaPage,
pageSize: memberQuotaPageSize,
total: memberQuotaTotal,
onPageChange: (page) => fetchQuota(page, memberQuotaPageSize),
onPageSizeChange: (size) => {
fetchQuota(1, size);
},
showTotal: (n) => t('共 {{total}} 条', { total: n }),
}}
empty={<OrgStateBlock icon={Users} title={t('暂无成员数据')} />}
/>
{memberQuotaRows.length > 0 && (
+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],
);
+14 -8
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('消耗'),
@@ -323,7 +327,7 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
placeholder={t('选择部门')}
style={{ width: 180 }}
optionList={departments.map((d) => ({
label: `${d.name}(${d.member_count})`,
label: `${d.name || t('未命名部门')}(${d.member_count ?? 0})`,
value: d.id,
}))}
/>
@@ -364,7 +368,7 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
dataSource={members}
loading={membersLoading}
rowKey='id'
pagination={false}
pagination={{ resetOnDataChange: true }}
empty={<Empty description={t('暂无成员')} />}
/>
</TabPane>
@@ -403,7 +407,7 @@ const OrgDeptManage = ({ orgId, featureFlags }) => {
columns={rankColumns}
dataSource={ranking}
rowKey='user_id'
pagination={false}
pagination={{ resetOnDataChange: true }}
empty={<Empty description={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'>
+28 -15
View File
@@ -16,6 +16,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
formatIdReference,
formatNumber,
formatPercent,
} from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons';
@@ -269,7 +274,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
{
label: t('质量评分'),
value: metric.has('quality.score')
? value('quality.score', true).toFixed(1)
? formatNumber(value('quality.score', true), 1, t('数据不足'))
: t('数据不足'),
detail: `${Math.round(value('quality.feedback_count'))} ${t('反馈样本')}`,
icon: FlaskConical,
@@ -406,7 +411,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
</Text>
<Table
size='small'
pagination={false}
pagination={{ resetOnDataChange: true }}
dataSource={directUsage}
rowKey='skill_id'
columns={[
@@ -414,13 +419,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'),
@@ -471,7 +478,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
</Tag>
</div>
<span>
{t('评分')}: {Number(row.score).toFixed(1)}
{t('评分')}: {formatNumber(row.score, 1)}
</span>
<span>
{t('样本')}: {row.sample_count}
@@ -485,14 +492,14 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
) : (
<Table
size='small'
pagination={false}
pagination={{ resetOnDataChange: true }}
dataSource={data.alerts || []}
columns={[
{ title: t('Skill'), dataIndex: 'dimension_id' },
{
title: t('评分'),
dataIndex: 'score',
render: (score) => Number(score).toFixed(1),
render: (score) => formatNumber(score, 1),
},
{ title: t('样本'), dataIndex: 'sample_count' },
{
@@ -545,19 +552,22 @@ 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>
{t('平均成本')}:{' '}
{row.data_sufficient
? Number(row.average_quota).toFixed(1)
? formatNumber(row.average_quota, 1)
: t('数据不足')}
</span>
</article>
@@ -565,7 +575,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
</div>
) : (
<Table
pagination={false}
pagination={{ resetOnDataChange: true }}
dataSource={comparison}
columns={[
{ title: t('版本'), dataIndex: 'version_id' },
@@ -574,21 +584,24 @@ 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('数据不足'),
},
{
title: t('平均成本'),
render: (_, row) =>
row.data_sufficient
? Number(row.average_quota).toFixed(1)
? formatNumber(row.average_quota, 1)
: t('数据不足'),
},
]}
@@ -660,7 +673,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
</div>
) : (
<Table
pagination={false}
pagination={{ resetOnDataChange: true }}
dataSource={experiments}
columns={[
{ title: t('实验'), dataIndex: 'name' },
+12 -4
View File
@@ -16,6 +16,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
formatIdReference,
formatPercent,
toFiniteNumber,
} from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import {
@@ -98,9 +103,10 @@ const uploadContentType = (file) => {
};
const formatBytes = (bytes, t) => {
if (!bytes) return `0 ${t('字节')}`;
const numericBytes = toFiniteNumber(bytes);
if (numericBytes === null || numericBytes <= 0) return `0 ${t('字节')}`;
const units = [t('字节'), 'KiB', 'MiB', 'GiB'];
let value = Number(bytes);
let value = numericBytes;
let unit = 0;
while (value >= 1024 && unit < units.length - 1) {
value /= 1024;
@@ -1887,7 +1893,7 @@ const OrgKnowledge = ({ orgId, canAuditContent = false }) => {
label:
member.display_name ||
member.username ||
`#${member.id}`,
formatIdReference(member.id),
}))}
/>
<Select
@@ -1959,7 +1965,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>}
+11 -5
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
@@ -935,7 +942,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
dataSource={rankingRows}
loading={rankingLoading}
rowKey='rank_row_key'
pagination={false}
pagination={{ resetOnDataChange: true }}
scroll={{ x: 790 }}
empty={<TableEmpty />}
/>
@@ -950,7 +957,6 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
currentPage: page,
pageSize,
total,
showSizeChanger: false,
onPageChange: (p) => doPageFetch(p),
onPageSizeChange: (size) => {
setPage(1);
+14 -7
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,
@@ -327,7 +329,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 +359,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>
@@ -503,8 +511,7 @@ const OrgMemberAccounts = ({
dataSource={members}
loading={loading}
pagination={{
pageSize: 15,
showSizeChanger: false,
resetOnDataChange: true,
showTotal: (n) => t('共 {{total}} 条', { total: n }),
}}
rowKey='id'
@@ -516,7 +523,7 @@ const OrgMemberAccounts = ({
columns={columns}
dataSource={members}
loading={loading}
pagination={{ pageSize: 15, showSizeChanger: false }}
pagination={{ resetOnDataChange: true }}
rowKey='id'
/>
</OrgPanel>
@@ -702,7 +709,7 @@ const OrgMemberAccounts = ({
/>
<Table
size='small'
pagination={false}
pagination={{ resetOnDataChange: true }}
rowKey={(r) => `${r.row}`}
dataSource={importResult.details || []}
columns={[
+2 -2
View File
@@ -460,7 +460,7 @@ const OrgPrivateSkills = ({ orgId }) => {
</div>
) : (
<Table
pagination={false}
pagination={{ resetOnDataChange: true }}
dataSource={items}
rowKey={(row) => row.definition.id}
columns={[
@@ -615,7 +615,7 @@ const OrgPrivateSkills = ({ orgId }) => {
</div>
) : (
<Table
pagination={false}
pagination={{ resetOnDataChange: true }}
dataSource={history}
rowKey={(row) => row.version.id}
columns={[
+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 { 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 }) => {
@@ -289,7 +293,7 @@ const OrgProjectManage = ({ orgId }) => {
dataSource={members}
loading={loading}
rowKey='org_member_id'
pagination={false}
pagination={{ resetOnDataChange: true }}
empty={<Empty description={t('暂无项目成员')} />}
/>
</OrgPanel>
+8 -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,
@@ -105,7 +106,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,7 +304,7 @@ 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]);
@@ -406,8 +407,7 @@ const OrgProjects = ({ orgId }) => {
dataSource={list}
loading={loading}
pagination={{
pageSize: 15,
showSizeChanger: false,
resetOnDataChange: true,
showTotal: (total) => t('共 {{total}} 条', { total }),
}}
rowKey='id'
@@ -491,7 +491,7 @@ const OrgProjects = ({ orgId }) => {
{
title: t('成员'),
dataIndex: 'org_member_id',
render: (v) => memberNameMap[v] || `#${v}`,
render: (v) => memberNameMap[v] || formatIdReference(v),
},
{
title: t('角色'),
@@ -519,7 +519,7 @@ const OrgProjects = ({ orgId }) => {
},
]}
dataSource={projectMembers}
pagination={false}
pagination={{ resetOnDataChange: true }}
rowKey='org_member_id'
size='small'
/>
@@ -550,7 +550,7 @@ const OrgProjects = ({ orgId }) => {
</Tag>
) : (
<Tag color='blue' size='small'>
{projectNameMap[v] || `#${v}`}
{projectNameMap[v] || formatIdReference(v)}
</Tag>
),
},
@@ -579,7 +579,7 @@ const OrgProjects = ({ orgId }) => {
},
]}
dataSource={orgTokens}
pagination={false}
pagination={{ resetOnDataChange: true }}
rowKey='id'
size='small'
/>
+26 -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 {
Copy as ActionCopy,
Search as ActionSearch,
@@ -28,6 +29,7 @@ import i18next from 'i18next';
import { Database, MessageSquareText, SlidersHorizontal } from 'lucide-react';
import {
Table,
Pagination,
Button,
Input,
Select,
@@ -60,6 +62,8 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
const quotaPerUnit = getQuotaPerUnit();
const [calls, setCalls] = useState(null); // null = 加载中
const [error, setError] = useState('');
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
useEffect(() => {
let cancelled = false;
@@ -88,6 +92,10 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
};
}, [orgId, groupKey, t]);
useEffect(() => {
setPage(1);
}, [calls]);
if (calls === null) {
return (
<div className='text-xs text-gray-400 dark:text-gray-500 mt-2'>
@@ -133,7 +141,7 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
</tr>
</thead>
<tbody>
{calls.map((log) => (
{calls.slice((page - 1) * pageSize, page * pageSize).map((log) => (
<tr
key={log.id}
className='border-t border-gray-100 dark:border-white/[0.06]'
@@ -159,6 +167,18 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
</tbody>
</table>
</div>
<Pagination
className='mt-4'
align='end'
currentPage={page}
pageSize={pageSize}
total={calls.length}
onPageChange={setPage}
onPageSizeChange={(size) => {
setPage(1);
setPageSize(size);
}}
/>
</div>
);
};
@@ -250,7 +270,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 +294,7 @@ const OrgPromptRecords = ({ orgId }) => {
member?.remark ||
member?.display_name ||
record.username ||
`User#${record.user_id}`
formatUserReference(record.name || record.username, record.user_id)
);
};
+11 -3
View File
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import { formatNumber } from '../../helpers/safeDisplay';
import { Check as ActionCheck } from '@/components/common/icons/ActionIcons';
import React, { useEffect, useState, useCallback, useMemo } from 'react';
import { timestamp2string } from '../../helpers/utils';
@@ -467,7 +468,7 @@ const OrgRecharge = ({ orgId }) => {
}
if (effectiveAmountYuan <= 0) return '';
const pay = effectiveAmountYuan * effectiveDiscount;
return `${pay.toFixed(2)} ${t('元')}`;
return `${formatNumber(pay, 2, '0.00')} ${t('元')}`;
};
// 充值记录状态渲染
@@ -508,7 +509,7 @@ const OrgRecharge = ({ orgId }) => {
title: t('金额'),
dataIndex: 'money',
width: 140,
render: (v) => `¥${Number(v).toFixed(2)}`,
render: (v) => `¥${formatNumber(v, 2, '0.00')}`,
},
{
title: t('获得额度'),
@@ -776,7 +777,14 @@ const OrgRecharge = ({ orgId }) => {
</div>
<div>
<dt>{t('优惠金额')}</dt>
<dd>¥{(effectiveAmountYuan - payableYuan).toFixed(2)}</dd>
<dd>
¥
{formatNumber(
effectiveAmountYuan - payableYuan,
2,
'0.00',
)}
</dd>
</div>
<div>
<dt>{t('支付方式')}</dt>
+3 -3
View File
@@ -25,6 +25,7 @@ import { Table, Button, Tag, Toast, Input, Popconfirm } from '@/components/ui';
import { API } from '../../helpers/api';
import { showError, collectPagedItems } from '../../helpers';
import { renderQuota } from '../../helpers/render';
import { formatIdReference } from '../../helpers/safeDisplay';
import OrgPageHeader from './components/OrgPageHeader';
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
import OrgModal from './components/OrgModal';
@@ -158,7 +159,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
// 后端已富化 subject_name;主体被删除等极端情况回退为 #ID
return r.subject_name
? `${label} · ${r.subject_name}`
: `${label} #${r.subject_id}`;
: `${label} ${formatIdReference(r.subject_id, t('未知主体'))}`;
},
},
{
@@ -271,8 +272,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
loading={loading}
empty={<TableEmpty />}
pagination={{
pageSize: 15,
showSizeChanger: false,
resetOnDataChange: true,
showTotal: (total) => t('共 {{total}} 条', { total }),
}}
rowKey='id'
+8 -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 { formatCurrency, formatUserReference } from '../../helpers/safeDisplay';
import {
RefreshCw as ActionRefreshCw,
@@ -653,7 +654,12 @@ const OrgSettings = ({ orgId, orgRole }) => {
extra={
Number(alertYuan) >= 0.005
? t('当企业剩余额度低于 {{amount}} 时触发预警', {
amount: `${getCurrencySymbol()}${Number(alertYuan).toFixed(2)}`,
amount: formatCurrency(
alertYuan,
getCurrencySymbol(),
2,
getCurrencySymbol() + '0.00',
),
})
: t('当前为 0:已关闭余额预警')
}
@@ -1013,7 +1019,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,
}))}
/>
@@ -29,6 +29,7 @@ import {
} from '@/components/ui';
import { useTranslation } from 'react-i18next';
import { API } from '../../helpers';
import { formatIdReference } from '../../helpers/safeDisplay';
import {
ActivationModeTag,
AssignmentModeTag,
@@ -309,7 +310,7 @@ const OrgSkillAssignments = ({ orgId, orgRole = '' }) => {
columns={columns}
dataSource={items}
rowKey='id'
pagination={false}
pagination={{ resetOnDataChange: true }}
/>
)}
</OrgPanel>
@@ -354,7 +355,7 @@ const OrgSkillAssignments = ({ orgId, orgRole = '' }) => {
>
{library.map((item) => (
<Select.Option key={item.skill_id} value={item.skill_id}>
Skill #{item.skill_id}
Skill {formatIdReference(item.skill_id)}
</Select.Option>
))}
</Select>
+4 -3
View File
@@ -42,6 +42,7 @@ import { Search } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { API } from '../../helpers';
import { formatIdReference } from '../../helpers/safeDisplay';
import {
LicenseBadge,
RiskBadge,
@@ -164,8 +165,8 @@ const OrgSkillLibrary = ({ orgId, orgRole, canAssignSkills = false }) => {
item?.locales?.find((locale) => locale.locale === 'zh')?.name ||
item?.locales?.[0]?.name ||
item?.definition?.canonical_id ||
`Skill #${item?.definition?.id}`,
[],
`Skill ${formatIdReference(item?.definition?.id, t('未知技能'))}`,
[t],
);
const importCandidates = useMemo(() => {
const keyword = importKeyword.trim().toLowerCase();
@@ -516,7 +517,7 @@ const OrgSkillLibrary = ({ orgId, orgRole, canAssignSkills = false }) => {
catalog
.get(policy.skill_id)
?.locales?.find((item) => item.locale === 'zh')?.name ||
`Skill #${policy.skill_id}`
`Skill ${formatIdReference(policy.skill_id, t('未知技能'))}`
}
actions={
<SkillStatusTag
+8 -11
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,
@@ -50,7 +52,6 @@ import {
TextArea,
} from '@/components/ui';
import { useOrgTokens } from '../../hooks/org/useOrgData';
import { useIsMobile } from '../../hooks/common/useIsMobile';
import {
API,
copy,
@@ -143,9 +144,6 @@ const OrgTokens = ({ orgId, orgRole }) => {
fetchTokenKey,
} = useOrgTokens(orgId);
const [page, setPage] = useState(1);
// 窄屏下两侧固定列(名称+操作≈400px)会占满可视宽度,中间列无处可显示,故仅桌面端固定
const isMobile = useIsMobile();
const fixedSide = (side) => (isMobile ? undefined : side);
const [pageSize, setPageSize] = useState(20);
const [visibleColumns, setVisibleColumns] = useState([
'name',
@@ -305,9 +303,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
title: t('名称'),
key: 'name',
dataIndex: 'name',
width: 230,
// 列数较多,常规桌面宽度也会横向滚动:名称与操作列固定在两侧,滚动时始终可见
fixed: fixedSide('left'),
width: 150,
ellipsis: { showTitle: false },
render: (name, record) => (
<Tooltip content={name} position='topLeft'>
@@ -331,7 +327,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
title: t('密钥'),
key: 'key',
dataIndex: 'key',
width: 335,
width: 300,
render: (key, record) => {
// key 为后端脱敏值(前 4 + **** + 后 4)
const fullKey = revealedKeys[record.id];
@@ -512,7 +508,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),
},
]
: []),
@@ -527,7 +523,6 @@ const OrgTokens = ({ orgId, orgRole }) => {
title: t('操作'),
key: 'actions',
width: 90,
fixed: fixedSide('right'),
render: (_, record) => {
// 管理员/超管可操作所有Token,普通成员只能操作自己创建的。
if (!canOperateRow(record)) return '-';
@@ -1348,7 +1343,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 { formatIdReference, 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>
);
};
@@ -136,9 +142,9 @@ const localizeAnalyticsRows = (rows, dimension, t) =>
}[dimension];
if (zeroName) name = zeroName;
} else if (dimension === 'member' && name === `成员#${row.key}`) {
name = `${t('成员')}#${row.key}`;
name = `${t('成员')}${formatIdReference(row.key, t('未知成员'))}`;
} else if (dimension === 'token' && name === `\u4ee4\u724c#${row.key}`) {
name = `${t('密钥')}#${row.key}`;
name = `${t('密钥')}${formatIdReference(row.key, t('未知密钥'))}`;
}
return name === row.name ? row : { ...row, name };
});
@@ -173,11 +179,6 @@ const OrgAnalyticsPanel = ({
const [trendRows, setTrendRows] = useState([]);
const [prevRows, setPrevRows] = useState([]);
const [loading, setLoading] = useState(false);
const [detailPage, setDetailPage] = useState(1);
useEffect(() => {
setDetailPage(1);
}, [breakdownRows, dimension, rangeDays]);
useEffect(() => {
initVChartTheme({ isWatchingThemeSwitch: true });
@@ -432,12 +433,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)}
@@ -505,16 +508,7 @@ const OrgAnalyticsPanel = ({
dataSource={breakdownRows}
rowKey='key'
scroll={{ x: 880 }}
pagination={{
currentPage: Math.min(
detailPage,
Math.max(1, Math.ceil(breakdownRows.length / 10)),
),
pageSize: 10,
showSizeChanger: false,
onPageChange: setDetailPage,
showTotal: (n) => t('共 {{total}} 条', { total: n }),
}}
pagination={{ resetOnDataChange: true }}
/>
)}
</AntCard>
@@ -23,12 +23,10 @@ import {
} from '@/components/common/icons/ActionIcons';
import TableEmpty from '../../../components/common/table/TableEmpty';
import React, { useMemo } from 'react';
import Table from '../../../components/ui/CenterActionTable';
import { Card, Tag } from 'antd';
import { Clock } from 'lucide-react';
import { Button, Pagination } from '@/components/ui';
import { Button, Table } from '@/components/ui';
import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData';
import { useIsMobile } from '../../../hooks/common/useIsMobile';
import { timestamp2string } from '../../../helpers';
import { getTaskLogsColumns } from '../../../components/table/task-logs/TaskLogsColumnDefs';
import TaskLogsFilters from '../../../components/table/task-logs/TaskLogsFilters';
@@ -76,7 +74,6 @@ const OrgTaskRecords = () => {
openVideoModal,
visibleColumns,
} = taskLogsData;
const isMobile = useIsMobile();
// 仅用于“实时更新中”提示(存在进行中任务时轮询);原型无“本页统计”区块,不渲染
const pageStats = useTaskPageStats(logs);
@@ -257,26 +254,16 @@ const OrgTaskRecords = () => {
dataSource={logs}
rowKey='key'
loading={loading}
pagination={false}
scroll={{ x: scrollX }}
locale={{
emptyText: <TableEmpty />,
pagination={{
currentPage: taskLogsData.activePage,
pageSize: taskLogsData.pageSize,
total: taskLogsData.logCount,
onPageSizeChange: taskLogsData.handlePageSizeChange,
onPageChange: taskLogsData.handlePageChange,
}}
scroll={{ x: scrollX }}
empty={<TableEmpty />}
/>
{taskLogsData.logCount > 0 && (
<Pagination
currentPage={taskLogsData.activePage}
pageSize={taskLogsData.pageSize}
total={taskLogsData.logCount}
pageSizeOpts={[10, 20, 50]}
showSizeChanger
onPageSizeChange={taskLogsData.handlePageSizeChange}
onPageChange={taskLogsData.handlePageChange}
preventPageChangeOnPageSizeChange={false}
showQuickJumper={isMobile}
showTotal={(total) => t('共 {{total}} 条', { total })}
/>
)}
</OrgListCard>
</div>
);
@@ -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],
);
}
@@ -296,7 +296,7 @@ const OrgDsRules = ({ orgId, isSuperAdmin }) => {
<Table
columns={customColumns}
dataSource={customRules}
pagination={false}
pagination={{ resetOnDataChange: true }}
rowKey='id'
size='small'
scroll={{ x: 'max(100%, 900px)' }}
@@ -320,7 +320,7 @@ const OrgDsRules = ({ orgId, isSuperAdmin }) => {
<Table
columns={platformColumns}
dataSource={platformRules.map((r, i) => ({ ...r, _key: i }))}
pagination={false}
pagination={{ resetOnDataChange: true }}
rowKey='_key'
size='small'
scroll={{ x: 'max(100%, 640px)' }}
@@ -26,7 +26,7 @@ import React, {
} from 'react';
import { useTranslation } from 'react-i18next';
import { Alert, Button, Tag, Typography } from 'antd';
import Table from '../../../components/ui/CenterActionTable';
import { Table } from '@/components/ui';
// 流水入口:ActionIcons 无 ScrollText,使用账本语义的 ReceiptText
import { ReceiptText as ScrollText } from '@/components/common/icons/ActionIcons';
import {
@@ -340,7 +340,7 @@ const DeptFundsPanel = ({ orgId, deptId, deptName, refreshKey }) => {
dataSource={tree}
loading={loading}
rowKey='key'
pagination={false}
pagination={{ resetOnDataChange: true }}
expandable={{ defaultExpandAllRows: true }}
size='middle'
scroll={{ x: 860 }}
@@ -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';
@@ -33,7 +34,7 @@ import {
fundEntryLabel,
} from './fundFormat';
const PAGE_SIZE = 20;
const DEFAULT_PAGE_SIZE = 20;
const defaultRange = () => {
const end = new Date();
return [new Date(end.getTime() - 30 * 24 * 3600 * 1000), end];
@@ -50,6 +51,7 @@ const FundLedgerSheet = ({ visible, account, fetchLedger, onClose }) => {
const [range, setRange] = useState(defaultRange);
const [types, setTypes] = useState([]);
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE);
const [items, setItems] = useState([]);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
@@ -76,7 +78,7 @@ const FundLedgerSheet = ({ visible, account, fetchLedger, onClose }) => {
end_timestamp: end ? Math.floor(end.getTime() / 1000) : undefined,
type: types.length ? types.join(',') : undefined,
p: page,
page_size: PAGE_SIZE,
page_size: pageSize,
});
if (seq !== seqRef.current) return;
if (res?.data?.success) {
@@ -91,7 +93,7 @@ const FundLedgerSheet = ({ visible, account, fetchLedger, onClose }) => {
} finally {
if (seq === seqRef.current) setLoading(false);
}
}, [visible, account?.id, range, types, page, fetchLedger, t]);
}, [visible, account?.id, range, types, page, pageSize, fetchLedger, t]);
useEffect(() => {
load();
@@ -157,7 +159,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}
@@ -262,8 +264,11 @@ const FundLedgerSheet = ({ visible, account, fetchLedger, onClose }) => {
scroll={{ x: 'max-content' }}
pagination={{
currentPage: page,
pageSize: PAGE_SIZE,
showSizeChanger: false,
pageSize,
onPageSizeChange: (size) => {
setPage(1);
setPageSize(size);
},
total,
onPageChange: setPage,
showTotal: (n) => t('共 {{total}} 条', { total: n }),
+2 -2
View File
@@ -28,7 +28,7 @@ import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { Alert, Button, Switch, Tag, Typography } from 'antd';
import { Building2, Layers, PiggyBank, Power, Wallet } from 'lucide-react';
import Table from '../../../components/ui/CenterActionTable';
import { Table } from '@/components/ui';
// 流水入口:ActionIcons 无 ScrollText,使用账本语义的 ReceiptText
import { ReceiptText as ScrollText } from '@/components/common/icons/ActionIcons';
import OrgPanel from '../components/OrgPanel';
@@ -486,7 +486,7 @@ const OrgDeptFunds = ({ orgId }) => {
dataSource={[...tree, ...(includeArchived ? archivedRows : [])]}
loading={loading}
rowKey='key'
pagination={false}
pagination={{ resetOnDataChange: true }}
expandable={{ defaultExpandAllRows: true }}
size='middle'
scroll={{ x: 900 }}
+3 -1
View File
@@ -17,6 +17,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';
// 与后端 model/org_fund.go 常量一一对应
export const FUND_STATE = { NEVER: 0, ON: 1, OFF: 2 };
export const FUND_ACCOUNT_TYPE = { POOL: 0, UNALLOCATED: 1, DEPT: 2 };
@@ -62,7 +64,7 @@ export const fundAccountDisplay = (t, accountType, deptName) => {
export const fundDeptDisplay = (t, deptId, deptName) => {
if (deptId === null || deptId === undefined) return '—';
if (!deptId) return t('未归属部门');
return deptName || `#${deptId}`;
return deptName || formatIdReference(deptId);
};
// 一次分配/回收的幂等键:打开弹窗时生成,重试沿用(F-12)。
+13 -6
View File
@@ -49,12 +49,16 @@ import {
} from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { API, copy, showError, showSuccess } from '../../helpers';
import {
formatNumber,
formatPercent,
toFiniteNumber,
} from '../../helpers/safeDisplay';
const { Text, Title } = Typography;
const fmtDate = (ts) => (ts ? new Date(ts * 1000).toLocaleDateString() : '-');
const fmtYuan = (v) =>
v === undefined || v === null ? '-' : Number(v).toFixed(2);
const fmtYuan = (v) => formatNumber(v, 2, '-');
const LEAD_STATUS = {
pending: ['orange', '待审核'],
@@ -845,12 +849,15 @@ function Bills({ t, readOnly }) {
{ title: t('毛利(元)'), dataIndex: 'gross_profit_yuan', render: fmtYuan },
{
title: t('返佣(元)'),
render: (r) => fmtYuan((r.l1_yuan || 0) + (r.l2_yuan || 0)),
render: (r) =>
fmtYuan(
(toFiniteNumber(r.l1_yuan) ?? 0) + (toFiniteNumber(r.l2_yuan) ?? 0),
),
},
{
title: t('应发(元)'),
dataIndex: 'payable_yuan',
render: (v) => Number(v ?? 0).toFixed(2),
render: (v) => formatNumber(v, 2, '0.00'),
},
{
title: '',
@@ -965,7 +972,7 @@ function Bills({ t, readOnly }) {
data={[
{
key: t('定档'),
value: `${t('第 {{tier}} 档', { tier: detail.bill.tier })} · ${(detail.bill.tier_rate * 100).toFixed(0)}%`,
value: `${t('第 {{tier}} 档', { tier: detail.bill.tier })} · ${formatPercent(Number(detail.bill.tier_rate) * 100, 0)}`,
},
{ key: t('一层(元)'), value: fmtYuan(detail.bill.l1_yuan) },
{ key: t('二层(元)'), value: fmtYuan(detail.bill.l2_yuan) },
@@ -980,7 +987,7 @@ function Bills({ t, readOnly }) {
},
{
key: t('应发(元)'),
value: Number(detail.bill.payable_yuan ?? 0).toFixed(2),
value: formatNumber(detail.bill.payable_yuan, 2, '0.00'),
},
]}
/>
+20 -11
View File
@@ -27,16 +27,23 @@ import {
PayPalBrandIcon,
} from '../../components/common/icons/BrandIcons';
import { getCurrencyConfig } from '../../helpers/render';
import { formatNumber, toFiniteNumber } from '../../helpers/safeDisplay';
import { CUSTOMER_SERVICE_OPEN_EVENT } from '../../components/customer-service';
import { showInfo } from '../../helpers';
import AmountCard from './AmountCard';
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
const formatCny = (value) =>
`¥${Number(value || 0).toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
const formatCny = (value) => {
const number = toFiniteNumber(value);
if (number === null) return '-';
return (
'¥' +
number.toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})
);
};
// 需要发票时的联系提示(原型:充值订单按钮下方)
export const InvoiceNote = ({ t }) => (
@@ -126,19 +133,21 @@ const RechargePanel = ({
// ---- 充值订单:仅由已选档位、金额与支付方式派生展示 ----
const { symbol } = getCurrencyConfig();
const preset = selectedPreset !== null ? selectedPresetObj : null;
const presetValue = toFiniteNumber(preset?.value) ?? 0;
const discount =
preset?.discount || topupInfo?.discount?.[preset?.value] || 1.0;
toFiniteNumber(preset?.discount ?? topupInfo?.discount?.[preset?.value]) ??
1.0;
const isNewVersion = preset?.id !== undefined;
const originalPrice = preset
? isNewVersion
? preset.value
: preset.value * priceRatio
? presetValue
: presetValue * (toFiniteNumber(priceRatio) ?? 0)
: 0;
const arrivalText = preset
? preset.label ||
(isNewVersion
? formatCny(preset.value)
: `${symbol}${Number(preset.value).toLocaleString('en-US')}`)
: `${symbol}${presetValue.toLocaleString('en-US')}`)
: '-';
const selectedMethod = payMethods?.find((method) => method.type === payWay);
const payPalQuoted = payWay === 'paypal' && payPalQuote;
@@ -149,7 +158,7 @@ const RechargePanel = ({
? payPalQuoted
? {
symbol: '$',
value: Number(payPalQuote.payAmount).toFixed(2),
value: formatNumber(payPalQuote.payAmount, 2, '0.00'),
unit: 'USD',
}
: null
@@ -300,7 +309,7 @@ const RechargePanel = ({
{payPalQuoted && (
<div>
<dt>{t('支付服务费')}</dt>
<dd>{`$${Number(payPalQuote.serviceFee).toFixed(2)} USD`}</dd>
<dd>{`$${formatNumber(payPalQuote.serviceFee, 2, '0.00')} USD`}</dd>
</div>
)}
</dl>
+20 -7
View File
@@ -34,6 +34,11 @@ import {
import { useTranslation } from 'react-i18next';
import { UserContext } from '../../context/User';
import { API, showError, showSuccess, renderQuota } from '../../helpers';
import {
formatCurrency,
formatNumber,
toFiniteNumber,
} from '../../helpers/safeDisplay';
import WechatQRModal from '../../components/topup/modals/WechatQRModal';
import './RechargeV2.css';
@@ -263,7 +268,11 @@ const RechargeV2 = () => {
}}
>
{t('{{rate}}折优惠', {
rate: (option.discount * 10).toFixed(1),
rate: formatNumber(
(toFiniteNumber(option.discount) ?? 1) * 10,
1,
'10.0',
),
})}
</div>
)}
@@ -288,13 +297,17 @@ const RechargeV2 = () => {
<Space vertical align='start' spacing='medium'>
<div>
<Text type='secondary'>{t('原价:')}</Text>
<Text delete>¥{payInfo.original_money.toFixed(2)}</Text>
<Text delete>{formatCurrency(payInfo.original_money)}</Text>
</div>
<div>
<Text type='secondary'>{t('折扣:')}</Text>
<Text strong>
{t('{{rate}}折', {
rate: (payInfo.discount_rate * 10).toFixed(1),
rate: formatNumber(
(toFiniteNumber(payInfo.discount_rate) ?? 1) * 10,
1,
'10.0',
),
})}
</Text>
</div>
@@ -304,18 +317,18 @@ const RechargeV2 = () => {
style={{ fontSize: 24, color: 'var(--ui-color-danger)' }}
strong
>
¥{payInfo.pay_money.toFixed(2)}
{formatCurrency(payInfo.pay_money)}
</Text>
</div>
<div>
<Text type='secondary'>{t('获得额度:')}</Text>
<Text strong>{renderQuota(payInfo.quota)}</Text>
</div>
{payInfo.save_money > 0 && (
{(toFiniteNumber(payInfo.save_money) ?? 0) > 0 && (
<div>
<Text type='secondary'>{t('节省:')}</Text>
<Text style={{ color: 'var(--ui-color-success)' }}>
¥{payInfo.save_money.toFixed(2)}
{formatCurrency(payInfo.save_money)}
</Text>
</div>
)}
@@ -390,7 +403,7 @@ const RechargeV2 = () => {
? t('处理中...')
: calculating
? t('计算中...')
: `${t('支付')} ¥${payInfo?.pay_money?.toFixed(2) || '0.00'}`}
: `${t('支付')} ${formatCurrency(payInfo?.pay_money, '¥', 2, '¥0.00')}`}
</Button>
</div>
</Card>
+25 -21
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, toFiniteNumber } from '../../helpers/safeDisplay';
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import {
@@ -96,7 +97,7 @@ const StatusBars = ({ dataPoints = [], loading = false, t }) => {
<div className='text-xs p-1'>
<div style={{ color: bgColor }} className='font-semibold'>
{isHealthy ? t('正常') : t('异常')} (
{point.uptime_percent?.toFixed(1)}
{formatPercent(point.uptime_percent, 1).replace('%', '')}
{I18N_TECHNICAL_TEXT.PERCENT_CLOSE}
</div>
<div className='text-gray-400 mt-1'>
@@ -351,25 +352,28 @@ const GroupMonitor = () => {
title: t('可用率'),
dataIndex: 'uptime_percent',
key: 'uptime_percent',
render: (value) => (
<div className='flex items-center gap-2'>
<div className='w-16 h-1.5 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden'>
<div
className='h-full rounded-full'
style={{
width: `${Math.min(100, value || 0)}%`,
backgroundColor: getUptimeColor(value),
}}
/>
render: (value) => {
const uptime = Math.max(0, Math.min(100, toFiniteNumber(value) ?? 0));
return (
<div className='flex items-center gap-2'>
<div className='w-16 h-1.5 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden'>
<div
className='h-full rounded-full'
style={{
width: `${uptime}%`,
backgroundColor: getUptimeColor(uptime),
}}
/>
</div>
<span
className='text-sm font-medium'
style={{ color: getUptimeColor(uptime) }}
>
{formatPercent(uptime, 1)}
</span>
</div>
<span
className='text-sm font-medium'
style={{ color: getUptimeColor(value) }}
>
{(value || 0).toFixed(1)}%
</span>
</div>
),
);
},
sorter: (a, b) => (a.uptime_percent || 0) - (b.uptime_percent || 0),
},
{
@@ -511,7 +515,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 +595,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
@@ -47,6 +47,7 @@ import {
showSuccess,
} from '../../../helpers';
import { mergePayPalFeePolicyFormValues } from '../../../helpers/paypalPayment';
import { formatPercent } from '../../../helpers/safeDisplay';
const { Text } = Typography;
const SECRET_PLACEHOLDER = '***ALREADY_SET***';
@@ -563,7 +564,7 @@ export default function SettingsPaymentGatewayPayPal(props) {
{
title: t('费率'),
dataIndex: 'new_rate_bps',
render: (value) => `${(Number(value) / 100).toFixed(2)}%`,
render: (value) => formatPercent(Number(value) / 100, 2),
},
{
title: t('操作人'),
@@ -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' },
{
+7 -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 { formatIdReference } from '../../../helpers/safeDisplay';
// 系统设置 →「WeyAi」页签 →「账号接入」子页签(方案 M8;M21 起从「系统设置」页签搬到这里)。只对超级管理员展示;
// 这些 key 在后端登记为 root-only(setting/console_setting/admin_delegation.go)。
@@ -250,7 +251,11 @@ function AccessGroupSelect({ id, value, onChange, groupOptions, placeholder }) {
);
}
const orgOptionLabel = (org) => `${org.name || ''} (#${org.id})`;
const orgOptionLabel = (org) => {
const name = org?.name?.trim();
const reference = formatIdReference(org?.id);
return name ? `${name} (${reference})` : reference;
};
// 开放企业多选:远程搜索管理端企业列表(名称 / 代码 / 联系人),值只存企业 ID。
// 已保存的企业由父组件按 ID 批量回填名称(orgLabels),已删除的企业回显为
@@ -338,7 +343,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) => {
@@ -354,7 +354,7 @@ const SettingsWeyAiContent = () => {
style={{ minWidth: 260 }}
optionList={(overview?.slots || []).map((s) => ({
value: s.id,
label: `${t(s.name)}(${s.item_count})`,
label: `${t(s.name)}(${s.item_count ?? 0})`,
}))}
/>
</div>
+6 -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 { ConsolePageActions } from '../../components/console/ConsolePageContainer';
import React, { useCallback, useEffect, useRef, useState } from 'react';
@@ -35,6 +36,7 @@ import {
import { IconPlus, IconRefresh, IconSearch } from '@/components/ui/icons';
import { useTranslation } from 'react-i18next';
import { API } from '../../helpers';
import { formatNumber } from '../../helpers/safeDisplay';
import { skillTagLabel } from '../../constants/skillCategories';
import {
CapabilityTags,
@@ -739,7 +741,7 @@ const SkillPlatform = () => {
{ value: '', label: t('全部分类') },
...tagFacets.map((facet) => ({
value: facet.tag,
label: `${skillTagLabel(facet.tag, tagLanguage)}(${facet.count})`,
label: `${skillTagLabel(facet.tag, tagLanguage)}(${facet.count ?? 0})`,
})),
]}
/>
@@ -1286,7 +1288,7 @@ const SkillPlatform = () => {
{ value: 0, label: t('自动路由(按模型自动选择渠道)') },
...testChannels.map((channel) => ({
value: channel.id,
label: `#${channel.id} ${channel.name}`,
label: `${formatIdReference(channel.id)} ${channel.name}`,
})),
]}
/>
@@ -1336,7 +1338,8 @@ const SkillPlatform = () => {
{modelTestResult.ok ? t('测试成功') : t('测试失败')}
</Text>
<Text type='tertiary' size='small'>
{t('耗时')} {modelTestResult.elapsed.toFixed(2)}s
{t('耗时')} {formatNumber(modelTestResult.elapsed, 2, '0.00')}
s
{modelTestResult.usage?.total_tokens
? ` · ${modelTestResult.usage.total_tokens} tokens`
: ''}
+2 -1
View File
@@ -30,6 +30,7 @@ import {
import { Iconbolt, IconActivity } from '@/components/ui/icons';
import { useTranslation } from 'react-i18next';
import { API, showError } from '../../helpers';
import { formatPercent } from '../../helpers/safeDisplay';
const { Content } = Layout;
const { Text, Title } = Typography;
@@ -84,7 +85,7 @@ const Status = () => {
size='small'
style={{ height: 8 }}
showInfo={true}
format={(per) => `${per}%`}
format={(per) => formatPercent(per, 0)}
/>
</div>
);
+190 -162
View File
@@ -16,6 +16,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import {
formatIdReference,
formatUserReference,
} from '../../helpers/safeDisplay';
import { Trans } from 'react-i18next';
import {
@@ -27,16 +31,20 @@ import {
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 { 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 { formatCurrency } from '../../helpers/safeDisplay';
import { useNavigate } from 'react-router-dom';
import { CreditCard, Search, Sparkles, History } from 'lucide-react';
import { CreditCard, Search, History } from 'lucide-react';
import {
Button,
Checkbox,
@@ -48,7 +56,6 @@ import {
Popconfirm,
Select,
Space,
Table,
Tag,
TextArea,
Timeline,
@@ -125,6 +132,7 @@ const RemainingTag = ({ endDate, status, t }) => {
const Subscription = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const isMobile = useIsMobile();
const admin = isAdmin();
// 列表数据
@@ -355,7 +363,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}
@@ -419,10 +427,11 @@ const Subscription = () => {
title: t('支付金额'),
dataIndex: 'price_paid',
width: 100,
render: (v) => (v != null ? `¥${Number(v).toFixed(2)}` : '-'),
render: (v) => (v != null ? formatCurrency(v) : '-'),
},
{
title: t('操作'),
key: 'actions',
width: 300,
fixed: 'right',
render: (_, r) => (
@@ -493,164 +502,175 @@ const Subscription = () => {
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}
/>
</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={16} />}
onClick={() => navigate('/console/setting?tab=membership')}
>
{t('会员管理')}
</Button>
<Button
type='primary'
icon={<ActionPlus size={16} />}
onClick={openCreate}
>
{t('新建会员')}
</Button>
</div>
)}
</div>
}
paginationArea={createCardProPagination({
currentPage: page,
pageSize,
total,
onPageChange: setPage,
onPageSizeChange: (size) => {
setPage(1);
setPageSize(size);
},
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 +998,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 +1389,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>
@@ -1418,7 +1444,7 @@ const DetailDrawer = ({ visible, row, loading, auditLogs, onClose, t }) => {
</div>
<div className='flex justify-between'>
<span className='text-gray-500'>{t('支付金额')}</span>
<span>¥{Number(row.price_paid || 0).toFixed(2)}</span>
<span>{formatCurrency(row.price_paid, '¥', 2, '¥0.00')}</span>
</div>
<div className='flex justify-between'>
<span className='text-gray-500'>{t('支付方式')}</span>
@@ -1481,7 +1507,9 @@ const DetailDrawer = ({ visible, row, loading, auditLogs, onClose, t }) => {
<span className='ml-2 text-gray-700 dark:text-gray-200'>
{log.admin_display_name ||
log.admin_username ||
`Admin#${log.admin_id}`}
(log.admin_id == null
? t('未知管理员')
: `Admin${formatIdReference(log.admin_id)}`)}
</span>
</div>
{log.reason && (
+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>
+11 -6
View File
@@ -50,6 +50,11 @@ import {
INVOICE_STATUS_COLOR,
} from '../../constants';
import { StatusContext } from '../../context/Status';
import {
formatCurrency,
formatNumber,
toFiniteNumber,
} from '../../helpers/safeDisplay';
const { Text } = Typography;
@@ -150,7 +155,7 @@ const Invoice = () => {
// 计算选中记录的金额合计
const selectedAmount = availableTopups
.filter((t) => selectedTopupIds.includes(t.id))
.reduce((sum, t) => sum + (t.money || 0), 0);
.reduce((sum, t) => sum + (toFiniteNumber(t.money) ?? 0), 0);
// 选择常用开票信息
const handleSelectTitle = (titleId) => {
@@ -315,7 +320,7 @@ const Invoice = () => {
title: t('支付金额'),
dataIndex: 'money',
width: 100,
render: (v) => (v ? `¥${Number(v).toFixed(2)}` : '-'),
render: (v) => formatCurrency(v),
},
{
title: t('订单号'),
@@ -343,7 +348,7 @@ const Invoice = () => {
title: t('开票金额'),
dataIndex: 'amount',
width: 100,
render: (v) => `¥${Number(v).toFixed(2)}`,
render: (v) => formatCurrency(v),
},
{
title: t('状态'),
@@ -449,7 +454,7 @@ const Invoice = () => {
<span className='text-lg font-bold text-amber-600 dark:text-amber-400'>
{t('合计')}
{I18N_TECHNICAL_TEXT.CNY_TOTAL_SEPARATOR}
{selectedAmount.toFixed(2)}
{formatNumber(selectedAmount, 2, '0.00')}
</span>
</div>
)}
@@ -584,7 +589,7 @@ const Invoice = () => {
<div className='flex justify-between'>
<Text>{t('开票金额')}</Text>
<Text strong className='text-amber-600'>
¥{Number(detailData.amount).toFixed(2)}
{formatCurrency(detailData.amount)}
</Text>
</div>
<div className='flex justify-between'>
@@ -640,7 +645,7 @@ const Invoice = () => {
)}
</span>
<span className='font-medium'>
¥{Number(topup.money).toFixed(2)}
{formatCurrency(topup.money)}
</span>
</div>
))}
+1 -15
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 */
@@ -243,14 +243,6 @@ html.dark .usage-record-consume-card {
background: var(--ur-consume-neutral-bg);
color: var(--ur-text);
}
.usage-logs-table.usage-record-table .usage-record-use-time .ant-tag {
margin-inline-end: 0;
padding: 0 6px;
font-size: 12px;
font-weight: 500;
font-variant-numeric: tabular-nums;
line-height: 22px;
}
.usage-logs-table.usage-record-table .usage-record-cost {
color: var(--ur-cost);
}
@@ -306,12 +298,6 @@ html.dark .usage-record-consume-card {
font-family: var(--ui-font-family-mono);
font-size: 11px;
}
.usage-record-use-time {
display: inline-flex;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.usage-record-cost {
color: var(--ur-cost);
font-weight: 600;
+16 -46
View File
@@ -36,11 +36,13 @@ import {
UserRound,
Receipt,
Gift,
Activity,
MonitorDown,
} from 'lucide-react';
import { StatusContext } from '../../context/Status';
import { UserContext } from '../../context/User';
import { isGroupAllowed } from '../../helpers/navigationVisibility';
import { isSidebarModuleVisible } from '../../helpers/navigationVisibility';
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
import { useWeyAiDownloadEntry } from '../../hooks/common/useWeyAiWebEntry';
@@ -56,46 +58,12 @@ const UserCenterSidebar = () => {
const { visible: weyaiDownloadEnabled } = useWeyAiDownloadEntry();
// 获取侧边栏配置
const sidebarConfig = useMemo(() => {
const defaultConfig = {
enabled: true,
groups: [],
moduleGroups: {},
dashboard: true,
usageRecord: true,
topup: true,
invoice: true,
invite: true,
settings: true,
};
try {
const configStr = statusState?.status?.SidebarModulesAdmin;
if (configStr) {
const config = JSON.parse(configStr);
const uc = config.userCenter || {};
// 向后兼容:只有旧配置同时隐藏了 usageLog 和 taskLog,才隐藏合并后的 usageRecord;
// 只隐藏其中之一时保持显示,避免用户意外失去本应可见的日志入口
if (
uc.usageRecord === undefined &&
uc.usageLog === false &&
uc.taskLog === false
) {
uc.usageRecord = false;
}
const merged = { ...defaultConfig, ...uc };
return {
...merged,
enabled:
merged.enabled !== false &&
isGroupAllowed(merged.groups, userGroup),
};
}
} catch (error) {
// 使用默认配置
}
return defaultConfig;
}, [statusState?.status?.SidebarModulesAdmin, userGroup]);
const sidebarConfig = useMemo(
() =>
normalizeSidebarModulesAdmin(statusState?.status?.SidebarModulesAdmin)
.userCenter,
[statusState?.status?.SidebarModulesAdmin],
);
// 统一单一品牌色高亮(云平台风格):菜单项不再各用一种颜色,
// 激活态统一走 brand(azure),非激活中性灰,靠图标本身区分功能。
@@ -119,6 +87,12 @@ const UserCenterSidebar = () => {
text: t('密钥管理'),
icon: KeyRound,
},
{
itemKey: '/user-center/service-dashboard',
configKey: 'serviceDashboard',
text: t('服务监控'),
icon: Activity,
},
{
itemKey: '/user-center/topup',
configKey: 'topup',
@@ -167,11 +141,7 @@ const UserCenterSidebar = () => {
const inMiniProgram = isMiniProgramWebView();
return allItems.filter(
(item) =>
sidebarConfig[item.configKey] !== false &&
isGroupAllowed(
sidebarConfig.moduleGroups?.[item.configKey],
userGroup,
) &&
isSidebarModuleVisible(sidebarConfig, item.configKey, userGroup) &&
!(inMiniProgram && isMiniProgramPaymentPath(item.itemKey)),
);
}, [allItems, sidebarConfig, userGroup]);
+9 -4
View File
@@ -36,6 +36,8 @@ import {
Receipt,
} from 'lucide-react';
import { StatusContext } from '../../context/Status';
import { UserContext } from '../../context/User';
import { isSidebarModuleVisible } from '../../helpers/navigationVisibility';
import { useMarquee } from '../../hooks/common/useMarquee';
import PageBackground from '../../components/common/PageBackground';
import UserCenterSidebar from './UserCenterSidebar';
@@ -59,6 +61,8 @@ const MobileBottomNav = ({ sidebarConfig }) => {
const { t } = useTranslation();
const location = useLocation();
const navigate = useNavigate();
const [userState] = useContext(UserContext);
const userGroup = userState?.user?.group;
const navItems = [
{
@@ -108,8 +112,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
const inMiniProgram = isMiniProgramWebView();
const visibleNavItems = navItems.filter(
(item) =>
sidebarConfig?.enabled !== false &&
sidebarConfig?.[item.key] !== false &&
isSidebarModuleVisible(sidebarConfig, item.key, userGroup) &&
!(inMiniProgram && isMiniProgramPaymentPath(item.path)),
);
@@ -147,6 +150,8 @@ const MobileBottomNav = ({ sidebarConfig }) => {
const UserCenter = ({ keyManagementMode = false }) => {
const [statusState] = useContext(StatusContext);
const [userState] = useContext(UserContext);
const userGroup = userState?.user?.group;
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
const ucRoute = useLocation().pathname.split('/')[2] || 'dashboard';
@@ -182,7 +187,7 @@ const UserCenter = ({ keyManagementMode = false }) => {
: routePathMap[
userCenterRoutes.find(
(key) =>
userCenterConfig[key] !== false &&
isSidebarModuleVisible(userCenterConfig, key, userGroup) &&
!(
inMiniProgram &&
isMiniProgramPaymentPath(`/user-center/${routePathMap[key]}`)
@@ -193,7 +198,7 @@ const UserCenter = ({ keyManagementMode = false }) => {
? `/user-center/${firstVisiblePath}`
: '/';
const guardUserCenterRoute = (key, element) => {
if (userCenterConfig.enabled === false || userCenterConfig[key] === false) {
if (!isSidebarModuleVisible(userCenterConfig, key, userGroup)) {
return <Navigate to={firstVisibleRoute} replace />;
}
return element;