- 资料表单三行分组:登录用户名/更新密码/业务状态;实名状态/实名姓名/实名证件号;账号备注独占一行 - 新增 FingerprintFields 共享组件(字段+载荷构建+回显转换),创建页同步复用 - 编辑页指纹独立卡片单独保存(PUT fingerprint),运行中环境保存后自动重启生效 - 修复暗病:保存资料不再发送 Number(undefined)=NaN 的 cooldown_seconds,改透传当前值
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
// 指纹浏览器环境表单字段 + 提交载荷构建:创建页(new.tsx)与编辑页(edit.tsx)共用。
|
||||
// 留空项不提交,后端使用浏览器默认值;seed 由系统按账号派生并保证唯一,代理由网络出口统一管理,均不在表单内。
|
||||
// 字段契约来源:internal/environment/fingerprint.go(fingerprint-chromium 启动参数)。
|
||||
import { Col, Form, Input, InputNumber, Row, Select } from 'antd';
|
||||
|
||||
export interface FingerprintValues {
|
||||
platform?: string;
|
||||
platform_version?: string;
|
||||
brand?: string;
|
||||
brand_version?: string;
|
||||
hardware_concurrency?: number;
|
||||
lang?: string;
|
||||
accept_lang?: string;
|
||||
timezone?: string;
|
||||
disable_spoofing?: string[];
|
||||
}
|
||||
|
||||
export const spoofingOptions = [
|
||||
{ value: 'font', label: '字体' },
|
||||
{ value: 'audio', label: '音频' },
|
||||
{ value: 'canvas', label: 'Canvas' },
|
||||
{ value: 'clientrects', label: 'ClientRects' },
|
||||
{ value: 'gpu', label: 'GPU' },
|
||||
];
|
||||
|
||||
// 提交方向:只提交非空项;disable_spoofing 多选合并为逗号分隔字符串(后端契约)。
|
||||
export function fingerprintPayload(fp?: FingerprintValues): Record<string, unknown> {
|
||||
const payload: Record<string, unknown> = {};
|
||||
if (!fp) return payload;
|
||||
if (fp.platform) payload.platform = fp.platform;
|
||||
if (fp.platform_version?.trim()) payload.platform_version = fp.platform_version.trim();
|
||||
if (fp.brand) payload.brand = fp.brand;
|
||||
if (fp.brand_version?.trim()) payload.brand_version = fp.brand_version.trim();
|
||||
if (fp.hardware_concurrency) payload.hardware_concurrency = fp.hardware_concurrency;
|
||||
if (fp.lang?.trim()) payload.lang = fp.lang.trim();
|
||||
if (fp.accept_lang?.trim()) payload.accept_lang = fp.accept_lang.trim();
|
||||
if (fp.timezone?.trim()) payload.timezone = fp.timezone.trim();
|
||||
if (fp.disable_spoofing?.length) payload.disable_spoofing = fp.disable_spoofing.join(',');
|
||||
return payload;
|
||||
}
|
||||
|
||||
// 回显方向:后端存储的指纹(disable_spoofing 为逗号分隔字符串)转表单值。
|
||||
export function fingerprintFormValues(fp?: FingerprintValues | null) {
|
||||
return {
|
||||
fingerprint: {
|
||||
platform: fp?.platform || undefined,
|
||||
platform_version: fp?.platform_version || '',
|
||||
brand: fp?.brand || undefined,
|
||||
brand_version: fp?.brand_version || '',
|
||||
hardware_concurrency: fp?.hardware_concurrency || undefined,
|
||||
lang: fp?.lang || '',
|
||||
accept_lang: fp?.accept_lang || '',
|
||||
timezone: fp?.timezone || '',
|
||||
disable_spoofing: fp?.disable_spoofing ? String(fp.disable_spoofing).split(',') : [],
|
||||
} satisfies FingerprintValues,
|
||||
};
|
||||
}
|
||||
|
||||
export default function FingerprintFields() {
|
||||
return (
|
||||
<>
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'platform']} label="平台伪装" extra="浏览器上报的操作系统">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="默认"
|
||||
options={[
|
||||
{ value: 'windows', label: 'Windows' },
|
||||
{ value: 'linux', label: 'Linux' },
|
||||
{ value: 'macos', label: 'macOS' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'brand']} label="浏览器品牌" extra="UA 中的浏览器品牌">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="默认"
|
||||
options={[
|
||||
{ value: 'Chrome', label: 'Chrome' },
|
||||
{ value: 'Edge', label: 'Edge' },
|
||||
{ value: 'Opera', label: 'Opera' },
|
||||
{ value: 'Vivaldi', label: 'Vivaldi' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'platform_version']} label="平台版本" extra="如 10.0.0">
|
||||
<Input maxLength={32} placeholder="默认" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'brand_version']} label="品牌版本" extra="如 132.0.6834.159">
|
||||
<Input maxLength={32} placeholder="默认" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'lang']} label="语言" extra="如 zh-CN">
|
||||
<Input maxLength={16} placeholder="默认" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'accept_lang']} label="接受语言" extra="逗号分隔,如 zh-CN,en-US">
|
||||
<Input maxLength={256} placeholder="默认" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'timezone']} label="时区" extra="IANA 时区,如 Asia/Shanghai">
|
||||
<Input maxLength={64} placeholder="默认" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name={['fingerprint', 'hardware_concurrency']} label="硬件并发数" extra="CPU 逻辑核数,1-128">
|
||||
<InputNumber min={1} max={128} precision={0} style={{ width: '100%' }} placeholder="默认" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Form.Item
|
||||
name={['fingerprint', 'disable_spoofing']}
|
||||
label="关闭伪装维度"
|
||||
extra="关闭指定维度的指纹伪装,保持浏览器真实特征"
|
||||
>
|
||||
<Select mode="multiple" allowClear placeholder="默认全部伪装" options={spoofingOptions} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user