fix(ui): 修复登录和并发请求并统一页面展示
调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
@@ -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 } from 'react';
|
||||
@@ -118,7 +119,7 @@ const ChannelConsumption = ({ data, title, icon, t, embedded = false }) => {
|
||||
width: 80,
|
||||
align: 'right',
|
||||
render: (val) => (
|
||||
<span className='text-gray-500'>{(val || 0).toFixed(1)}%</span>
|
||||
<span className='text-gray-500'>{formatPercent(val || 0, 1)}</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -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 React, { useMemo, useState } from 'react';
|
||||
import {
|
||||
@@ -113,7 +114,9 @@ const HighFreqLowCostUsers = ({
|
||||
width: 160,
|
||||
render: (v, row) => (
|
||||
<div className='flex flex-col'>
|
||||
<Text strong>{v || row.username || `user_${row.user_id}`}</Text>
|
||||
<Text strong>
|
||||
{formatUserReference(v || row.username, row.user_id, t('未知用户'))}
|
||||
</Text>
|
||||
{row.username && v && row.username !== v && (
|
||||
<Text type='tertiary' size='small'>
|
||||
@{row.username}
|
||||
|
||||
@@ -21,6 +21,7 @@ import React, { useMemo } from 'react';
|
||||
import { Card } from '@/components/ui';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
import { renderQuota } from '../../helpers';
|
||||
import { formatPercent } from '../../helpers/safeDisplay';
|
||||
|
||||
const ModelDistribution = ({ data, title, icon, t }) => {
|
||||
const pieSpec = useMemo(() => {
|
||||
@@ -119,12 +120,12 @@ const ModelDistribution = ({ data, title, icon, t }) => {
|
||||
<span className='text-xs text-gray-500 w-4'>{index + 1}</span>
|
||||
<span
|
||||
className='text-sm flex-1 truncate'
|
||||
title={item.model_name}
|
||||
title={item.model_name || t('未知')}
|
||||
>
|
||||
{item.model_name}
|
||||
{item.model_name || t('未知')}
|
||||
</span>
|
||||
<span className='text-xs text-gray-500'>
|
||||
{item.percent?.toFixed(1)}%
|
||||
{formatPercent(item.percent, 1)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { formatPercent } from '../../helpers/safeDisplay';
|
||||
import React, { useState, useCallback } from 'react';
|
||||
import { Badge, Empty, Progress, Skeleton, Tag, Tooltip, theme } from 'antd';
|
||||
import { ArrowDown } from 'lucide-react';
|
||||
@@ -275,7 +276,7 @@ const OrgRealtimeUsage = ({
|
||||
className='text-sm font-semibold group-hover:underline'
|
||||
style={{ color: cacheRateColor(rate, token) }}
|
||||
>
|
||||
{rate.toFixed(1)}%
|
||||
{formatPercent(rate, 1)}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden
|
||||
|
||||
@@ -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 React from 'react';
|
||||
import { Card } from '@/components/ui';
|
||||
@@ -117,7 +118,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
||||
)}
|
||||
<span>
|
||||
{isPositive ? '+' : ''}
|
||||
{change.toFixed(1)}%
|
||||
{formatPercent(change, 1)}
|
||||
</span>
|
||||
</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 { formatUserReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import React, { useState } from 'react';
|
||||
@@ -246,7 +247,9 @@ const RiskControlBanLogs = ({
|
||||
<div>
|
||||
<Text type='tertiary'>{t('用户:')}</Text>
|
||||
<Text strong>
|
||||
{unbanRow.user_snapshot || `user_${unbanRow.user_id}`}(ID:
|
||||
{unbanRow.user_snapshot ||
|
||||
formatUserReference('', unbanRow.user_id, t('未知用户'))}
|
||||
(ID:
|
||||
{unbanRow.user_id})
|
||||
</Text>
|
||||
</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 { formatUserReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
@@ -104,9 +105,13 @@ const UserRanking = ({ data, title, icon, t }) => {
|
||||
<div className='flex items-center justify-between'>
|
||||
<span
|
||||
className='text-sm font-medium truncate'
|
||||
title={`${item.display_name || item.username || 'User'} (ID: ${item.user_id})`}
|
||||
title={`${formatUserReference(item.display_name || item.username, item.user_id, t('未知用户'))}`}
|
||||
>
|
||||
{item.display_name || item.username || `User ${item.user_id}`}
|
||||
{formatUserReference(
|
||||
item.display_name || item.username,
|
||||
item.user_id,
|
||||
t('未知用户'),
|
||||
)}
|
||||
<span className='text-xs text-gray-400 ml-1'>
|
||||
#{item.user_id}
|
||||
</span>
|
||||
|
||||
@@ -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 React, { useMemo, useState, useEffect, useCallback } from 'react';
|
||||
import { Card, Spin, Tag, Progress } from '@/components/ui';
|
||||
@@ -130,7 +131,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
},
|
||||
{
|
||||
key: () => t('占比'),
|
||||
value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`,
|
||||
value: (datum) => formatPercent(datum?.percentage || 0, 1),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -186,7 +187,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
},
|
||||
{
|
||||
key: () => t('占比'),
|
||||
value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`,
|
||||
value: (datum) => formatPercent(datum?.percentage || 0, 1),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -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 { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
@@ -80,9 +81,9 @@ const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
|
||||
<div className='flex flex-col'>
|
||||
<span
|
||||
className='font-medium text-sm truncate'
|
||||
title={text || `User ${record.user_id}`}
|
||||
title={formatUserReference(text, record.user_id, t('未知用户'))}
|
||||
>
|
||||
{text || `User ${record.user_id}`}
|
||||
{formatUserReference(text, record.user_id, t('未知用户'))}
|
||||
</span>
|
||||
<span className='text-xs text-gray-400 truncate'>
|
||||
{I18N_TECHNICAL_TEXT.ID} {record.user_id}
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
} from '@/components/ui';
|
||||
import { ClipboardList } from 'lucide-react';
|
||||
import { ChangeText, OrgNameCell, ReasonTags, SectionCard } from './shared';
|
||||
import { formatRatioPercent } from '../../../helpers/safeDisplay';
|
||||
import {
|
||||
daysSince,
|
||||
downloadCsv,
|
||||
@@ -284,7 +285,11 @@ const columnsFor = (tab, cny, t, atRisk) => {
|
||||
{v}/{r.member_count}
|
||||
{r.member_count > 0 ? (
|
||||
<span className='text-xs text-gray-400 ml-1'>
|
||||
{Math.min(100, (v / r.member_count) * 100).toFixed(0)}%
|
||||
{formatRatioPercent(
|
||||
Math.min(100, Number(v) || 0),
|
||||
r.member_count,
|
||||
0,
|
||||
)}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
|
||||
@@ -31,6 +31,10 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { ChangeText, KpiCard, SectionCard } from './shared';
|
||||
import { formatCny, formatCst, pct, SEGMENTS } from './utils';
|
||||
import {
|
||||
formatPercent,
|
||||
formatRatioPercent,
|
||||
} from '../../../helpers/safeDisplay';
|
||||
|
||||
// ─── 报表抬头:统计口径 + 数据状态 ─────────────────────────────────
|
||||
export const ReportHeader = ({ report, onExport, t }) => {
|
||||
@@ -209,7 +213,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
n: (k.active_orgs || 0).toLocaleString(),
|
||||
count: k.active_orgs || 0,
|
||||
}),
|
||||
sub: `${t('活跃率')} ${pct(k.active_orgs, servingOrgs).toFixed(1)}% · ${t('新增')} ${k.new_orgs || 0}`,
|
||||
sub: `${t('活跃率')} ${formatRatioPercent(k.active_orgs, servingOrgs)} · ${t('新增')} ${k.new_orgs || 0}`,
|
||||
compare: (
|
||||
<ChangeText cur={k.active_orgs} prev={k.prev_active_orgs} t={t} />
|
||||
),
|
||||
@@ -229,7 +233,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
n: (k.active_members || 0).toLocaleString(),
|
||||
count: k.active_members || 0,
|
||||
}),
|
||||
sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||
sub: `${t('渗透率')} ${formatPercent(Math.min(100, pct(k.active_members, k.total_members)))} · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
|
||||
onClick: () => onJump('growth'),
|
||||
},
|
||||
@@ -277,7 +281,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
},
|
||||
{
|
||||
title: t('企业消耗占平台'),
|
||||
value: `${share.toFixed(1)}%`,
|
||||
value: formatPercent(share),
|
||||
sub: `${t('个人消耗')} ${formatCny(k.personal_quota, cny)}`,
|
||||
compare:
|
||||
shareDelta === null ? null : (
|
||||
@@ -341,7 +345,7 @@ export const HealthSegments = ({ report, cny, activeSegment, onSelect, t }) => {
|
||||
{t(meta.label)}
|
||||
</Tag>
|
||||
<span className='text-xs text-gray-400 tabular-nums'>
|
||||
{pct(s.count, totalCount).toFixed(0)}%
|
||||
{formatPercent(pct(s.count, totalCount), 0)}
|
||||
</span>
|
||||
</div>
|
||||
<div className='mt-2 text-lg font-bold text-gray-800 dark:text-gray-100 tabular-nums'>
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
} from '@/components/ui';
|
||||
import { Search, Table2, UserCog } from 'lucide-react';
|
||||
import { ChangeText, OrgNameCell, SectionCard } from './shared';
|
||||
import { formatPercent } from '../../../helpers/safeDisplay';
|
||||
import {
|
||||
ALERT_LEVELS,
|
||||
ORG_STATUS,
|
||||
@@ -266,7 +267,7 @@ export const OrgDetailTable = ({ report, filter, setFilter, cny, t }) => {
|
||||
align: 'right',
|
||||
render: (v) =>
|
||||
v > 0 ? (
|
||||
<span className='tabular-nums'>{v.toFixed(1)}%</span>
|
||||
<span className='tabular-nums'>{formatPercent(v, 1)}</span>
|
||||
) : (
|
||||
<Text type='tertiary'>—</Text>
|
||||
),
|
||||
@@ -501,8 +502,8 @@ export const exportOrgDetail = (rows, cny, t) => {
|
||||
SEGMENTS[o.segment] ? t(SEGMENTS[o.segment].label) : '',
|
||||
yuan(o.quota),
|
||||
yuan(o.prev_quota),
|
||||
rate === null ? '' : `${rate.toFixed(1)}%`,
|
||||
o.share ? `${o.share.toFixed(2)}%` : '',
|
||||
rate === null ? '' : formatPercent(rate, 1),
|
||||
o.share ? formatPercent(o.share, 2) : '',
|
||||
o.requests,
|
||||
o.active_members,
|
||||
o.member_count,
|
||||
|
||||
@@ -21,6 +21,7 @@ import React from 'react';
|
||||
import { Card, Tag, Tooltip } from '@/components/ui';
|
||||
import { TrendingDown, TrendingUp } from 'lucide-react';
|
||||
import { changeRate, ORG_STATUS, orgDisplayName, REASONS } from './utils';
|
||||
import { formatPercent } from '../../../helpers/safeDisplay';
|
||||
|
||||
export const SectionCard = ({
|
||||
id,
|
||||
@@ -90,7 +91,7 @@ export const ChangeText = ({ cur, prev, t, size = 'xs', showNew = true }) => {
|
||||
<TrendingDown className='w-3 h-3' />
|
||||
)}
|
||||
{up ? '+' : ''}
|
||||
{rate.toFixed(1)}%
|
||||
{formatPercent(rate, 1)}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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';
|
||||
|
||||
// 企业经营决策报表:口径常量、行动清单派生、要点生成、CSV 导出
|
||||
|
||||
@@ -52,7 +54,15 @@ export const formatRate = (rate) =>
|
||||
? '—'
|
||||
: `${rate >= 0 ? '+' : ''}${rate.toFixed(1)}%`;
|
||||
|
||||
export const pct = (part, total) => (total > 0 ? (part / total) * 100 : 0);
|
||||
export const pct = (part, total) => {
|
||||
const numerator = Number(part);
|
||||
const denominator = Number(total);
|
||||
return Number.isFinite(numerator) &&
|
||||
Number.isFinite(denominator) &&
|
||||
denominator > 0
|
||||
? (numerator / denominator) * 100
|
||||
: 0;
|
||||
};
|
||||
|
||||
// ─── 时间(报表口径统一为 UTC+8,与浏览器时区无关) ─────────────────
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
@@ -405,11 +415,11 @@ export const deriveFindings = (report, lists, cny, t) => {
|
||||
? t(
|
||||
'头部依赖较高:Top5 企业贡献 {{share}} 的企业消耗,需关注大客户稳定性',
|
||||
{
|
||||
share: `${k.top5_share.toFixed(1)}%`,
|
||||
share: formatPercent(k.top5_share, 1),
|
||||
},
|
||||
)
|
||||
: t('客户结构较分散:Top5 企业贡献 {{share}} 的企业消耗', {
|
||||
share: `${k.top5_share.toFixed(1)}%`,
|
||||
share: formatPercent(k.top5_share, 1),
|
||||
}),
|
||||
target: 'tiers',
|
||||
});
|
||||
@@ -426,7 +436,7 @@ export const deriveFindings = (report, lists, cny, t) => {
|
||||
text: t(
|
||||
'企业成员渗透率 {{rate}},{{count}} 家企业成员活跃率低于 30%,存在增量空间',
|
||||
{
|
||||
rate: `${Math.min(100, penetration).toFixed(1)}%`,
|
||||
rate: formatPercent(Math.min(100, penetration), 1),
|
||||
count: lowPen,
|
||||
},
|
||||
),
|
||||
@@ -467,4 +477,6 @@ export const downloadCsv = (filename, headers, rows) => {
|
||||
};
|
||||
|
||||
export const orgDisplayName = (o, t) =>
|
||||
o.deleted ? `${t('已删除企业')} #${o.org_id}` : o.name || `#${o.org_id}`;
|
||||
o.deleted
|
||||
? `${t('已删除企业')} ${formatIdReference(o.org_id)}`
|
||||
: o.name || formatIdReference(o.org_id);
|
||||
|
||||
Reference in New Issue
Block a user