fix(*): 全量 UI 审查与 undefined 展示异常修复
This commit is contained in:
@@ -45,6 +45,11 @@ import { CHANNEL_OPTIONS } from '../../../constants';
|
||||
import { IconTreeTriangleDown } from '@/components/ui/icons';
|
||||
import { ShuffleBrandIcon } from '../../common/icons/BrandIcons';
|
||||
|
||||
const formatDisplayPercent = (value, digits = 0) => {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? `${number.toFixed(digits)}%` : '-';
|
||||
};
|
||||
|
||||
function ChannelStatusSwitch({ record, manageChannel, t }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
return (
|
||||
@@ -311,7 +316,7 @@ const renderDailyQuota = (record, dailyQuotaInfo, t) => {
|
||||
{t('已使用')}: {formatQuotaCount(info.daily_quota)}
|
||||
</div>
|
||||
<div>
|
||||
{t('使用率')}: {percent}%
|
||||
{t('使用率')}: {formatDisplayPercent(percent)}
|
||||
</div>
|
||||
{isExceeded && (
|
||||
<div style={{ color: 'var(--ui-color-danger)' }}>
|
||||
@@ -327,7 +332,7 @@ const renderDailyQuota = (record, dailyQuotaInfo, t) => {
|
||||
strokeColor={strokeColor}
|
||||
size='small'
|
||||
showInfo
|
||||
format={(percent) => `${percent}%`}
|
||||
format={(percent) => formatDisplayPercent(percent)}
|
||||
/>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
@@ -25,6 +25,11 @@ import { copy, showError, showInfo, showSuccess } from '../../../../helpers';
|
||||
import { MODEL_TABLE_PAGE_SIZE } from '../../../../constants';
|
||||
import './model-test-modal.css';
|
||||
|
||||
const formatTestTime = (value) => {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? number.toFixed(2) : '0.00';
|
||||
};
|
||||
|
||||
const ModelTestModal = ({
|
||||
showModelTestModal,
|
||||
currentTestChannel,
|
||||
@@ -141,7 +146,7 @@ const ModelTestModal = ({
|
||||
{testResult.success && (
|
||||
<Typography.Text type='secondary'>
|
||||
{t('请求时长: {{time}}s', {
|
||||
time: testResult.time.toFixed(2),
|
||||
time: formatTestTime(testResult.time),
|
||||
})}
|
||||
</Typography.Text>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user