From a392656d44b0bfc8948188bce6f5a3876ceba92b Mon Sep 17 00:00:00 2001 From: guke Date: Mon, 13 Jul 2026 18:12:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(config-page):=20=E6=94=AF=E6=8C=81=20json?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96/=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96(?= =?UTF-8?q?=E5=90=8C=20dict=5Fstr=5Fint)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llm_token_price 新 type=json(嵌套 JSON 含浮点数,非 str→int 映射)在配置页 需 JSON.stringify/JSON.parse,与 dict_str_int 共用编辑框。 --- src/app/(main)/config/page.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/(main)/config/page.tsx b/src/app/(main)/config/page.tsx index 4d2070d..3f48f83 100644 --- a/src/app/(main)/config/page.tsx +++ b/src/app/(main)/config/page.tsx @@ -11,7 +11,7 @@ interface ConfigItem { key: string; label: string; group: string; - type: string; // int / int_list / dict_str_int / bool + type: string; // int / int_list / dict_str_int / bool / json help: string | null; // eslint-disable-next-line @typescript-eslint/no-explicit-any default: any; @@ -24,7 +24,7 @@ interface ConfigItem { // eslint-disable-next-line @typescript-eslint/no-explicit-any function toEdit(item: ConfigItem): any { if (item.type === 'int_list') return (item.value as number[]).join(', '); - if (item.type === 'dict_str_int') return JSON.stringify(item.value); + if (item.type === 'dict_str_int' || item.type === 'json') return JSON.stringify(item.value); return item.value; } @@ -37,7 +37,7 @@ function fromEdit(type: string, raw: any): any { .split(',') .map((s) => parseInt(s.trim(), 10)); } - if (type === 'dict_str_int') return JSON.parse(raw); + if (type === 'dict_str_int' || type === 'json') return JSON.parse(raw); return raw; }