fix(ui): 修复固定列表头并优化官网指标配置

This commit is contained in:
zhanjunhao
2026-11-17 17:47:57 +08:00
parent d0ef462921
commit 914e5e2c67
28 changed files with 351 additions and 108 deletions
+1 -1
View File
@@ -230,7 +230,7 @@
margin-inline-start: auto;
}
.console-page .console-table .ant-table-thead > tr > th {
background: var(--console-fill);
--center-table-head-bg: var(--console-fill);
color: var(--console-muted);
font-weight: 500;
}
@@ -96,16 +96,6 @@
opacity: 0.65;
}
/* Sticky headers need an opaque surface below the translucent header tint. */
.console-page[data-console-page='models']
.console-table
.ant-table-thead
> tr
> th.ant-table-cell-fix-right {
background-color: var(--console-surface);
background-image: linear-gradient(var(--console-fill), var(--console-fill));
}
.models-vendor-actions {
display: flex;
flex-shrink: 0;
+28 -22
View File
@@ -68,29 +68,34 @@ const CenterTable = forwardRef(function CenterTable(
const cells = [...root.querySelectorAll(`td.${marker}`)].filter(
(element) => element.getBoundingClientRect().width > 0,
);
const cell = cells.find((candidate) =>
candidate.querySelector('button, a, [role="button"]'),
);
const controls = cell
? [...cell.querySelectorAll('button, a, [role="button"]')].filter(
(element) => element.getBoundingClientRect().width > 0,
)
: [];
const cellStyle = getComputedStyle(cell || header);
const padding =
(Number.parseFloat(cellStyle.paddingLeft) || 0) +
(Number.parseFloat(cellStyle.paddingRight) || 0);
const gap = Number.parseFloat(cellStyle.columnGap) || 8;
const contentWidth = controls.length
? controls.reduce(
const widths = cells.map((cell) => {
const controls = [
...cell.querySelectorAll('button, a, [role="button"]'),
].filter((element) => element.getBoundingClientRect().width > 0);
if (!controls.length) return 0;
let group = controls[0].parentElement;
while (
group !== cell &&
!controls.every((control) => group.contains(control))
)
group = group.parentElement;
const cellStyle = getComputedStyle(cell);
const padding =
(Number.parseFloat(cellStyle.paddingLeft) || 0) +
(Number.parseFloat(cellStyle.paddingRight) || 0);
const gap = Number.parseFloat(getComputedStyle(group).columnGap) || 8;
return (
controls.reduce(
(total, element) => total + element.getBoundingClientRect().width,
0,
) +
gap * Math.max(0, controls.length - 1)
: Math.max(...cells.map((candidate) => candidate.scrollWidth), 0) -
padding;
next[marker.replace('center-fixed-index-', '')] =
contentWidth + padding;
gap * Math.max(0, controls.length - 1) +
padding
);
});
const measured = Math.max(...widths, 0);
if (measured > 0)
next[marker.replace('center-fixed-index-', '')] = measured;
});
setMeasuredActionWidths((current) => {
const same =
@@ -101,15 +106,16 @@ const CenterTable = forwardRef(function CenterTable(
return same ? current : next;
});
};
requestAnimationFrame(measureActionWidths);
const frame = requestAnimationFrame(measureActionWidths);
const observer = new ResizeObserver(update);
observer.observe(root);
return () => {
observer.disconnect();
cancelAnimationFrame(frame);
if (scroller && previousTabIndex === null)
scroller.removeAttribute('tabindex');
};
}, [enabled, width]);
}, [enabled, width, columns, props.dataSource]);
return (
<Table
{...props}
+14 -10
View File
@@ -3,30 +3,34 @@
max-width: 100%;
}
.center-action-table .ant-table-tbody > tr > .center-fixed-cell {
z-index: 2;
.center-action-table .ant-table-tbody > tr > .ant-table-cell-fix {
background: var(--center-table-bg);
background-clip: padding-box;
}
.center-action-table .ant-table-thead > tr > .center-fixed-cell {
z-index: 3;
background: var(--ur-head-bg, var(--center-table-head-bg));
.center-action-table .ant-table-thead > tr > .ant-table-cell {
/* Composite the header tint over an opaque surface, including sticky cells. */
background-color: var(--center-table-bg);
background-image: linear-gradient(
var(--center-table-head-bg),
var(--center-table-head-bg)
);
background-clip: padding-box;
white-space: nowrap;
}
.center-action-table .ant-table-tbody > tr:hover > .center-fixed-cell {
.center-action-table .ant-table-tbody > tr:hover > .ant-table-cell-fix {
background: var(--center-table-hover-bg);
}
.center-action-table
.ant-table-tbody
> tr.ant-table-row-selected
> .center-fixed-cell {
> .ant-table-cell-fix {
background: var(--center-table-selected-bg);
}
.center-action-table .center-fixed-cell {
.center-action-table .ant-table-tbody > tr > .center-fixed-cell {
white-space: normal;
overflow-wrap: anywhere;
}
@@ -50,6 +54,6 @@
.admin-tokens-row-actions,
.website-insights-row-actions
) {
flex-wrap: nowrap;
max-width: none;
flex-wrap: wrap;
max-width: 100%;
}
+26 -2
View File
@@ -89,11 +89,15 @@ const markFixedRight = (
index,
action = false,
measuredWidths = {},
containerWidth = 0,
) => ({
...column,
fixed: 'right',
width: action
? actionWidth(column, measuredWidths[index])
? Math.min(
actionWidth(column, measuredWidths[index]),
containerWidth > 0 ? Math.max(56, containerWidth) : Infinity,
)
: columnWidth(column),
...(action ? { title: i18next.t('操作') || '操作' } : {}),
className: [
@@ -110,6 +114,22 @@ export function prepareCenterColumns(columns, width = 0, measuredWidths = {}) {
const leaves = leafColumns(columns);
const last = leaves.at(-1);
const hasAction = last && isActionColumn(last);
const pinnedWidth = hasAction
? leaves.reduce(
(total, column, index) =>
total +
(column === last
? Math.min(
actionWidth(column, measuredWidths[index]),
width || Infinity,
)
: column.fixed
? columnWidth(column)
: 0),
0,
)
: 0;
const releaseOtherFixed = width > 0 && pinnedWidth > width;
const estimatedTotal = leaves.reduce(
(total, column) => total + columnWidth(column),
0,
@@ -125,8 +145,12 @@ export function prepareCenterColumns(columns, width = 0, measuredWidths = {}) {
return { ...column, children: column.children.map(mapColumn) };
const columnIndex = index++;
if (hasAction && column === last)
return markFixedRight(column, columnIndex, true, measuredWidths);
return markFixedRight(column, columnIndex, true, measuredWidths, width);
if (fallback.has(column)) return markFixedRight(column, columnIndex);
if (releaseOtherFixed && column.fixed) {
const { fixed: _fixed, ...scrollable } = column;
return scrollable;
}
if (column.fixed) return { ...column, width: columnWidth(column) };
return column;
});
+4
View File
@@ -10710,6 +10710,10 @@
"点击图片可放大预览": "Click on the image to enlarge the preview",
"官网设置已保存": "The official website settings have been saved",
"研发人员占比": "Proportion of R & D personnel",
"官网展示:{{value}}": "Website display: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D ratio {{ratio}}",
"降幅": "reduction",
"首页与关于微词元共用": "shared by Home and About",
"四个页签共用一份配置,保存时将统一校验并提交。": "All four tabs share one configuration. Saving validates and submits all settings together.",
"富文本工具栏": "Rich text toolbar",
"正文段落": "Body paragraph",
+4
View File
@@ -10599,6 +10599,10 @@
"点击图片可放大预览": "Cliquez sur l'image pour agrandir l'aperçu",
"官网设置已保存": "Les paramètres du site officiel sont sauvegardés",
"研发人员占比": "Proportion de personnel R & D",
"官网展示:{{value}}": "Affichage sur le site : {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · part R&D {{ratio}}",
"降幅": "baisse",
"首页与关于微词元共用": "partagé entre Accueil et À propos",
"四个页签共用一份配置,保存时将统一校验并提交。": "Les quatre onglets partagent une configuration et sont soumis uniformément à la vérification et à la validation lorsqu 'ils sont sauvegardés.",
"结算状态: {{label}}": "Statut du règlement: {{label}}",
"确认未生效:授权、凭据或操作内容已变化,请刷新任务后重试。": "La confirmation n'est pas effective: l'autorisation, les informations d'identification ou le contenu de l'action ont changé, veuillez actualiser la tâche et réessayer.",
+4
View File
@@ -10684,6 +10684,10 @@
"点击图片可放大预览": "画像をクリックしてプレビューを拡大",
"官网设置已保存": "WEB保存済みです。",
"研发人员占比": "開発スタッフの割合",
"官网展示:{{value}}": "公式サイト表示:{{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研究開発比率 {{ratio}}",
"降幅": "削減率",
"首页与关于微词元共用": "ホームと会社概要で共用",
"四个页签共用一份配置,保存时将统一校验并提交。": "4つのタブは1つの構成を共有し、保存時に均一に検証およびコミットされます。",
"富文本工具栏": "リッチテキストツールバー",
"正文段落": "本文段落",
+4
View File
@@ -10685,6 +10685,10 @@
"点击图片可放大预览": "이미지를 클릭하여 미리보기를 확대합니다.",
"官网设置已保存": "공식 웹사이트 설정이 저장되었습니다.",
"研发人员占比": "R&D 인력의 비율",
"官网展示:{{value}}": "웹사이트 표시: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D 비율 {{ratio}}",
"降幅": "감소폭",
"首页与关于微词元共用": "홈과 회사 소개에서 공용",
"四个页签共用一份配置,保存时将统一校验并提交。": "네 개의 탭은 구성을 공유하며, 이 구성은 저장 시 확인되고 제출됩니다.",
"富文本工具栏": "서식 있는 텍스트 도구 모음",
"正文段落": "본문 단락",
+4
View File
@@ -10351,6 +10351,10 @@
"点击图片可放大预览": "Нажмите на изображение для увеличения предварительного просмотра",
"官网设置已保存": "Официальный сайт сохранен.",
"研发人员占比": "Доля исследователей",
"官网展示:{{value}}": "На сайте: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · доля R&D {{ratio}}",
"降幅": "снижение",
"首页与关于微词元共用": "общее для главной и раздела «О нас»",
"四个页签共用一份配置,保存时将统一校验并提交。": "Четыре страницы совместно используют один экземпляр конфигурации, при сохранении будет проведена единая проверка и отправка.",
"{{count}} 处非法输入": "{{count}} неверный вход (ы)",
"{{count}} 个已验证渠道": "{{count}} верифицированные каналы",
+4
View File
@@ -10684,6 +10684,10 @@
"点击图片可放大预览": "คลิกที่ภาพเพื่อดูตัวอย่าง",
"官网设置已保存": "บันทึกการตั้งค่าเว็บไซต์อย่างเป็นทางการแล้ว",
"研发人员占比": "สัดส่วนของบุคลากรด้าน R&D",
"官网展示:{{value}}": "แสดงบนเว็บไซต์: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · สัดส่วน R&D {{ratio}}",
"降幅": "ลดลง",
"首页与关于微词元共用": "ใช้ร่วมกันระหว่างหน้าแรกและเกี่ยวกับเรา",
"四个页签共用一份配置,保存时将统一校验并提交。": "แท็บทั้งสี่จะใช้การกําหนดค่าร่วมกันและจะได้รับการตรวจสอบและส่งเมื่อบันทึก",
"富文本工具栏": "แถบเครื่องมือข้อความที่มีรูปแบบ",
"正文段落": "ย่อหน้าเนื้อหา",
+4
View File
@@ -10684,6 +10684,10 @@
"点击图片可放大预览": "Nhấp vào hình ảnh để phóng to bản xem trước",
"官网设置已保存": "Cài đặt trang web chính thức đã được lưu",
"研发人员占比": "Tỷ lệ nhân viên R & D",
"官网展示:{{value}}": "Hiển thị trên website: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · tỷ lệ R&D {{ratio}}",
"降幅": "mức giảm",
"首页与关于微词元共用": "dùng chung cho Trang chủ và Giới thiệu",
"四个页签共用一份配置,保存时将统一校验并提交。": "Bốn tab dùng chung một bản sao của bố trí và được kiểm tra và cam kết thống nhất khi bạn lưu lại.",
"富文本工具栏": "Thanh công cụ văn bản có định dạng",
"正文段落": "Đoạn văn bản",
+4
View File
@@ -10684,6 +10684,10 @@
"点击图片可放大预览": "點擊圖片可放大預覽",
"官网设置已保存": "官網設置已保存",
"研发人员占比": "研發人員佔比",
"官网展示:{{value}}": "官網展示:{{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研發佔比 {{ratio}}",
"降幅": "降幅",
"首页与关于微词元共用": "首頁與關於微詞元共用",
"四个页签共用一份配置,保存时将统一校验并提交。": "四個頁籤共用一份配置,保存時將統一校驗並提交。",
"富文本工具栏": "富文字工具列",
"正文段落": "內文段落",
+4
View File
@@ -10598,6 +10598,10 @@
"点击图片可放大预览": "点击图片可放大预览",
"官网设置已保存": "官网设置已保存",
"研发人员占比": "研发人员占比",
"官网展示:{{value}}": "官网展示:{{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研发占比 {{ratio}}",
"降幅": "降幅",
"首页与关于微词元共用": "首页与关于微词元共用",
"四个页签共用一份配置,保存时将统一校验并提交。": "四个页签共用一份配置,保存时将统一校验并提交。",
"富文本工具栏": "富文本工具栏",
"正文段落": "正文段落",
+1 -1
View File
@@ -123,10 +123,10 @@ html.dark .km-page {
/* 表格:表头 46px、底色 #f8f9fc、常规字重;行分隔 #f0f0f0(middle 尺寸 12px 8px) */
.km-table .ant-table-thead > tr > th {
--center-table-head-bg: var(--km-head-bg);
height: 46px;
padding-block: 0;
border-bottom-color: var(--km-row-split);
background: var(--km-head-bg);
color: var(--km-head-text);
font-weight: 400;
}
+1 -2
View File
@@ -180,10 +180,10 @@ html.dark .usage-record-tabs .ant-tabs-ink-bar {
margin: 0;
}
.usage-record-table .ant-table-thead > tr > th {
--center-table-head-bg: var(--ur-head-bg);
height: 46px;
padding-block: 0;
border-bottom-color: var(--ur-row-split);
background: var(--ur-head-bg);
color: var(--ur-head-text);
font-weight: 400;
}
@@ -217,7 +217,6 @@ html.dark .usage-record-consume-card {
> th {
padding-block: 0;
padding-inline: 8px;
background: var(--ur-head-bg);
color: var(--ur-head-text);
font-size: 14px;
}
+9 -3
View File
@@ -27,9 +27,15 @@ teamMembers/researchRatio 映射 about.teamMembers/researchStaffRatio;首页
其余总部、服务网络和商务字段依联调文档映射。保存保留后端返回的未知字段。
严格检查 success === true 后才提示成功,失败保留当前编辑。提交期间防止重复请求。
完整配置按 UTF-8 字节限制为 60 KiB,超限时提示精简内容。
客户数和人数支持正整数及末尾 +;Token 支持正数、万/亿单位及末尾 +。
百分比支持 0~100,最多两位小数,% 可选。上述展示值以字符串提交。
后端以 LONGTEXT 存储完整配置,前端不再限制总大小;单篇正文由编辑器限制为 20000 字。
指标字段只填数字,单位由官网展示(后台输入框右侧灰字同步显示,下方实时预览“官网展示”):
- 付费企业客户、团队成员:大于 0 的整数,不含前导零,存 "300",官网显示 300+。
- 平台日均 Token 调用:大于 0、最多两位小数的数字 + 下拉单位(万/亿,默认亿),合成存 "500亿",官网显示 500亿+。
- 客户月度 AI 调用成本(降幅)、研发人员占比:0~100、最多两位小数,存 "20",官网显示 ↓20% / 60%。
输入时全角数字与句号自动转半角,其他字符直接丢弃。官网尚未对接,不兼容带 + / % 的旧值。
## 二维码上传
+86 -21
View File
@@ -17,10 +17,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import React, { useState } from 'react';
import { Select as AntSelect, Space } from 'antd';
import { Form, Input } from '@/components/ui';
import { useTranslation } from 'react-i18next';
import { FIELDS } from './model';
import {
AMOUNT_UNITS,
FIELDS,
joinAmount,
metricPreview,
sanitizeMetricInput,
splitAmount,
} from './model';
export default function WebsiteField({
name,
@@ -29,18 +37,43 @@ export default function WebsiteField({
onChange,
onBlur,
disabled,
labelSuffix,
preview,
children,
}) {
const { t } = useTranslation();
const field = FIELDS[name];
const metric = field.metric;
const amount = metric?.kind === 'amount' ? splitAmount(value) : null;
// Keep the chosen unit while the number is still empty (the stored value is '' then).
const [pendingUnit, setPendingUnit] = useState(amount?.unit);
const unit = amount?.number ? amount.unit : pendingUnit;
const previewText = preview ?? metricPreview(name, value);
const inputProps = {
id: `website-${name}`,
'aria-label': t(field.label),
'aria-required': true,
'aria-invalid': Boolean(error),
'aria-describedby': error ? `website-${name}-error` : undefined,
onBlur,
disabled,
placeholder: t(field.placeholder),
validateStatus: error ? 'error' : 'default',
showClear: true,
};
const unitAddon = metric ? (
<Space.Addon className='website-metric-unit' aria-hidden='true'>
{metric.suffix}
</Space.Addon>
) : null;
return (
<Form.Slot
label={{
text: (
<>
{t(field.label)}
{labelSuffix}
{field.note ? (
<span className='website-field-note'>({t(field.note)})</span>
) : null}
</>
),
required: true,
@@ -50,24 +83,56 @@ export default function WebsiteField({
error: error ? t(error) : undefined,
errorMessageId: `website-${name}-error`,
}}
extra={
metric ? (
<span className='website-metric-preview' aria-live='polite'>
{previewText
? t('官网展示:{{value}}', { value: previewText })
: ''}
</span>
) : undefined
}
>
{children || (
<Input
id={`website-${name}`}
aria-label={t(field.label)}
aria-required={true}
aria-invalid={Boolean(error)}
aria-describedby={error ? `website-${name}-error` : undefined}
value={value}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
placeholder={t(field.placeholder)}
validateStatus={error ? 'error' : 'default'}
maxLength={name === 'businessEmail' ? 254 : 200}
showClear
/>
)}
{children ||
(metric ? (
<Space.Compact block>
<Input
{...inputProps}
inputMode={metric.kind === 'integer' ? 'numeric' : 'decimal'}
value={amount ? amount.number : value}
maxLength={12}
onChange={(next) => {
const number = sanitizeMetricInput(next);
onChange(amount ? joinAmount(number, unit) : number);
}}
/>
{amount ? (
<AntSelect
className='website-metric-unit-select'
aria-label={t('计量单位')}
value={unit}
disabled={disabled}
status={error ? 'error' : undefined}
options={AMOUNT_UNITS.map((item) => ({
value: item,
label: item,
}))}
onChange={(next) => {
setPendingUnit(next);
if (amount.number) onChange(joinAmount(amount.number, next));
}}
/>
) : null}
{unitAddon}
</Space.Compact>
) : (
<Input
{...inputProps}
value={value}
onChange={onChange}
maxLength={name === 'businessEmail' ? 254 : 200}
/>
))}
</Form.Slot>
);
}
+21 -2
View File
@@ -47,8 +47,27 @@
font-size: 13px;
}
.website-settings-page .website-research-ratio-hint {
opacity: 0.9;
.website-settings-page .website-field-note {
color: var(--ui-color-text-2);
font-weight: 400;
}
.website-settings-page .website-metric-unit {
min-width: 40px;
justify-content: center;
color: var(--ui-color-text-2);
}
.website-settings-page .website-metric-unit-select {
width: 72px;
flex: none;
}
.website-settings-page .website-metric-preview {
display: block;
min-height: 22px;
color: var(--ui-color-text-2);
line-height: 22px;
}
.website-settings-page .website-settings-tab-description {
+16 -7
View File
@@ -32,6 +32,7 @@ import { showError, showSuccess, showWarning } from '../../helpers';
import {
TABS,
emptySettings,
metricPreview,
settingsFromConfig,
serializeSettings,
validateField,
@@ -91,6 +92,17 @@ export default function WebsiteSettings() {
}, [dirty]);
const tab = TABS.find((item) => item.key === activeTab);
// Home team card on the official site: "50+ · 研发占比60%" (ratio is edited in the about tab).
const teamPreview = () => {
const team = metricPreview('teamMembers', values.teamMembers);
if (!team) return '';
const ratio = metricPreview('researchRatio', values.researchRatio);
return t('{{team}} · 研发占比 {{ratio}}', {
team,
ratio: ratio || t('未配置'),
});
};
const change = (name, value) => {
setDirty(true);
setValues((previous) => ({ ...previous, [name]: value }));
@@ -209,13 +221,10 @@ export default function WebsiteSettings() {
>
<WebsiteField
name={name}
labelSuffix={
activeTab === 'home' && name === 'teamMembers' ? (
<span className='website-research-ratio-hint'>
({t('研发人员占比')}:
{values.researchRatio || t('未配置')})
</span>
) : undefined
preview={
activeTab === 'home' && name === 'teamMembers'
? teamPreview()
: undefined
}
value={values[name]}
error={errors[name]}
+54 -16
View File
@@ -51,31 +51,35 @@ export const TABS = [
},
];
// Metric fields store plain numbers; the official site renders "+", "%", "万/亿" itself.
// kind: integer = positive integer, amount = positive number + 万/亿 unit, percent = 0~100.
export const FIELDS = {
paidCustomers: {
label: '付费企业客户',
placeholder: '请输入付费企业客户数量,例如 300+',
help: '正整数,可带 +。',
placeholder: '请输入付费企业客户数量,例如 300',
metric: { kind: 'integer', suffix: '+' },
},
dailyTokens: {
label: '平台日均 Token 调用',
placeholder: '请输入平台日均 Token 调用量,例如 500亿+',
help: '支持正数及万、亿单位,可带 +。',
placeholder: '请输入调用量,例如 500',
metric: { kind: 'amount', suffix: '+' },
},
costReduction: {
label: '客户月度 AI 调用成本',
placeholder: '请输入成本降幅,例如 20%',
help: '填写 0~100 的百分比,官网可展示为 ↓20%。',
note: '降幅',
placeholder: '请输入成本降幅,例如 20',
metric: { kind: 'percent', suffix: '%', prefix: '↓' },
},
teamMembers: {
label: '团队成员',
placeholder: '请输入团队成员数量,例如 50+',
help: '首页与关于微词元共用此字段,正整数,可带 +。',
note: '首页与关于微词元共用',
placeholder: '请输入团队成员数量,例如 50',
metric: { kind: 'integer', suffix: '+' },
},
researchRatio: {
label: '研发人员占比',
placeholder: '请输入研发人员占比,例如 60%',
help: '填写 0~100 的百分比。',
placeholder: '请输入研发人员占比,例如 60',
metric: { kind: 'percent', suffix: '%' },
},
headquarters: {
label: '总部',
@@ -125,6 +129,39 @@ export function isAbsoluteImageUrl(value) {
}
}
export const AMOUNT_UNITS = ['万', '亿'];
export const DEFAULT_AMOUNT_UNIT = '亿';
// Typed or pasted numbers: full-width digits / dots become half-width, everything else is dropped.
export function sanitizeMetricInput(value) {
return String(value ?? '')
.replace(/[0-9]/g, (char) =>
String.fromCharCode(char.charCodeAt(0) - 0xfee0),
)
.replace(/[.。]/g, '.')
.replace(/[^\d.]/g, '');
}
// "500亿" -> { number: '500', unit: '亿' }; values without a unit keep the default unit.
export function splitAmount(value) {
const text = String(value ?? '').trim();
const unit = AMOUNT_UNITS.find((item) => text.endsWith(item));
return {
number: unit ? text.slice(0, -unit.length) : text,
unit: unit || DEFAULT_AMOUNT_UNIT,
};
}
export const joinAmount = (number, unit) => (number ? `${number}${unit}` : '');
// Text shown under a metric input, matching how the official site renders the value.
export function metricPreview(key, value) {
const metric = FIELDS[key]?.metric;
if (!metric || validateField(key, value)) return '';
const text = String(value).trim();
return `${metric.prefix || ''}${text}${metric.suffix}`;
}
export function validateField(key, rawValue) {
if (key === 'insights') return validateInsights(rawValue);
const value = String(rawValue ?? '').trim();
@@ -134,19 +171,20 @@ export function validateField(key, rawValue) {
: `请输入${FIELDS[key].label}`;
if (
['paidCustomers', 'teamMembers'].includes(key) &&
!/^[1-9]\d*\+?$/.test(value)
!/^[1-9]\d*$/.test(value)
)
return '请输入正整数,可在末尾添加 +';
return '请输入大于 0 的整数';
if (
key === 'dailyTokens' &&
(!/^\d+(?:\.\d+)?[万亿]?\+?$/.test(value) || parseFloat(value) <= 0)
(!/^(?:0|[1-9]\d*)(?:\.\d{1,2})?[万亿]$/.test(value) ||
parseFloat(value) <= 0)
)
return '请输入大于 0 的调用量,例如 500亿+';
return '请输入大于 0 的数字,最多两位小数';
if (
['costReduction', 'researchRatio'].includes(key) &&
(!/^\d+(?:\.\d{1,2})?%?$/.test(value) || parseFloat(value) > 100)
(!/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/.test(value) || parseFloat(value) > 100)
)
return '请输入 0~100 的百分比,最多两位小数';
return '请输入 0~100 之间的数字,最多两位小数';
if (key === 'businessPhone' && !PHONE.test(value))
return '请输入有效的手机号、固定电话或 400 电话';
if (
+1 -2
View File
@@ -87,8 +87,7 @@ export async function saveWebsiteSettings(configurationJson) {
}
}
configurationJson = JSON.stringify(payload);
if (new TextEncoder().encode(configurationJson).byteLength > 60 * 1024)
throw new Error('官网配置不能超过 60 KiB,请精简内容或减少图片');
// Backend stores config as LONGTEXT; article bodies are capped at ARTICLE_BODY_LIMIT in the editor.
await requestWebsite(
'post',
'/api/website/page-config',
+3 -3
View File
@@ -106,7 +106,7 @@ html.dark .org-center .oc-page {
}
.org-center .oc-page .oc-list-card .ant-table-thead > tr > th {
background: var(--oc-soft);
--center-table-head-bg: var(--oc-soft);
color: var(--oc-muted);
font-size: 12px;
font-weight: 500;
@@ -370,7 +370,7 @@ body:has(.org-center .oc-page)
}
.oc-dialog-table .ant-table-thead > tr > th {
background: var(--oc-soft);
--center-table-head-bg: var(--oc-soft);
color: var(--oc-muted);
font-size: 12px;
font-weight: 500;
@@ -2443,7 +2443,7 @@ html.dark .org-center .oc-dashboard {
}
.org-center .oc-dashboard .oc-ea-detail-card .ant-table-thead .ant-table-cell {
background: var(--oc-ea-head-bg);
--center-table-head-bg: var(--oc-ea-head-bg);
color: var(--oc-ea-muted);
font-size: 12px;
}
+1 -1
View File
@@ -521,7 +521,7 @@ body[data-ui-scope='admin'] .ant-layout {
border: 0;
}
.org-panel .ant-table-thead > tr > th {
background: var(--ui-color-fill-0);
--center-table-head-bg: var(--ui-color-fill-0);
color: var(--text-secondary);
font-size: 12px;
font-weight: 500;