From d615d85a26c70a334cf5039d944cc9a79776b782 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 12 Jul 2026 16:16:56 +0800 Subject: [PATCH] refactor: remove unused remarks and add quick domain create Drop remark fields from Zone, Zone domains, proxy routes, WAF rule groups and IP groups across models, APIs, UI and DB columns (keep certificate/origin remarks). Add quick-create domain input for short labels, @ apex and full FQDNs when binding domains. --- docs/changelog/index.md | 1 + docs/design/zone-design.md | 6 +- docs/docs.go | 33 -- docs/swagger.json | 33 -- docs/swagger.yaml | 22 -- .../(main)/proxy-routes/components/helpers.ts | 1 - .../components/proxy-route-create-sheet.tsx | 23 +- .../components/zone-domain-selector.tsx | 87 ++++-- .../detail/components/domain-section.tsx | 7 +- .../detail/components/proxy-section.tsx | 18 -- .../app/(main)/proxy-routes/page-client.tsx | 1 - frontend/app/(main)/waf/components/helpers.ts | 3 - .../(main)/waf/components/ip-group-dialog.tsx | 17 -- .../waf/components/rule-group-sheet.tsx | 17 -- .../components/zone-domain-dialog.tsx | 148 +-------- .../components/zone-domains-table.tsx | 9 +- .../components/zone-editor-dialog.tsx | 77 ++++- .../[zoneId]/components/zone-overview.tsx | 2 +- .../(main)/websites/[zoneId]/page-client.tsx | 1 + .../quick-create-zone-domain-dialog.tsx | 285 ++++++++++++++++++ .../components/resolve-zone-domain-input.ts | 55 ++++ frontend/app/(main)/websites/page.tsx | 1 - frontend/lib/services/openflare/types.ts | 10 - .../zone/resolve-zone-domain-input.test.ts | 28 ++ frontend/tests/zone/websites-page.test.tsx | 2 - .../tests/zone/zone-domain-selector.test.tsx | 46 ++- frontend/tests/zone/zone-page.test.tsx | 2 +- .../apps/openflare/config_version/snapshot.go | 2 - .../openflare/integration/security_test.go | 5 +- .../openflare/proxy_route/build_helpers.go | 5 +- internal/apps/openflare/proxy_route/logics.go | 5 - internal/apps/openflare/waf/logics.go | 8 - internal/apps/openflare/waf/logics_test.go | 1 - internal/apps/openflare/zone/errs.go | 2 +- internal/apps/openflare/zone/legacy_import.go | 28 +- .../apps/openflare/zone/legacy_import_test.go | 4 - internal/apps/openflare/zone/logics.go | 12 +- ...02607140001_drop_unused_remark_columns.sql | 16 + ...02607140001_drop_unused_remark_columns.sql | 17 ++ internal/model/openflare_proxy_route.go | 2 - internal/model/openflare_waf.go | 4 - internal/model/openflare_zone.go | 2 - pkg/render/openresty/types.go | 1 - 43 files changed, 616 insertions(+), 433 deletions(-) create mode 100644 frontend/app/(main)/websites/components/quick-create-zone-domain-dialog.tsx create mode 100644 frontend/app/(main)/websites/components/resolve-zone-domain-input.ts create mode 100644 frontend/tests/zone/resolve-zone-domain-input.test.ts create mode 100644 internal/db/migrator/goose/postgres/202607140001_drop_unused_remark_columns.sql create mode 100644 internal/db/migrator/goose/sqlite/202607140001_drop_unused_remark_columns.sql diff --git a/docs/changelog/index.md b/docs/changelog/index.md index c69cfe29..4e371283 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -37,6 +37,7 @@ sidebar: false ### 移除 - 移除托管域名(managed-domains)管理 API 与前端 `WebsiteService`;请改用 Zone / Zone 域名 API。 +- 移除 Zone、Zone 域名、反代路由、WAF 规则组与 IP 组的备注字段(前后端与数据库列同步删除);证书与源站备注保留。 ### 修复 diff --git a/docs/design/zone-design.md b/docs/design/zone-design.md index 3635b669..c046272c 100644 --- a/docs/design/zone-design.md +++ b/docs/design/zone-design.md @@ -27,7 +27,6 @@ erDiagram ZONES { uint id PK string domain UK - string remark } ZONE_DOMAINS { uint id PK @@ -35,17 +34,16 @@ erDiagram uint proxy_route_id string domain UK uint cert_id - string remark } ``` ### `of_zones` -保存根域、备注、创建时间与更新时间。根域全局唯一且创建后不可原地修改;需要变更时新建 Zone 并迁移域名。删除 Zone 前必须先清空其 Zone 域名。 +保存根域、创建时间与更新时间。根域全局唯一且创建后不可原地修改;需要变更时新建 Zone 并迁移域名。删除 Zone 前必须先清空其 Zone 域名。 ### `of_zone_domains` -保存 `zone_id`、明确 `domain`、可空的 `proxy_route_id`、可空的 `cert_id`、备注及时间戳。`domain` 全局唯一;所有关系字段建立索引但不建立物理外键。`proxy_route_id` 允许为空,以承接已准备证书但尚未配置反代的历史域名。 +保存 `zone_id`、明确 `domain`、可空的 `proxy_route_id`、可空的 `cert_id` 及时间戳。`domain` 全局唯一;所有关系字段建立索引但不建立物理外键。`proxy_route_id` 允许为空,以承接已准备证书但尚未配置反代的历史域名。 `of_proxy_routes` 逐步移除 `domain`、`domains`、`cert_id`、`cert_ids` 与 `domain_cert_ids` 等域名/证书冗余列。路由不得再指定任何 TLS 证书;路由名称 `site_name` 成为稳定的人类可读标识,编译器从关联的 Zone 域名读取 `server_name` 与其 `cert_id`。这使每个明确域名的证书只有一个来源。 diff --git a/docs/docs.go b/docs/docs.go index b6c7e6a0..e5ab06c5 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -15436,9 +15436,6 @@ const docTemplate = `{ "id": { "type": "integer" }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" } @@ -15462,9 +15459,6 @@ const docTemplate = `{ "proxy_route_id": { "type": "integer" }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" }, @@ -17133,9 +17127,6 @@ const docTemplate = `{ "redirect_http": { "type": "boolean" }, - "remark": { - "type": "string" - }, "site_name": { "type": "string" }, @@ -17240,9 +17231,6 @@ const docTemplate = `{ "redirect_http": { "type": "boolean" }, - "remark": { - "type": "string" - }, "site_name": { "type": "string" }, @@ -18553,9 +18541,6 @@ const docTemplate = `{ "name": { "type": "string" }, - "remark": { - "type": "string" - }, "subscription_format": { "type": "string" }, @@ -18644,9 +18629,6 @@ const docTemplate = `{ "referenced_by_rule_count": { "type": "integer" }, - "remark": { - "type": "string" - }, "subscription_format": { "type": "string" }, @@ -18796,9 +18778,6 @@ const docTemplate = `{ "items": { "type": "string" } - }, - "remark": { - "type": "string" } } }, @@ -18889,9 +18868,6 @@ const docTemplate = `{ "type": "string" } }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" } @@ -18934,9 +18910,6 @@ const docTemplate = `{ }, "domain": { "type": "string" - }, - "remark": { - "type": "string" } } }, @@ -18945,9 +18918,6 @@ const docTemplate = `{ "properties": { "domain": { "type": "string" - }, - "remark": { - "type": "string" } } }, @@ -18966,9 +18936,6 @@ const docTemplate = `{ "id": { "type": "integer" }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" } diff --git a/docs/swagger.json b/docs/swagger.json index 68a89b1b..0a2183f9 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -15429,9 +15429,6 @@ "id": { "type": "integer" }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" } @@ -15455,9 +15452,6 @@ "proxy_route_id": { "type": "integer" }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" }, @@ -17126,9 +17120,6 @@ "redirect_http": { "type": "boolean" }, - "remark": { - "type": "string" - }, "site_name": { "type": "string" }, @@ -17233,9 +17224,6 @@ "redirect_http": { "type": "boolean" }, - "remark": { - "type": "string" - }, "site_name": { "type": "string" }, @@ -18546,9 +18534,6 @@ "name": { "type": "string" }, - "remark": { - "type": "string" - }, "subscription_format": { "type": "string" }, @@ -18637,9 +18622,6 @@ "referenced_by_rule_count": { "type": "integer" }, - "remark": { - "type": "string" - }, "subscription_format": { "type": "string" }, @@ -18789,9 +18771,6 @@ "items": { "type": "string" } - }, - "remark": { - "type": "string" } } }, @@ -18882,9 +18861,6 @@ "type": "string" } }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" } @@ -18927,9 +18903,6 @@ }, "domain": { "type": "string" - }, - "remark": { - "type": "string" } } }, @@ -18938,9 +18911,6 @@ "properties": { "domain": { "type": "string" - }, - "remark": { - "type": "string" } } }, @@ -18959,9 +18929,6 @@ "id": { "type": "integer" }, - "remark": { - "type": "string" - }, "updated_at": { "type": "string" } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 4a4473b4..48a4f105 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1631,8 +1631,6 @@ definitions: type: string id: type: integer - remark: - type: string updated_at: type: string type: object @@ -1648,8 +1646,6 @@ definitions: type: integer proxy_route_id: type: integer - remark: - type: string updated_at: type: string zone_id: @@ -2742,8 +2738,6 @@ definitions: type: integer redirect_http: type: boolean - remark: - type: string site_name: type: string tunnel_id: @@ -2813,8 +2807,6 @@ definitions: type: integer redirect_http: type: boolean - remark: - type: string site_name: type: string tunnel_id: @@ -3697,8 +3689,6 @@ definitions: type: array name: type: string - remark: - type: string subscription_format: type: string subscription_mapping_rule: @@ -3757,8 +3747,6 @@ definitions: type: string referenced_by_rule_count: type: integer - remark: - type: string subscription_format: type: string subscription_mapping_rule: @@ -3858,8 +3846,6 @@ definitions: items: type: string type: array - remark: - type: string type: object waf.RuleGroupView: properties: @@ -3919,8 +3905,6 @@ definitions: items: type: string type: array - remark: - type: string updated_at: type: string type: object @@ -3949,15 +3933,11 @@ definitions: type: integer domain: type: string - remark: - type: string type: object zone.Input: properties: domain: type: string - remark: - type: string type: object zone.ListItem: properties: @@ -3969,8 +3949,6 @@ definitions: type: integer id: type: integer - remark: - type: string updated_at: type: string type: object diff --git a/frontend/app/(main)/proxy-routes/components/helpers.ts b/frontend/app/(main)/proxy-routes/components/helpers.ts index 95666714..05443839 100644 --- a/frontend/app/(main)/proxy-routes/components/helpers.ts +++ b/frontend/app/(main)/proxy-routes/components/helpers.ts @@ -338,7 +338,6 @@ export function buildPayloadFromRoute( cache_policy: route.cache_policy || 'url', cache_rules: route.cache_rule_list ?? [], custom_headers: route.custom_header_list ?? [], - remark: route.remark || '', basic_auth_enabled: route.basic_auth_enabled, basic_auth_username: route.basic_auth_username, basic_auth_password: route.basic_auth_password, diff --git a/frontend/app/(main)/proxy-routes/components/proxy-route-create-sheet.tsx b/frontend/app/(main)/proxy-routes/components/proxy-route-create-sheet.tsx index 6473d354..b1847659 100644 --- a/frontend/app/(main)/proxy-routes/components/proxy-route-create-sheet.tsx +++ b/frontend/app/(main)/proxy-routes/components/proxy-route-create-sheet.tsx @@ -11,7 +11,6 @@ import {Form, FormControl, FormDescription, FormField, FormItem, FormLabel, Form import {Input} from '@/components/ui/input'; import {Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle,} from '@/components/ui/sheet'; import {Switch} from '@/components/ui/switch'; -import {Textarea} from '@/components/ui/textarea'; import type {ProxyRouteItem} from '@/lib/services/openflare'; import {ProxyRouteService, ZoneService, zoneQueryKey} from '@/lib/services/openflare'; @@ -24,7 +23,6 @@ const createProxyRouteSchema = z zone_domain_ids: z.array(z.number().int().positive()).min(1, '请至少选择一个域名'), origin_url: z.string().trim().min(1, '请输入上游地址'), enabled: z.boolean(), - remark: z.string().max(255, '备注不能超过 255 个字符'), }) .superRefine((value, context) => { try { @@ -52,7 +50,6 @@ const defaultValues: CreateProxyRouteFormValues = { zone_domain_ids: [], origin_url: '', enabled: true, - remark: '', }; interface ProxyRouteCreateSheetProps { @@ -120,7 +117,6 @@ export function ProxyRouteCreateSheet({ cache_rules: [], custom_headers: [], basic_auth_enabled: false, - remark: values.remark.trim(), upstream_type: 'direct', }); @@ -174,10 +170,13 @@ export function ProxyRouteCreateSheet({ domains={domainsQuery.data ?? []} zones={zonesQuery.data ?? []} disabled={domainsQuery.isLoading} + onDomainCreated={async () => { + await domainsQuery.refetch(); + }} /> - 域名与证书在 Zone 中维护;此处只选择本站点要绑定的 FQDN。 + 勾选已登记域名,或使用「快捷新增域名」创建后自动勾选。 @@ -214,20 +213,6 @@ export function ProxyRouteCreateSheet({ )} /> - ( - - 备注 - -