From 9d6f1010067dff65db51ba489d9d28d6d02c81ae Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 10 Nov 2025 15:51:18 +0800 Subject: [PATCH] fix(usage-script): replace FormLabel with Label to fix white screen crash FormLabel component requires FormField context and throws error when used standalone, causing the entire component to crash with a white screen. Root cause: - FormLabel internally calls useFormField() hook - useFormField() requires FormFieldContext (must be within ) - Without context, it throws: "useFormField should be used within " - Uncaught error crashes React rendering tree Solution: - Replace FormLabel with standalone Label component - Label component from @/components/ui/label doesn't depend on form context - Maintains same styling (text-sm font-medium) without requiring context This fixes the white screen issue when clicking the usage panel. --- src/components/UsageScriptModal.tsx | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/UsageScriptModal.tsx b/src/components/UsageScriptModal.tsx index 899b5ba..4e37dd2 100644 --- a/src/components/UsageScriptModal.tsx +++ b/src/components/UsageScriptModal.tsx @@ -17,7 +17,7 @@ import { } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; -import { FormLabel } from "@/components/ui/form"; +import { Label } from "@/components/ui/label"; interface UsageScriptModalProps { provider: Provider; @@ -298,9 +298,9 @@ const UsageScriptModal: React.FC = ({ <> {/* 预设模板选择 */}
- + +
{Object.keys(PRESET_TEMPLATES).map((name) => { const isSelected = selectedTemplate === name; @@ -332,9 +332,9 @@ const UsageScriptModal: React.FC = ({ {selectedTemplate === TEMPLATE_KEYS.GENERAL && ( <>
- + +
= ({
- + + = ({ {selectedTemplate === TEMPLATE_KEYS.NEW_API && ( <>
- + + = ({
- + +
= ({
- + + = ({ {/* 脚本编辑器 */}
- + + setScript({ ...script, code })} @@ -466,9 +466,9 @@ const UsageScriptModal: React.FC = ({ {/* 配置选项 */}
- + + = ({ {/* 🆕 自动查询间隔 */}
- + +