From c230d5a744f436178acde91398fd392b35bf2e41 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 30 Jun 2026 11:52:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E8=A7=A3=E5=86=B3=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0DNS=E8=B4=A6=E5=8F=B7=E6=97=B6this.post=20is=20not=20a?= =?UTF-8?q?=20function=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 DnsAccountCreateDialog 组件中,mutationFn 错误地直接传递了类静态方法 DnsAccountService.create,导致执行时丢失 class constructor 上下文。现将其修改为使用箭头函数包裹,以保证 this 指向正确。 --- docs/changelog/index.md | 1 + .../(main)/websites/components/dns-account-create-dialog.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 366803f3..67e86df0 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -20,6 +20,7 @@ sidebar: false ### 修复 +- 修复添加 DNS 账号时因直接传递 class static 方法作为 React Query 的 mutationFn 导致 JavaScript 丢失 `this` 上下文报错 `this.post is not a function` 的问题。 - 修复侧边栏一级菜单项当前页面字体颜色被硬编码为 `#6366F1` 的问题,改用 CSS 主题变量 `text-sidebar-primary`,以保证在多主题系统下的色彩一致性。 - 修复默认(Default)主题因遗漏声明 `destructive-foreground` 变量,导致删除按钮(如确认删除证书弹窗)在某些状态下渲染为黑底黑字而无法阅读的问题。 diff --git a/frontend/app/(main)/websites/components/dns-account-create-dialog.tsx b/frontend/app/(main)/websites/components/dns-account-create-dialog.tsx index e0adfd5b..c8f9893c 100644 --- a/frontend/app/(main)/websites/components/dns-account-create-dialog.tsx +++ b/frontend/app/(main)/websites/components/dns-account-create-dialog.tsx @@ -20,6 +20,7 @@ import {Input} from '@/components/ui/input'; import {Label} from '@/components/ui/label'; import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from '@/components/ui/select'; import {DnsAccountService} from '@/lib/services/openflare'; +import type {DnsAccountMutationPayload} from '@/lib/services/openflare'; import {getErrorMessage} from './website-utils'; @@ -52,7 +53,7 @@ export function DnsAccountCreateDialog({ }); const createMutation = useMutation({ - mutationFn: DnsAccountService.create, + mutationFn: (payload: DnsAccountMutationPayload) => DnsAccountService.create(payload), onSuccess: async () => { await queryClient.invalidateQueries({queryKey: dnsAccountsQueryKey}); form.reset();