diff --git a/.env.production b/.env.production index e69de29..6e2d2cf 100644 --- a/.env.production +++ b/.env.production @@ -0,0 +1 @@ +NEXT_PUBLIC_API_SERVER=http://localhost:19159 \ No newline at end of file diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 58feefe..531413f 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -14,6 +14,12 @@ const Dashboard: React.FC = () => { const { data: entity, error, isLoading } = useSWR("/v1/configuration", fetcher); const { trigger } = useSWRMutation("/v1/configuration", put); const formRef = useRef(); + const [formKey, setFormKey] = useState(0); // 初始化一个key + + // 触发表单重新挂载 + const remountForm = () => { + setFormKey(prevKey => prevKey + 1); // 更新key的值 + }; const [labelPosition, setLabelPosition] = useState<'top' | 'left' | 'inset'>('inset'); useEffect(() => { @@ -27,6 +33,10 @@ const Dashboard: React.FC = () => { }) return () => unRegister(); }, []); + + useEffect(() => { + remountForm(); + }, [entity]); // const handleSelectChange = (value) => { // let text = value === 'male' ? 'Hi male' : 'Hi female!'; // formRef.current?.setValue('Note', text); @@ -50,7 +60,8 @@ const Dashboard: React.FC = () => { > -
{ await trigger(values) }} @@ -62,11 +73,11 @@ const Dashboard: React.FC = () => { label={{text: "分段大小"} } suffix={'MB'} /> - = ({ formState, formApi, values }) = const {biliUsers} = useBiliUsers(); const list = biliUsers?.map((item) => { return { - value: item.id, label: <> + value: item.value, label: <> {item.name} @@ -64,7 +64,7 @@ const TemplateFields: React.FC = ({ formState, formApi, values }) = field="copyright" label='类型' direction='vertical' - initValue={1} + // initValue={1} >
formApi.setValue('source', '')}> 自制 @@ -97,7 +97,7 @@ const TemplateFields: React.FC = ({ formState, formApi, values }) = style={{width: 560}} />