diff --git a/apps/admin/app/dashboard/nodes/node-form.tsx b/apps/admin/app/dashboard/nodes/node-form.tsx index 87dc4e9..527890a 100644 --- a/apps/admin/app/dashboard/nodes/node-form.tsx +++ b/apps/admin/app/dashboard/nodes/node-form.tsx @@ -92,7 +92,7 @@ export default function NodeForm(props: { const { data } = useQuery({ queryKey: ['filterServerListAll'], queryFn: async () => { - const { data } = await filterServerList({ page: 1, size: 1000 }); + const { data } = await filterServerList({ page: 1, size: 999999999 }); return data?.data?.list || []; }, }); @@ -130,17 +130,32 @@ export default function NodeForm(props: { const sel = servers.find((s) => s.id === id); const dirty = form.formState.dirtyFields as Record; + const currentValues = form.getValues(); + if (!dirty.name) { form.setValue('name', (sel?.name as string) || '', { shouldDirty: false }); } - if (!dirty.address) { + + if ( + !dirty.address && + (!currentValues.address || currentValues.address === (sel?.address as string)) + ) { form.setValue('address', (sel?.address as string) || '', { shouldDirty: false }); } + const allowed = (sel?.protocols || []) .map((p) => (p as any).type as ProtocolName) .filter(Boolean); - if (!allowed.includes(form.getValues('protocol') as ProtocolName)) { - form.setValue('protocol', '' as any); + + const currentProtocol = form.getValues('protocol') as ProtocolName; + + if (!allowed.includes(currentProtocol)) { + const firstProtocol = allowed[0] || ''; + form.setValue('protocol', firstProtocol as any); + + if (firstProtocol) { + handleProtocolChange(firstProtocol); + } } } @@ -148,13 +163,18 @@ export default function NodeForm(props: { const p = (nextProto || '') as ProtocolName | ''; form.setValue('protocol', p); if (!p || !currentServer) return; + const dirty = form.formState.dirtyFields as Record; + const currentValues = form.getValues(); + if (!dirty.port) { const hit = (currentServer.protocols as any[]).find((x) => (x as any).type === p); const port = (hit as any)?.port as number | undefined; - form.setValue('port', typeof port === 'number' && port > 0 ? port : 0, { - shouldDirty: false, - }); + const newPort = typeof port === 'number' && port > 0 ? port : 0; + + if (!currentValues.port || currentValues.port === 0 || currentValues.port === newPort) { + form.setValue('port', newPort, { shouldDirty: false }); + } } } diff --git a/apps/admin/app/dashboard/nodes/page.tsx b/apps/admin/app/dashboard/nodes/page.tsx index 9e226e8..230a857 100644 --- a/apps/admin/app/dashboard/nodes/page.tsx +++ b/apps/admin/app/dashboard/nodes/page.tsx @@ -28,7 +28,7 @@ export default function NodesPage() { const { data: servers = [] } = useQuery({ queryKey: ['filterServerListAll'], queryFn: async () => { - const { data } = await filterServerList({ page: 1, size: 1000 }); + const { data } = await filterServerList({ page: 1, size: 999999999 }); return data?.data?.list || []; }, }); diff --git a/apps/admin/app/dashboard/order/page.tsx b/apps/admin/app/dashboard/order/page.tsx index 51a020c..40cf094 100644 --- a/apps/admin/app/dashboard/order/page.tsx +++ b/apps/admin/app/dashboard/order/page.tsx @@ -37,7 +37,7 @@ export default function Page() { queryFn: async () => { const { data } = await getSubscribeList({ page: 1, - size: 9999, + size: 999999999, }); return data.data?.list as API.SubscribeGroup[]; }, diff --git a/apps/admin/app/dashboard/product/subscribe-form.tsx b/apps/admin/app/dashboard/product/subscribe-form.tsx index 13c9c65..f7c2f12 100644 --- a/apps/admin/app/dashboard/product/subscribe-form.tsx +++ b/apps/admin/app/dashboard/product/subscribe-form.tsx @@ -241,7 +241,7 @@ export default function SubscribeForm>({ const { data: nodes } = useQuery({ queryKey: ['filterNodeListAll'], queryFn: async () => { - const { data } = await filterNodeList({ page: 1, size: 9999 }); + const { data } = await filterNodeList({ page: 1, size: 999999999 }); return (data.data?.list || []) as API.Node[]; }, });