From c264ec66738a93fa3f9f23b118fe22588c337865 Mon Sep 17 00:00:00 2001 From: wc24 Date: Mon, 29 Jun 2026 22:25:58 +0800 Subject: [PATCH] =?UTF-8?q?feat!:=20=E5=8E=BB=E6=8E=89=20json=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B(object=20=E5=8F=96=E4=BB=A3)=20+=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=200.7.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - object 字段已能声明式表达嵌套结构,freeform 的 json 类型不再需要: 删 ShrimpFieldTypes.Json + defaultTypeHandlers[Json](reqFilter/resFilter)。 - 源码无任何 type:json 使用,安全移除。 - 前后端版本自此统一:一起推的版本用相同版本号,本批 = 0.7.0。 --- package.json | 2 +- src/IShrimpType.ts | 1 - src/Shrimp/ShrimpTableModule.ts | 20 -------------------- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/package.json b/package.json index 5fbded2..068bc90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shrimp-server", - "version": "0.6.11", + "version": "0.7.0", "description": "Shrimp 框架后端 — 声明式字段驱动的 Node.js 管理后台框架(Express + Mongoose + JWT)", "main": "dist/main/index.js", "types": "dist/main/index.d.ts", diff --git a/src/IShrimpType.ts b/src/IShrimpType.ts index bd02d7d..c329bbb 100644 --- a/src/IShrimpType.ts +++ b/src/IShrimpType.ts @@ -235,7 +235,6 @@ export const ShrimpFieldTypes = { Textarea: "textarea" as ShrimpFieldType, Password: "password" as ShrimpFieldType, Relation: "relation" as ShrimpFieldType, - Json: "json" as ShrimpFieldType, Tab: "tab" as ShrimpFieldType, Object: "object" as ShrimpFieldType, Array: "array" as ShrimpFieldType, diff --git a/src/Shrimp/ShrimpTableModule.ts b/src/Shrimp/ShrimpTableModule.ts index 2a8c5e9..50a94c1 100644 --- a/src/Shrimp/ShrimpTableModule.ts +++ b/src/Shrimp/ShrimpTableModule.ts @@ -27,26 +27,6 @@ export const defaultTypeHandlers: Record = { [ShrimpFieldTypes.Boolean]: { defaultValue: false, }, - [ShrimpFieldTypes.Json]: { - reqFilter: (value) => { - if (value == null || value === "") return undefined - if (typeof value === "string") { - try { - return JSON.parse(value) - } catch { - throw new ShrimpError({ t: 'shrimp.invalidJson' }) - } - } - return value - }, - resFilter: (value) => { - if (value == null) return value - if (typeof value === "object") { - return JSON.stringify(value) - } - return value - }, - }, [ShrimpFieldTypes.Tab]: { // tab 是结构化字段:库里/响应/编辑全程是对象,只在"给人看"的边界(import/export/label)走字符串。 reqFilter: (value, field) => {