fix(webui): keep node dialog actions visible

Separate the node editor into fixed header and footer rows with an independently scrollable form body, so short viewports cannot push the save action out of reach.
This commit is contained in:
DrSmoothl committed 2026-07-22 00:02:48 +08:00
1 parent 622c90d418
commit 7fb8aa1d42
2 files changed
+87 -75

No files matched your search

@@ -92,8 +92,11 @@ export function NodeEditDialog<K extends NetworkKind>(props: NodeEditDialogProps
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-xl"> <DialogContent
<DialogHeader> className="max-w-xl"
viewportClassName="grid max-h-[calc(100dvh_-_2rem)] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0"
>
<DialogHeader className="px-4 pb-4 pr-14 pt-5 sm:px-6 sm:pr-16 sm:pt-6">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className="flex size-11 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary"> <div className="flex size-11 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary">
<Icon className="size-5" /> <Icon className="size-5" />
@@ -105,90 +108,93 @@ export function NodeEditDialog<K extends NetworkKind>(props: NodeEditDialogProps
</div> </div>
</DialogHeader> </DialogHeader>
<div className="flex flex-col gap-5"> <div className="min-h-0 overflow-y-auto overscroll-contain px-4 pb-5 sm:px-6">
<motion.div <div className="flex flex-col gap-5">
initial={{ opacity: 0, y: 8 }} <motion.div
animate={{ opacity: 1, y: 0 }} initial={{ opacity: 0, y: 8 }}
transition={{ duration: 0.3, delay: 0 }} animate={{ opacity: 1, y: 0 }}
className="flex items-center justify-between gap-4 rounded-2xl border border-border/60 bg-card/60 px-4 py-3.5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]" transition={{ duration: 0.3, delay: 0 }}
> className="flex items-center justify-between gap-4 rounded-2xl border border-border/60 bg-card/60 px-4 py-3.5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]"
<div className="min-w-0"> >
<Label className="text-sm font-medium text-foreground">启用</Label> <div className="min-w-0">
<p className="mt-0.5 text-xs leading-relaxed text-muted-foreground"> <Label className="text-sm font-medium text-foreground">启用</Label>
关闭后保存即可保留配置但不启动该节点 <p className="mt-0.5 text-xs leading-relaxed text-muted-foreground">
</p> 关闭后保存即可保留配置但不启动该节点
</div> </p>
<ToggleSwitch </div>
value={draft.enabled !== false} <ToggleSwitch
onChange={(v) => patch({ enabled: v ? undefined : false } as Partial<AnyAdapter<K>>)} value={draft.enabled !== false}
ariaLabel="启用" onChange={(v) => patch({ enabled: v ? undefined : false } as Partial<AnyAdapter<K>>)}
/> ariaLabel="启用"
</motion.div>
<Section caption="连接" delay={0.05}>
<div className="flex flex-col gap-3 p-4">
<Field
label="名称"
placeholder="自定义"
value={draft.name}
onChange={(v) => patch({ name: v } as Partial<AnyAdapter<K>>)}
error={blankName ? '请填写名称' : duplicateName ? '名称与其它节点重复' : undefined}
/> />
<KindFields kind={kind} draft={draft} patch={patch} /> </motion.div>
</div>
</Section>
<Section caption="鉴权" delay={0.1}> <Section caption="连接" delay={0.05}>
<div className="p-4"> <div className="flex flex-col gap-3 p-4">
<TokenField <Field
label="授权 Token" label="名称"
placeholder="不填则无密码" placeholder="自定义"
value={draft.accessToken} value={draft.name}
onChange={(v) => patch({ accessToken: v || undefined } as Partial<AnyAdapter<K>>)} onChange={(v) => patch({ name: v } as Partial<AnyAdapter<K>>)}
/> error={blankName ? '请填写名称' : duplicateName ? '名称与其它节点重复' : undefined}
</div>
</Section>
<Section caption="行为" delay={0.15}>
<div className="divide-y divide-border/60">
<SettingRow label="消息格式" desc="数组为标准 OneBot 段,CQ 码为兼容字符串">
<DropdownSelect
className="w-32"
ariaLabel="消息格式"
value={(draft.messageFormat ?? 'array') as MessageFormat}
options={FORMAT_OPTIONS}
onChange={(v) => patch({ messageFormat: v } as Partial<AnyAdapter<K>>)}
/> />
</SettingRow> <KindFields kind={kind} draft={draft} patch={patch} />
</div>
</Section>
{isWs && ( <Section caption="鉴权" delay={0.1}>
<SettingRow label="角色" desc="Universal 收发合一,Event / Api 分离"> <div className="p-4">
<TokenField
label="授权 Token"
placeholder="不填则无密码"
value={draft.accessToken}
onChange={(v) => patch({ accessToken: v || undefined } as Partial<AnyAdapter<K>>)}
/>
</div>
</Section>
<Section caption="行为" delay={0.15}>
<div className="divide-y divide-border/60">
<SettingRow label="消息格式" desc="数组为标准 OneBot 段,CQ 码为兼容字符串">
<DropdownSelect <DropdownSelect
className="w-32" className="w-32"
ariaLabel="角色" ariaLabel="消息格式"
value={role} value={(draft.messageFormat ?? 'array') as MessageFormat}
options={WS_ROLE_OPTIONS} options={FORMAT_OPTIONS}
onChange={(v) => patch({ role: v } as unknown as Partial<AnyAdapter<K>>)} onChange={(v) => patch({ messageFormat: v } as Partial<AnyAdapter<K>>)}
/> />
</SettingRow> </SettingRow>
)}
<SettingRow label="上报自身消息" desc="将机器人自己发送的消息也作为 message_sent 事件上报"> {isWs && (
<ToggleSwitch <SettingRow label="角色" desc="Universal 收发合一,Event / Api 分离">
value={!!draft.reportSelfMessage} <DropdownSelect
onChange={(v) => patch({ reportSelfMessage: v } as Partial<AnyAdapter<K>>)} className="w-32"
ariaLabel="上报自身消息" ariaLabel="角色"
/> value={role}
</SettingRow> options={WS_ROLE_OPTIONS}
</div> onChange={(v) => patch({ role: v } as unknown as Partial<AnyAdapter<K>>)}
</Section> />
</SettingRow>
)}
<SettingRow label="上报自身消息" desc="将机器人自己发送的消息也作为 message_sent 事件上报">
<ToggleSwitch
value={!!draft.reportSelfMessage}
onChange={(v) => patch({ reportSelfMessage: v } as Partial<AnyAdapter<K>>)}
ariaLabel="上报自身消息"
/>
</SettingRow>
</div>
</Section>
</div>
</div> </div>
<DialogFooter> <DialogFooter className="flex-row justify-end border-t border-border/60 bg-card px-4 py-3 sm:px-6 sm:py-4">
<Button variant="outline" onClick={() => onOpenChange(false)}> <Button className="flex-1 sm:flex-none" variant="outline" onClick={() => onOpenChange(false)}>
取消 取消
</Button> </Button>
<Button <Button
className="flex-1 sm:flex-none"
disabled={!canSave} disabled={!canSave}
onClick={() => { onClick={() => {
const cleaned = { ...draft, name: trimmedName } as AnyAdapter<K>; const cleaned = { ...draft, name: trimmedName } as AnyAdapter<K>;
+9 -3
View File
@@ -26,8 +26,11 @@ DialogOverlay.displayName = 'DialogOverlay';
const DialogContent = React.forwardRef< const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>, React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & { showClose?: boolean } React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
>(({ className, children, showClose = true, ...props }, ref) => ( showClose?: boolean;
viewportClassName?: string;
}
>(({ className, children, showClose = true, viewportClassName, ...props }, ref) => (
<DialogPortal> <DialogPortal>
<DialogOverlay /> <DialogOverlay />
<DialogPrimitive.Content <DialogPrimitive.Content
@@ -44,7 +47,10 @@ const DialogContent = React.forwardRef<
)} )}
{...props} {...props}
> >
<div className="grid max-h-[calc(100dvh_-_2rem)] gap-4 overflow-y-auto overscroll-contain p-6"> <div className={cn(
'grid max-h-[calc(100dvh_-_2rem)] gap-4 overflow-y-auto overscroll-contain p-6',
viewportClassName,
)}>
{children} {children}
</div> </div>
{showClose && ( {showClose && (