fix(ui): 修复固定列表头并优化官网指标配置
This commit is contained in:
@@ -10,6 +10,22 @@
|
|||||||
|
|
||||||
## 2026-11-17
|
## 2026-11-17
|
||||||
|
|
||||||
|
### 调整 · 官网设置指标只填数字并实时预览官网展示
|
||||||
|
|
||||||
|
- **范围**:`/console/website-setting` 的“首页”“关于微词元”指标字段(付费企业客户、平台日均 Token 调用、客户月度 AI 调用成本、团队成员、研发人员占比)及保存逻辑。
|
||||||
|
- **变更**:指标输入只保留数字(全角自动转半角、其他字符丢弃),`+` / `%` 以不可编辑后缀展示,Token 调用用“万 / 亿”下拉并合成存储(如 `500亿`);输入框下方实时显示“官网展示”,首页团队成员同时展示研发占比;校验改为不接受 `+` / `%` 与前导零;后端改为 LONGTEXT 后移除前端 60 KiB 总大小限制。
|
||||||
|
- **影响**:配置中的指标字段为纯数字字符串,单位由官网渲染;不兼容带单位的旧值(官网尚未对接)。接口路径与结构不变,新增文案已补齐 9 个语言包。官网仓库 `weelink-open` 的 `docs/api-integration-frontend-20261031.md` 同步了指标与动态与洞察约定。
|
||||||
|
- **回滚**:按文件还原 `src/pages/WebsiteSettings/` 下 `model.js`、`WebsiteField.jsx`、`index.jsx`、`settingsApi.js`、`WebsiteSettings.css`、README、相关单测(含 `test/unit/website-save-validation.test.js`)及语言包新增键。
|
||||||
|
- **关联**:`src/pages/WebsiteSettings/README.md`。
|
||||||
|
|
||||||
|
### 修复 · 三中心固定列表头透字与样式对齐
|
||||||
|
|
||||||
|
- **范围**:公共表格封装、列布局策略与 `center-table.css`,控制台(含聊天设置)、企业中心、用户中心的表头样式和列策略回归测试。
|
||||||
|
- **变更**:所有表头统一在不透明容器底色上叠加页面色调,避免半透明背景透出滚动列文字;页面仅提供表头色调变量。固定单元格恢复 antd 6 动态层级,使用当前版本固定列类名覆盖正文底色、悬停与选中态;移除模型页依赖旧类名的局部补丁,统一表头不换行。异步数据加载后按可见行重新测量操作宽度,窄屏限制操作列宽并允许按钮组换行;固定区挤占时释放其他固定列,恢复宽屏后自动还原。
|
||||||
|
- **影响**:保留原列对齐、横向滚动、操作回调、接口、权限与数据流;操作区列宽随实际内容和容器调整,浅深主题均适用,不涉及生产构建与数据迁移。
|
||||||
|
- **回滚**:按本条涉及的组件、列策略、CSS、测试与规范差异还原,不覆盖其他修改。
|
||||||
|
- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md` 第 5.2 节,`src/components/ui/center-table.css`。
|
||||||
|
|
||||||
### 工具 · 两项目浏览器环境与报告隔离
|
### 工具 · 两项目浏览器环境与报告隔离
|
||||||
|
|
||||||
- **范围**:Playwright 配置、设备共享模块、公共 fixture、启动与产物校验脚本、测试命令和对应文档。
|
- **范围**:Playwright 配置、设备共享模块、公共 fixture、启动与产物校验脚本、测试命令和对应文档。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# UI 公共组件与样式规范
|
# UI 公共组件与样式规范
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-16 · 版本:v2.2
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-17 · 版本:v2.3
|
||||||
|
|
||||||
所有后台页面共用的主题与组件标准。页面规范只记录与本文不同的部分;编码约定见 `DEV_STANDARDS.md`,外壳与布局见 `GLOBAL_UI_BASELINE.md`。
|
所有后台页面共用的主题与组件标准。页面规范只记录与本文不同的部分;编码约定见 `DEV_STANDARDS.md`,外壳与布局见 `GLOBAL_UI_BASELINE.md`。
|
||||||
|
|
||||||
@@ -152,6 +152,8 @@ html.dark .km-page {
|
|||||||
- 操作列放在最后,按钮为 `type='link' size='small'`,危险操作加 `danger`,同一行操作间距 8–10px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`;操作较多时折叠到“更多”下拉。
|
- 操作列放在最后,按钮为 `type='link' size='small'`,危险操作加 `danger`,同一行操作间距 8–10px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`;操作较多时折叠到“更多”下拉。
|
||||||
- 三中心表格通过 `CenterActionTable` 统一处理,最后一列存在创建、查看、编辑、测试、详情、删除、添加、设置、配置、弹窗 / 抽屉或请求交互时,列头统一显示“操作”并固定右侧,宽度按按钮 / 交互数量计算。没有操作列但估算列宽超出容器时,从右侧固定末 4 列,列数不足时降为 3、2、1 列。固定列使用不透明底色并保持表头层级;横向滚动条遵循 Ant Design 官方固定列表格行为,允许鼠标、触控板、触屏和键盘滚动,不隐藏滚动条。
|
- 三中心表格通过 `CenterActionTable` 统一处理,最后一列存在创建、查看、编辑、测试、详情、删除、添加、设置、配置、弹窗 / 抽屉或请求交互时,列头统一显示“操作”并固定右侧,宽度按按钮 / 交互数量计算。没有操作列但估算列宽超出容器时,从右侧固定末 4 列,列数不足时降为 3、2、1 列。固定列使用不透明底色并保持表头层级;横向滚动条遵循 Ant Design 官方固定列表格行为,允许鼠标、触控板、触屏和键盘滚动,不隐藏滚动条。
|
||||||
- 列显隐只在已有列设置的表格中提供,统一使用 `ColumnSettings`(见 `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
- 列显隐只在已有列设置的表格中提供,统一使用 `ColumnSettings`(见 `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
||||||
|
- 三中心表头背景统一由 `center-table.css` 绘制:页面通过 `--center-table-head-bg` 提供色调,公共层在不透明的容器底色上叠加同色填充,普通列与固定列保持一致;页面不再直接覆盖表头 `background`。固定列使用 antd 6 的 `.ant-table-cell-fix` 与原生动态层级,不写死 `z-index`,不使用旧版 `fix-left` / `fix-right` 类名补丁;表头不换行,表头与正文沿用同一列宽和对齐方式。
|
||||||
|
- 操作列在异步数据或列变化后重新测量可见行的按钮宽度,取最大值;列宽不超过表格容器,按钮组在空间不足时换行。左右固定区总宽超过容器时,保留右侧操作列,其余固定列参与横向滚动;容器恢复足够宽度后恢复原固定配置,避免窄屏相互遮挡。
|
||||||
|
|
||||||
### 5.3 状态
|
### 5.3 状态
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@
|
|||||||
margin-inline-start: auto;
|
margin-inline-start: auto;
|
||||||
}
|
}
|
||||||
.console-page .console-table .ant-table-thead > tr > th {
|
.console-page .console-table .ant-table-thead > tr > th {
|
||||||
background: var(--console-fill);
|
--center-table-head-bg: var(--console-fill);
|
||||||
color: var(--console-muted);
|
color: var(--console-muted);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,16 +96,6 @@
|
|||||||
opacity: 0.65;
|
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 {
|
.models-vendor-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|||||||
@@ -68,29 +68,34 @@ const CenterTable = forwardRef(function CenterTable(
|
|||||||
const cells = [...root.querySelectorAll(`td.${marker}`)].filter(
|
const cells = [...root.querySelectorAll(`td.${marker}`)].filter(
|
||||||
(element) => element.getBoundingClientRect().width > 0,
|
(element) => element.getBoundingClientRect().width > 0,
|
||||||
);
|
);
|
||||||
const cell = cells.find((candidate) =>
|
const widths = cells.map((cell) => {
|
||||||
candidate.querySelector('button, a, [role="button"]'),
|
const controls = [
|
||||||
);
|
...cell.querySelectorAll('button, a, [role="button"]'),
|
||||||
const controls = cell
|
].filter((element) => element.getBoundingClientRect().width > 0);
|
||||||
? [...cell.querySelectorAll('button, a, [role="button"]')].filter(
|
if (!controls.length) return 0;
|
||||||
(element) => element.getBoundingClientRect().width > 0,
|
let group = controls[0].parentElement;
|
||||||
|
while (
|
||||||
|
group !== cell &&
|
||||||
|
!controls.every((control) => group.contains(control))
|
||||||
)
|
)
|
||||||
: [];
|
group = group.parentElement;
|
||||||
const cellStyle = getComputedStyle(cell || header);
|
const cellStyle = getComputedStyle(cell);
|
||||||
const padding =
|
const padding =
|
||||||
(Number.parseFloat(cellStyle.paddingLeft) || 0) +
|
(Number.parseFloat(cellStyle.paddingLeft) || 0) +
|
||||||
(Number.parseFloat(cellStyle.paddingRight) || 0);
|
(Number.parseFloat(cellStyle.paddingRight) || 0);
|
||||||
const gap = Number.parseFloat(cellStyle.columnGap) || 8;
|
const gap = Number.parseFloat(getComputedStyle(group).columnGap) || 8;
|
||||||
const contentWidth = controls.length
|
return (
|
||||||
? controls.reduce(
|
controls.reduce(
|
||||||
(total, element) => total + element.getBoundingClientRect().width,
|
(total, element) => total + element.getBoundingClientRect().width,
|
||||||
0,
|
0,
|
||||||
) +
|
) +
|
||||||
gap * Math.max(0, controls.length - 1)
|
gap * Math.max(0, controls.length - 1) +
|
||||||
: Math.max(...cells.map((candidate) => candidate.scrollWidth), 0) -
|
padding
|
||||||
padding;
|
);
|
||||||
next[marker.replace('center-fixed-index-', '')] =
|
});
|
||||||
contentWidth + padding;
|
const measured = Math.max(...widths, 0);
|
||||||
|
if (measured > 0)
|
||||||
|
next[marker.replace('center-fixed-index-', '')] = measured;
|
||||||
});
|
});
|
||||||
setMeasuredActionWidths((current) => {
|
setMeasuredActionWidths((current) => {
|
||||||
const same =
|
const same =
|
||||||
@@ -101,15 +106,16 @@ const CenterTable = forwardRef(function CenterTable(
|
|||||||
return same ? current : next;
|
return same ? current : next;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
requestAnimationFrame(measureActionWidths);
|
const frame = requestAnimationFrame(measureActionWidths);
|
||||||
const observer = new ResizeObserver(update);
|
const observer = new ResizeObserver(update);
|
||||||
observer.observe(root);
|
observer.observe(root);
|
||||||
return () => {
|
return () => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
if (scroller && previousTabIndex === null)
|
if (scroller && previousTabIndex === null)
|
||||||
scroller.removeAttribute('tabindex');
|
scroller.removeAttribute('tabindex');
|
||||||
};
|
};
|
||||||
}, [enabled, width]);
|
}, [enabled, width, columns, props.dataSource]);
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -3,30 +3,34 @@
|
|||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.center-action-table .ant-table-tbody > tr > .center-fixed-cell {
|
.center-action-table .ant-table-tbody > tr > .ant-table-cell-fix {
|
||||||
z-index: 2;
|
|
||||||
background: var(--center-table-bg);
|
background: var(--center-table-bg);
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.center-action-table .ant-table-thead > tr > .center-fixed-cell {
|
.center-action-table .ant-table-thead > tr > .ant-table-cell {
|
||||||
z-index: 3;
|
/* Composite the header tint over an opaque surface, including sticky cells. */
|
||||||
background: var(--ur-head-bg, var(--center-table-head-bg));
|
background-color: var(--center-table-bg);
|
||||||
|
background-image: linear-gradient(
|
||||||
|
var(--center-table-head-bg),
|
||||||
|
var(--center-table-head-bg)
|
||||||
|
);
|
||||||
background-clip: padding-box;
|
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);
|
background: var(--center-table-hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.center-action-table
|
.center-action-table
|
||||||
.ant-table-tbody
|
.ant-table-tbody
|
||||||
> tr.ant-table-row-selected
|
> tr.ant-table-row-selected
|
||||||
> .center-fixed-cell {
|
> .ant-table-cell-fix {
|
||||||
background: var(--center-table-selected-bg);
|
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;
|
white-space: normal;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
@@ -50,6 +54,6 @@
|
|||||||
.admin-tokens-row-actions,
|
.admin-tokens-row-actions,
|
||||||
.website-insights-row-actions
|
.website-insights-row-actions
|
||||||
) {
|
) {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: wrap;
|
||||||
max-width: none;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,11 +89,15 @@ const markFixedRight = (
|
|||||||
index,
|
index,
|
||||||
action = false,
|
action = false,
|
||||||
measuredWidths = {},
|
measuredWidths = {},
|
||||||
|
containerWidth = 0,
|
||||||
) => ({
|
) => ({
|
||||||
...column,
|
...column,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: action
|
width: action
|
||||||
? actionWidth(column, measuredWidths[index])
|
? Math.min(
|
||||||
|
actionWidth(column, measuredWidths[index]),
|
||||||
|
containerWidth > 0 ? Math.max(56, containerWidth) : Infinity,
|
||||||
|
)
|
||||||
: columnWidth(column),
|
: columnWidth(column),
|
||||||
...(action ? { title: i18next.t('操作') || '操作' } : {}),
|
...(action ? { title: i18next.t('操作') || '操作' } : {}),
|
||||||
className: [
|
className: [
|
||||||
@@ -110,6 +114,22 @@ export function prepareCenterColumns(columns, width = 0, measuredWidths = {}) {
|
|||||||
const leaves = leafColumns(columns);
|
const leaves = leafColumns(columns);
|
||||||
const last = leaves.at(-1);
|
const last = leaves.at(-1);
|
||||||
const hasAction = last && isActionColumn(last);
|
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(
|
const estimatedTotal = leaves.reduce(
|
||||||
(total, column) => total + columnWidth(column),
|
(total, column) => total + columnWidth(column),
|
||||||
0,
|
0,
|
||||||
@@ -125,8 +145,12 @@ export function prepareCenterColumns(columns, width = 0, measuredWidths = {}) {
|
|||||||
return { ...column, children: column.children.map(mapColumn) };
|
return { ...column, children: column.children.map(mapColumn) };
|
||||||
const columnIndex = index++;
|
const columnIndex = index++;
|
||||||
if (hasAction && column === last)
|
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 (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) };
|
if (column.fixed) return { ...column, width: columnWidth(column) };
|
||||||
return column;
|
return column;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10710,6 +10710,10 @@
|
|||||||
"点击图片可放大预览": "Click on the image to enlarge the preview",
|
"点击图片可放大预览": "Click on the image to enlarge the preview",
|
||||||
"官网设置已保存": "The official website settings have been saved",
|
"官网设置已保存": "The official website settings have been saved",
|
||||||
"研发人员占比": "Proportion of R & D personnel",
|
"研发人员占比": "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.",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "All four tabs share one configuration. Saving validates and submits all settings together.",
|
||||||
"富文本工具栏": "Rich text toolbar",
|
"富文本工具栏": "Rich text toolbar",
|
||||||
"正文段落": "Body paragraph",
|
"正文段落": "Body paragraph",
|
||||||
|
|||||||
@@ -10599,6 +10599,10 @@
|
|||||||
"点击图片可放大预览": "Cliquez sur l'image pour agrandir l'aperçu",
|
"点击图片可放大预览": "Cliquez sur l'image pour agrandir l'aperçu",
|
||||||
"官网设置已保存": "Les paramètres du site officiel sont sauvegardés",
|
"官网设置已保存": "Les paramètres du site officiel sont sauvegardés",
|
||||||
"研发人员占比": "Proportion de personnel R & D",
|
"研发人员占比": "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.",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "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}}",
|
"结算状态: {{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.",
|
"确认未生效:授权、凭据或操作内容已变化,请刷新任务后重试。": "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.",
|
||||||
|
|||||||
@@ -10684,6 +10684,10 @@
|
|||||||
"点击图片可放大预览": "画像をクリックしてプレビューを拡大",
|
"点击图片可放大预览": "画像をクリックしてプレビューを拡大",
|
||||||
"官网设置已保存": "WEB保存済みです。",
|
"官网设置已保存": "WEB保存済みです。",
|
||||||
"研发人员占比": "開発スタッフの割合",
|
"研发人员占比": "開発スタッフの割合",
|
||||||
|
"官网展示:{{value}}": "公式サイト表示:{{value}}",
|
||||||
|
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研究開発比率 {{ratio}}",
|
||||||
|
"降幅": "削減率",
|
||||||
|
"首页与关于微词元共用": "ホームと会社概要で共用",
|
||||||
"四个页签共用一份配置,保存时将统一校验并提交。": "4つのタブは1つの構成を共有し、保存時に均一に検証およびコミットされます。",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "4つのタブは1つの構成を共有し、保存時に均一に検証およびコミットされます。",
|
||||||
"富文本工具栏": "リッチテキストツールバー",
|
"富文本工具栏": "リッチテキストツールバー",
|
||||||
"正文段落": "本文段落",
|
"正文段落": "本文段落",
|
||||||
|
|||||||
@@ -10685,6 +10685,10 @@
|
|||||||
"点击图片可放大预览": "이미지를 클릭하여 미리보기를 확대합니다.",
|
"点击图片可放大预览": "이미지를 클릭하여 미리보기를 확대합니다.",
|
||||||
"官网设置已保存": "공식 웹사이트 설정이 저장되었습니다.",
|
"官网设置已保存": "공식 웹사이트 설정이 저장되었습니다.",
|
||||||
"研发人员占比": "R&D 인력의 비율",
|
"研发人员占比": "R&D 인력의 비율",
|
||||||
|
"官网展示:{{value}}": "웹사이트 표시: {{value}}",
|
||||||
|
"{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D 비율 {{ratio}}",
|
||||||
|
"降幅": "감소폭",
|
||||||
|
"首页与关于微词元共用": "홈과 회사 소개에서 공용",
|
||||||
"四个页签共用一份配置,保存时将统一校验并提交。": "네 개의 탭은 구성을 공유하며, 이 구성은 저장 시 확인되고 제출됩니다.",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "네 개의 탭은 구성을 공유하며, 이 구성은 저장 시 확인되고 제출됩니다.",
|
||||||
"富文本工具栏": "서식 있는 텍스트 도구 모음",
|
"富文本工具栏": "서식 있는 텍스트 도구 모음",
|
||||||
"正文段落": "본문 단락",
|
"正文段落": "본문 단락",
|
||||||
|
|||||||
@@ -10351,6 +10351,10 @@
|
|||||||
"点击图片可放大预览": "Нажмите на изображение для увеличения предварительного просмотра",
|
"点击图片可放大预览": "Нажмите на изображение для увеличения предварительного просмотра",
|
||||||
"官网设置已保存": "Официальный сайт сохранен.",
|
"官网设置已保存": "Официальный сайт сохранен.",
|
||||||
"研发人员占比": "Доля исследователей",
|
"研发人员占比": "Доля исследователей",
|
||||||
|
"官网展示:{{value}}": "На сайте: {{value}}",
|
||||||
|
"{{team}} · 研发占比 {{ratio}}": "{{team}} · доля R&D {{ratio}}",
|
||||||
|
"降幅": "снижение",
|
||||||
|
"首页与关于微词元共用": "общее для главной и раздела «О нас»",
|
||||||
"四个页签共用一份配置,保存时将统一校验并提交。": "Четыре страницы совместно используют один экземпляр конфигурации, при сохранении будет проведена единая проверка и отправка.",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "Четыре страницы совместно используют один экземпляр конфигурации, при сохранении будет проведена единая проверка и отправка.",
|
||||||
"{{count}} 处非法输入": "{{count}} неверный вход (ы)",
|
"{{count}} 处非法输入": "{{count}} неверный вход (ы)",
|
||||||
"{{count}} 个已验证渠道": "{{count}} верифицированные каналы",
|
"{{count}} 个已验证渠道": "{{count}} верифицированные каналы",
|
||||||
|
|||||||
@@ -10684,6 +10684,10 @@
|
|||||||
"点击图片可放大预览": "คลิกที่ภาพเพื่อดูตัวอย่าง",
|
"点击图片可放大预览": "คลิกที่ภาพเพื่อดูตัวอย่าง",
|
||||||
"官网设置已保存": "บันทึกการตั้งค่าเว็บไซต์อย่างเป็นทางการแล้ว",
|
"官网设置已保存": "บันทึกการตั้งค่าเว็บไซต์อย่างเป็นทางการแล้ว",
|
||||||
"研发人员占比": "สัดส่วนของบุคลากรด้าน R&D",
|
"研发人员占比": "สัดส่วนของบุคลากรด้าน R&D",
|
||||||
|
"官网展示:{{value}}": "แสดงบนเว็บไซต์: {{value}}",
|
||||||
|
"{{team}} · 研发占比 {{ratio}}": "{{team}} · สัดส่วน R&D {{ratio}}",
|
||||||
|
"降幅": "ลดลง",
|
||||||
|
"首页与关于微词元共用": "ใช้ร่วมกันระหว่างหน้าแรกและเกี่ยวกับเรา",
|
||||||
"四个页签共用一份配置,保存时将统一校验并提交。": "แท็บทั้งสี่จะใช้การกําหนดค่าร่วมกันและจะได้รับการตรวจสอบและส่งเมื่อบันทึก",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "แท็บทั้งสี่จะใช้การกําหนดค่าร่วมกันและจะได้รับการตรวจสอบและส่งเมื่อบันทึก",
|
||||||
"富文本工具栏": "แถบเครื่องมือข้อความที่มีรูปแบบ",
|
"富文本工具栏": "แถบเครื่องมือข้อความที่มีรูปแบบ",
|
||||||
"正文段落": "ย่อหน้าเนื้อหา",
|
"正文段落": "ย่อหน้าเนื้อหา",
|
||||||
|
|||||||
@@ -10684,6 +10684,10 @@
|
|||||||
"点击图片可放大预览": "Nhấp vào hình ảnh để phóng to bản xem trước",
|
"点击图片可放大预览": "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",
|
"官网设置已保存": "Cài đặt trang web chính thức đã được lưu",
|
||||||
"研发人员占比": "Tỷ lệ nhân viên R & D",
|
"研发人员占比": "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.",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "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",
|
"富文本工具栏": "Thanh công cụ văn bản có định dạng",
|
||||||
"正文段落": "Đoạn văn bản",
|
"正文段落": "Đoạn văn bản",
|
||||||
|
|||||||
@@ -10684,6 +10684,10 @@
|
|||||||
"点击图片可放大预览": "點擊圖片可放大預覽",
|
"点击图片可放大预览": "點擊圖片可放大預覽",
|
||||||
"官网设置已保存": "官網設置已保存",
|
"官网设置已保存": "官網設置已保存",
|
||||||
"研发人员占比": "研發人員佔比",
|
"研发人员占比": "研發人員佔比",
|
||||||
|
"官网展示:{{value}}": "官網展示:{{value}}",
|
||||||
|
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研發佔比 {{ratio}}",
|
||||||
|
"降幅": "降幅",
|
||||||
|
"首页与关于微词元共用": "首頁與關於微詞元共用",
|
||||||
"四个页签共用一份配置,保存时将统一校验并提交。": "四個頁籤共用一份配置,保存時將統一校驗並提交。",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "四個頁籤共用一份配置,保存時將統一校驗並提交。",
|
||||||
"富文本工具栏": "富文字工具列",
|
"富文本工具栏": "富文字工具列",
|
||||||
"正文段落": "內文段落",
|
"正文段落": "內文段落",
|
||||||
|
|||||||
@@ -10598,6 +10598,10 @@
|
|||||||
"点击图片可放大预览": "点击图片可放大预览",
|
"点击图片可放大预览": "点击图片可放大预览",
|
||||||
"官网设置已保存": "官网设置已保存",
|
"官网设置已保存": "官网设置已保存",
|
||||||
"研发人员占比": "研发人员占比",
|
"研发人员占比": "研发人员占比",
|
||||||
|
"官网展示:{{value}}": "官网展示:{{value}}",
|
||||||
|
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研发占比 {{ratio}}",
|
||||||
|
"降幅": "降幅",
|
||||||
|
"首页与关于微词元共用": "首页与关于微词元共用",
|
||||||
"四个页签共用一份配置,保存时将统一校验并提交。": "四个页签共用一份配置,保存时将统一校验并提交。",
|
"四个页签共用一份配置,保存时将统一校验并提交。": "四个页签共用一份配置,保存时将统一校验并提交。",
|
||||||
"富文本工具栏": "富文本工具栏",
|
"富文本工具栏": "富文本工具栏",
|
||||||
"正文段落": "正文段落",
|
"正文段落": "正文段落",
|
||||||
|
|||||||
@@ -123,10 +123,10 @@ html.dark .km-page {
|
|||||||
|
|
||||||
/* 表格:表头 46px、底色 #f8f9fc、常规字重;行分隔 #f0f0f0(middle 尺寸 12px 8px) */
|
/* 表格:表头 46px、底色 #f8f9fc、常规字重;行分隔 #f0f0f0(middle 尺寸 12px 8px) */
|
||||||
.km-table .ant-table-thead > tr > th {
|
.km-table .ant-table-thead > tr > th {
|
||||||
|
--center-table-head-bg: var(--km-head-bg);
|
||||||
height: 46px;
|
height: 46px;
|
||||||
padding-block: 0;
|
padding-block: 0;
|
||||||
border-bottom-color: var(--km-row-split);
|
border-bottom-color: var(--km-row-split);
|
||||||
background: var(--km-head-bg);
|
|
||||||
color: var(--km-head-text);
|
color: var(--km-head-text);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,10 +180,10 @@ html.dark .usage-record-tabs .ant-tabs-ink-bar {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.usage-record-table .ant-table-thead > tr > th {
|
.usage-record-table .ant-table-thead > tr > th {
|
||||||
|
--center-table-head-bg: var(--ur-head-bg);
|
||||||
height: 46px;
|
height: 46px;
|
||||||
padding-block: 0;
|
padding-block: 0;
|
||||||
border-bottom-color: var(--ur-row-split);
|
border-bottom-color: var(--ur-row-split);
|
||||||
background: var(--ur-head-bg);
|
|
||||||
color: var(--ur-head-text);
|
color: var(--ur-head-text);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,6 @@ html.dark .usage-record-consume-card {
|
|||||||
> th {
|
> th {
|
||||||
padding-block: 0;
|
padding-block: 0;
|
||||||
padding-inline: 8px;
|
padding-inline: 8px;
|
||||||
background: var(--ur-head-bg);
|
|
||||||
color: var(--ur-head-text);
|
color: var(--ur-head-text);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,15 @@ teamMembers/researchRatio 映射 about.teamMembers/researchStaffRatio;首页
|
|||||||
其余总部、服务网络和商务字段依联调文档映射。保存保留后端返回的未知字段。
|
其余总部、服务网络和商务字段依联调文档映射。保存保留后端返回的未知字段。
|
||||||
|
|
||||||
严格检查 success === true 后才提示成功,失败保留当前编辑。提交期间防止重复请求。
|
严格检查 success === true 后才提示成功,失败保留当前编辑。提交期间防止重复请求。
|
||||||
完整配置按 UTF-8 字节限制为 60 KiB,超限时提示精简内容。
|
后端以 LONGTEXT 存储完整配置,前端不再限制总大小;单篇正文由编辑器限制为 20000 字。
|
||||||
客户数和人数支持正整数及末尾 +;Token 支持正数、万/亿单位及末尾 +。
|
|
||||||
百分比支持 0~100,最多两位小数,% 可选。上述展示值以字符串提交。
|
指标字段只填数字,单位由官网展示(后台输入框右侧灰字同步显示,下方实时预览“官网展示”):
|
||||||
|
|
||||||
|
- 付费企业客户、团队成员:大于 0 的整数,不含前导零,存 "300",官网显示 300+。
|
||||||
|
- 平台日均 Token 调用:大于 0、最多两位小数的数字 + 下拉单位(万/亿,默认亿),合成存 "500亿",官网显示 500亿+。
|
||||||
|
- 客户月度 AI 调用成本(降幅)、研发人员占比:0~100、最多两位小数,存 "20",官网显示 ↓20% / 60%。
|
||||||
|
|
||||||
|
输入时全角数字与句号自动转半角,其他字符直接丢弃。官网尚未对接,不兼容带 + / % 的旧值。
|
||||||
|
|
||||||
## 二维码上传
|
## 二维码上传
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
For commercial licensing, please contact support@quantumnous.com
|
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 { Form, Input } from '@/components/ui';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { FIELDS } from './model';
|
import {
|
||||||
|
AMOUNT_UNITS,
|
||||||
|
FIELDS,
|
||||||
|
joinAmount,
|
||||||
|
metricPreview,
|
||||||
|
sanitizeMetricInput,
|
||||||
|
splitAmount,
|
||||||
|
} from './model';
|
||||||
|
|
||||||
export default function WebsiteField({
|
export default function WebsiteField({
|
||||||
name,
|
name,
|
||||||
@@ -29,18 +37,43 @@ export default function WebsiteField({
|
|||||||
onChange,
|
onChange,
|
||||||
onBlur,
|
onBlur,
|
||||||
disabled,
|
disabled,
|
||||||
labelSuffix,
|
preview,
|
||||||
children,
|
children,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const field = FIELDS[name];
|
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 (
|
return (
|
||||||
<Form.Slot
|
<Form.Slot
|
||||||
label={{
|
label={{
|
||||||
text: (
|
text: (
|
||||||
<>
|
<>
|
||||||
{t(field.label)}
|
{t(field.label)}
|
||||||
{labelSuffix}
|
{field.note ? (
|
||||||
|
<span className='website-field-note'>({t(field.note)})</span>
|
||||||
|
) : null}
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
required: true,
|
required: true,
|
||||||
@@ -50,24 +83,56 @@ export default function WebsiteField({
|
|||||||
error: error ? t(error) : undefined,
|
error: error ? t(error) : undefined,
|
||||||
errorMessageId: `website-${name}-error`,
|
errorMessageId: `website-${name}-error`,
|
||||||
}}
|
}}
|
||||||
|
extra={
|
||||||
|
metric ? (
|
||||||
|
<span className='website-metric-preview' aria-live='polite'>
|
||||||
|
{previewText
|
||||||
|
? t('官网展示:{{value}}', { value: previewText })
|
||||||
|
: ''}
|
||||||
|
</span>
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{children || (
|
{children ||
|
||||||
|
(metric ? (
|
||||||
|
<Space.Compact block>
|
||||||
<Input
|
<Input
|
||||||
id={`website-${name}`}
|
{...inputProps}
|
||||||
aria-label={t(field.label)}
|
inputMode={metric.kind === 'integer' ? 'numeric' : 'decimal'}
|
||||||
aria-required={true}
|
value={amount ? amount.number : value}
|
||||||
aria-invalid={Boolean(error)}
|
maxLength={12}
|
||||||
aria-describedby={error ? `website-${name}-error` : undefined}
|
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}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onBlur={onBlur}
|
|
||||||
disabled={disabled}
|
|
||||||
placeholder={t(field.placeholder)}
|
|
||||||
validateStatus={error ? 'error' : 'default'}
|
|
||||||
maxLength={name === 'businessEmail' ? 254 : 200}
|
maxLength={name === 'businessEmail' ? 254 : 200}
|
||||||
showClear
|
|
||||||
/>
|
/>
|
||||||
)}
|
))}
|
||||||
</Form.Slot>
|
</Form.Slot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,27 @@
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.website-settings-page .website-research-ratio-hint {
|
.website-settings-page .website-field-note {
|
||||||
opacity: 0.9;
|
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 {
|
.website-settings-page .website-settings-tab-description {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import { showError, showSuccess, showWarning } from '../../helpers';
|
|||||||
import {
|
import {
|
||||||
TABS,
|
TABS,
|
||||||
emptySettings,
|
emptySettings,
|
||||||
|
metricPreview,
|
||||||
settingsFromConfig,
|
settingsFromConfig,
|
||||||
serializeSettings,
|
serializeSettings,
|
||||||
validateField,
|
validateField,
|
||||||
@@ -91,6 +92,17 @@ export default function WebsiteSettings() {
|
|||||||
}, [dirty]);
|
}, [dirty]);
|
||||||
const tab = TABS.find((item) => item.key === activeTab);
|
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) => {
|
const change = (name, value) => {
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
setValues((previous) => ({ ...previous, [name]: value }));
|
setValues((previous) => ({ ...previous, [name]: value }));
|
||||||
@@ -209,13 +221,10 @@ export default function WebsiteSettings() {
|
|||||||
>
|
>
|
||||||
<WebsiteField
|
<WebsiteField
|
||||||
name={name}
|
name={name}
|
||||||
labelSuffix={
|
preview={
|
||||||
activeTab === 'home' && name === 'teamMembers' ? (
|
activeTab === 'home' && name === 'teamMembers'
|
||||||
<span className='website-research-ratio-hint'>
|
? teamPreview()
|
||||||
({t('研发人员占比')}:
|
: undefined
|
||||||
{values.researchRatio || t('未配置')})
|
|
||||||
</span>
|
|
||||||
) : undefined
|
|
||||||
}
|
}
|
||||||
value={values[name]}
|
value={values[name]}
|
||||||
error={errors[name]}
|
error={errors[name]}
|
||||||
|
|||||||
@@ -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 = {
|
export const FIELDS = {
|
||||||
paidCustomers: {
|
paidCustomers: {
|
||||||
label: '付费企业客户',
|
label: '付费企业客户',
|
||||||
placeholder: '请输入付费企业客户数量,例如 300+',
|
placeholder: '请输入付费企业客户数量,例如 300',
|
||||||
help: '正整数,可带 +。',
|
metric: { kind: 'integer', suffix: '+' },
|
||||||
},
|
},
|
||||||
dailyTokens: {
|
dailyTokens: {
|
||||||
label: '平台日均 Token 调用',
|
label: '平台日均 Token 调用',
|
||||||
placeholder: '请输入平台日均 Token 调用量,例如 500亿+',
|
placeholder: '请输入调用量,例如 500',
|
||||||
help: '支持正数及万、亿单位,可带 +。',
|
metric: { kind: 'amount', suffix: '+' },
|
||||||
},
|
},
|
||||||
costReduction: {
|
costReduction: {
|
||||||
label: '客户月度 AI 调用成本',
|
label: '客户月度 AI 调用成本',
|
||||||
placeholder: '请输入成本降幅,例如 20%',
|
note: '降幅',
|
||||||
help: '填写 0~100 的百分比,官网可展示为 ↓20%。',
|
placeholder: '请输入成本降幅,例如 20',
|
||||||
|
metric: { kind: 'percent', suffix: '%', prefix: '↓' },
|
||||||
},
|
},
|
||||||
teamMembers: {
|
teamMembers: {
|
||||||
label: '团队成员',
|
label: '团队成员',
|
||||||
placeholder: '请输入团队成员数量,例如 50+',
|
note: '首页与关于微词元共用',
|
||||||
help: '首页与关于微词元共用此字段,正整数,可带 +。',
|
placeholder: '请输入团队成员数量,例如 50',
|
||||||
|
metric: { kind: 'integer', suffix: '+' },
|
||||||
},
|
},
|
||||||
researchRatio: {
|
researchRatio: {
|
||||||
label: '研发人员占比',
|
label: '研发人员占比',
|
||||||
placeholder: '请输入研发人员占比,例如 60%',
|
placeholder: '请输入研发人员占比,例如 60',
|
||||||
help: '填写 0~100 的百分比。',
|
metric: { kind: 'percent', suffix: '%' },
|
||||||
},
|
},
|
||||||
headquarters: {
|
headquarters: {
|
||||||
label: '总部',
|
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) {
|
export function validateField(key, rawValue) {
|
||||||
if (key === 'insights') return validateInsights(rawValue);
|
if (key === 'insights') return validateInsights(rawValue);
|
||||||
const value = String(rawValue ?? '').trim();
|
const value = String(rawValue ?? '').trim();
|
||||||
@@ -134,19 +171,20 @@ export function validateField(key, rawValue) {
|
|||||||
: `请输入${FIELDS[key].label}`;
|
: `请输入${FIELDS[key].label}`;
|
||||||
if (
|
if (
|
||||||
['paidCustomers', 'teamMembers'].includes(key) &&
|
['paidCustomers', 'teamMembers'].includes(key) &&
|
||||||
!/^[1-9]\d*\+?$/.test(value)
|
!/^[1-9]\d*$/.test(value)
|
||||||
)
|
)
|
||||||
return '请输入正整数,可在末尾添加 +';
|
return '请输入大于 0 的整数';
|
||||||
if (
|
if (
|
||||||
key === 'dailyTokens' &&
|
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 (
|
if (
|
||||||
['costReduction', 'researchRatio'].includes(key) &&
|
['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))
|
if (key === 'businessPhone' && !PHONE.test(value))
|
||||||
return '请输入有效的手机号、固定电话或 400 电话';
|
return '请输入有效的手机号、固定电话或 400 电话';
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ export async function saveWebsiteSettings(configurationJson) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
configurationJson = JSON.stringify(payload);
|
configurationJson = JSON.stringify(payload);
|
||||||
if (new TextEncoder().encode(configurationJson).byteLength > 60 * 1024)
|
// Backend stores config as LONGTEXT; article bodies are capped at ARTICLE_BODY_LIMIT in the editor.
|
||||||
throw new Error('官网配置不能超过 60 KiB,请精简内容或减少图片');
|
|
||||||
await requestWebsite(
|
await requestWebsite(
|
||||||
'post',
|
'post',
|
||||||
'/api/website/page-config',
|
'/api/website/page-config',
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ html.dark .org-center .oc-page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.org-center .oc-page .oc-list-card .ant-table-thead > tr > th {
|
.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);
|
color: var(--oc-muted);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -370,7 +370,7 @@ body:has(.org-center .oc-page)
|
|||||||
}
|
}
|
||||||
|
|
||||||
.oc-dialog-table .ant-table-thead > tr > th {
|
.oc-dialog-table .ant-table-thead > tr > th {
|
||||||
background: var(--oc-soft);
|
--center-table-head-bg: var(--oc-soft);
|
||||||
color: var(--oc-muted);
|
color: var(--oc-muted);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
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 {
|
.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);
|
color: var(--oc-ea-muted);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ body[data-ui-scope='admin'] .ant-layout {
|
|||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
.org-panel .ant-table-thead > tr > th {
|
.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);
|
color: var(--text-secondary);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|||||||
@@ -112,3 +112,33 @@ test('recognizes translated operation headers without requiring a key', async ()
|
|||||||
});
|
});
|
||||||
assert.equal(isActionColumn({ title: 'Actions', render: () => null }), true);
|
assert.equal(isActionColumn({ title: 'Actions', render: () => null }), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('releases competing fixed columns when the operation area would overlap them', () => {
|
||||||
|
const columns = [
|
||||||
|
{ key: 'name', width: 180, fixed: 'left' },
|
||||||
|
{ key: 'description', width: 300 },
|
||||||
|
{ title: '操作', key: 'actions', render: () => null },
|
||||||
|
];
|
||||||
|
const narrow = prepareCenterColumns(columns, 321, { 2: 240 });
|
||||||
|
assert.equal(narrow[0].fixed, undefined);
|
||||||
|
assert.equal(narrow[0].width, 180);
|
||||||
|
assert.equal(narrow[2].fixed, 'right');
|
||||||
|
assert.equal(narrow[2].width, 240);
|
||||||
|
const wide = prepareCenterColumns(columns, 900, { 2: 240 });
|
||||||
|
assert.equal(wide[0].fixed, 'left');
|
||||||
|
assert.equal(wide[2].width, 240);
|
||||||
|
assert.equal(columns[0].fixed, 'left');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('bounds measured operation widths to the viewport and restores them after resize', () => {
|
||||||
|
const render = () => null;
|
||||||
|
const columns = [
|
||||||
|
{ key: 'name', width: 200 },
|
||||||
|
{ title: '操作', render },
|
||||||
|
];
|
||||||
|
const narrow = prepareCenterColumns(columns, 280, { 1: 350 });
|
||||||
|
assert.equal(narrow[1].width, 280);
|
||||||
|
assert.equal(narrow[1].render, render);
|
||||||
|
assert.equal(prepareCenterColumns(columns, 900, { 1: 350 })[1].width, 350);
|
||||||
|
assert.equal(prepareCenterColumns(columns, 0, { 1: 350 })[1].width, 350);
|
||||||
|
});
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ import { loadFrontendModule } from './frontend-module.js';
|
|||||||
|
|
||||||
function validValues() {
|
function validValues() {
|
||||||
return {
|
return {
|
||||||
paidCustomers: '200+',
|
paidCustomers: '200',
|
||||||
dailyTokens: '10亿',
|
dailyTokens: '10亿',
|
||||||
costReduction: '30%',
|
costReduction: '30',
|
||||||
teamMembers: '100+',
|
teamMembers: '100',
|
||||||
researchRatio: '70%',
|
researchRatio: '70',
|
||||||
headquarters: '珠海',
|
headquarters: '珠海',
|
||||||
serviceNetwork: '全国',
|
serviceNetwork: '全国',
|
||||||
businessPhone: '13800138000',
|
businessPhone: '13800138000',
|
||||||
|
|||||||
Reference in New Issue
Block a user