refactor: unify realtime canvas enhance panel styling
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-04-05 22:26:05 +08:00
parent 3100d10dc0
commit b0245c5366
2 changed files with 232 additions and 227 deletions

View File

@ -20,7 +20,6 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch"; import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { import {
@ -88,10 +87,14 @@ const FALLBACK_CONFIG: EnhanceProClientConfig = {
presets: defaultEnhanceProPresets(), presets: defaultEnhanceProPresets(),
}; };
const PANEL_SHELL_CLASS =
"rounded-[28px] border border-[#e7e1d4] bg-white/78 shadow-[0_20px_50px_rgba(15,23,42,0.08)] backdrop-blur-xl";
const SOLID_PANEL_FIELD_CLASS = const SOLID_PANEL_FIELD_CLASS =
"border-border/60 bg-background text-foreground shadow-sm"; "border-[#e8e2d8] bg-[#fffdfa] text-foreground shadow-[0_8px_20px_rgba(15,23,42,0.05)]";
const SOLID_PANEL_CARD_CLASS = const SOLID_PANEL_CARD_CLASS =
"rounded-2xl border border-border/60 bg-card shadow-sm"; "rounded-[22px] border border-[#e8e2d8] bg-[#fffdfa] shadow-[0_8px_20px_rgba(15,23,42,0.05)]";
const PANEL_SECTION_TITLE_CLASS = "font-semibold text-[13px] text-slate-700";
const PANEL_SECTION_NOTE_CLASS = "text-[11px] leading-5 text-slate-500";
function clampNumber(value: number, min: number, max: number) { function clampNumber(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value)); return Math.min(max, Math.max(min, value));
@ -543,12 +546,12 @@ export function EnhanceProWorkspace({
) : null} ) : null}
</div> </div>
<div className="flex h-full w-[420px] max-w-[42vw] shrink-0 flex-col border-border/60 border-l bg-[#fcfbf7]"> <div className="flex h-full w-[420px] max-w-[42vw] shrink-0 flex-col border-[#e7e1d4] border-l bg-[linear-gradient(180deg,#f8f5ee_0%,#f6f2e9_100%)]">
<div className="min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4 pt-6"> <div className="min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4 pt-6">
{isLoading ? ( {isLoading ? (
<div <div
className={cn( className={cn(
SOLID_PANEL_CARD_CLASS, PANEL_SHELL_CLASS,
"flex items-center gap-2 px-4 py-3 text-muted-foreground text-sm" "flex items-center gap-2 px-4 py-3 text-muted-foreground text-sm"
)} )}
> >
@ -570,66 +573,66 @@ export function EnhanceProWorkspace({
</div> </div>
) : null} ) : null}
<div className="space-y-2"> <div className={cn(PANEL_SHELL_CLASS, "space-y-4 px-4 py-4")}>
<Label className="text-[11px] uppercase tracking-[0.08em] text-muted-foreground"> <div className="space-y-2">
增强预设 <Label className={PANEL_SECTION_TITLE_CLASS}>增强预设</Label>
</Label> <Select onValueChange={handleSelectPreset} value={selectedPresetId}>
<Select onValueChange={handleSelectPreset} value={selectedPresetId}> <SelectTrigger
<SelectTrigger className={`${SOLID_PANEL_FIELD_CLASS} h-10`}> className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
<SelectValue placeholder="选择一个增强预设" /> >
</SelectTrigger> <SelectValue placeholder="选择一个增强预设" />
<SelectContent> </SelectTrigger>
{presets.map((preset) => ( <SelectContent>
<SelectItem key={preset.id} value={preset.id}> {presets.map((preset) => (
{preset.name} <SelectItem key={preset.id} value={preset.id}>
</SelectItem> {preset.name}
))} </SelectItem>
</SelectContent> ))}
</Select> </SelectContent>
{selectedPreset ? ( </Select>
<div className="line-clamp-2 text-[11px] leading-5 text-muted-foreground"> {selectedPreset ? (
{selectedPreset.description || <div className={cn(PANEL_SECTION_NOTE_CLASS, "line-clamp-2")}>
`${selectedPreset.model} · ${getSubjectDetectionLabel(selectedPreset.subjectDetection)}`} {selectedPreset.description ||
</div> `${selectedPreset.model} · ${getSubjectDetectionLabel(selectedPreset.subjectDetection)}`}
) : null} </div>
</div> ) : null}
<div className="space-y-2">
<Label
className="text-[11px] uppercase tracking-[0.08em] text-muted-foreground"
htmlFor="enhance-workspace-prompt"
>
增强提示词
</Label>
<Textarea
className={`${SOLID_PANEL_FIELD_CLASS} min-h-[82px] resize-none placeholder:text-muted-foreground/70`}
id="enhance-workspace-prompt"
onChange={(event) =>
setFormState((prev) => ({
...prev,
prompt: event.target.value,
}))
}
placeholder="例如:保持主体不变,提升画质层次、纹理和局部细节,让结果更高级。"
rows={3}
value={formState.prompt}
/>
</div>
<div className="space-y-2">
<div className="text-[11px] uppercase tracking-[0.08em] text-muted-foreground">
基础参数
</div> </div>
<div className="space-y-2">
<Label
className={PANEL_SECTION_TITLE_CLASS}
htmlFor="enhance-workspace-prompt"
>
增强提示词
</Label>
<Textarea
className={`${SOLID_PANEL_FIELD_CLASS} min-h-[92px] resize-none rounded-[22px] placeholder:text-muted-foreground/70`}
id="enhance-workspace-prompt"
onChange={(event) =>
setFormState((prev) => ({
...prev,
prompt: event.target.value,
}))
}
placeholder="例如:保持主体不变,提升画质层次、纹理和局部细节,让结果更高级。"
rows={3}
value={formState.prompt}
/>
</div>
</div>
<div className={cn(PANEL_SHELL_CLASS, "space-y-3 px-4 py-4")}>
<div className={PANEL_SECTION_TITLE_CLASS}>基础参数</div>
<div className="grid grid-cols-3 gap-3"> <div className="grid grid-cols-3 gap-3">
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label <Label
className="text-foreground/80 text-xs" className="text-slate-600 text-xs"
htmlFor="enhance-workspace-width" htmlFor="enhance-workspace-width"
> >
宽度 宽度
</Label> </Label>
<Input <Input
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
id="enhance-workspace-width" id="enhance-workspace-width"
max={config.maxOutputEdge} max={config.maxOutputEdge}
min="1" min="1"
@ -649,13 +652,13 @@ export function EnhanceProWorkspace({
</div> </div>
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label <Label
className="text-foreground/80 text-xs" className="text-slate-600 text-xs"
htmlFor="enhance-workspace-height" htmlFor="enhance-workspace-height"
> >
高度 高度
</Label> </Label>
<Input <Input
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
id="enhance-workspace-height" id="enhance-workspace-height"
max={config.maxOutputEdge} max={config.maxOutputEdge}
min="1" min="1"
@ -675,7 +678,7 @@ export function EnhanceProWorkspace({
</div> </div>
{config.allowBatchSize ? ( {config.allowBatchSize ? (
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label className="text-foreground/80 text-xs">候选</Label> <Label className="text-slate-600 text-xs">候选</Label>
<Select <Select
onValueChange={(value) => onValueChange={(value) =>
handleNumericField( handleNumericField(
@ -690,7 +693,7 @@ export function EnhanceProWorkspace({
value={String(formState.batchSize)} value={String(formState.batchSize)}
> >
<SelectTrigger <SelectTrigger
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
> >
<SelectValue /> <SelectValue />
</SelectTrigger> </SelectTrigger>
@ -709,13 +712,13 @@ export function EnhanceProWorkspace({
) : ( ) : (
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label <Label
className="text-foreground/80 text-xs" className="text-slate-600 text-xs"
htmlFor="enhance-workspace-seed" htmlFor="enhance-workspace-seed"
> >
Seed Seed
</Label> </Label>
<Input <Input
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
id="enhance-workspace-seed" id="enhance-workspace-seed"
onChange={(event) => onChange={(event) =>
handleNumericField( handleNumericField(
@ -729,7 +732,7 @@ export function EnhanceProWorkspace({
</div> </div>
)} )}
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label className="text-foreground/80 text-xs">模式</Label> <Label className="text-slate-600 text-xs">模式</Label>
<Select <Select
onValueChange={(value) => onValueChange={(value) =>
setFormState((prev) => ({ setFormState((prev) => ({
@ -739,7 +742,9 @@ export function EnhanceProWorkspace({
} }
value={formState.model} value={formState.model}
> >
<SelectTrigger className={`${SOLID_PANEL_FIELD_CLASS} h-10`}> <SelectTrigger
className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
>
<SelectValue /> <SelectValue />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
@ -751,7 +756,7 @@ export function EnhanceProWorkspace({
</Select> </Select>
</div> </div>
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label className="text-foreground/80 text-xs">格式</Label> <Label className="text-slate-600 text-xs">格式</Label>
<Select <Select
onValueChange={(value) => onValueChange={(value) =>
setFormState((prev) => ({ setFormState((prev) => ({
@ -761,7 +766,9 @@ export function EnhanceProWorkspace({
} }
value={formState.output_format} value={formState.output_format}
> >
<SelectTrigger className={`${SOLID_PANEL_FIELD_CLASS} h-10`}> <SelectTrigger
className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
>
<SelectValue /> <SelectValue />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
@ -772,7 +779,7 @@ export function EnhanceProWorkspace({
</Select> </Select>
</div> </div>
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label className="text-foreground/80 text-xs">区域</Label> <Label className="text-slate-600 text-xs">区域</Label>
<Select <Select
onValueChange={(value) => onValueChange={(value) =>
setFormState((prev) => ({ setFormState((prev) => ({
@ -782,7 +789,9 @@ export function EnhanceProWorkspace({
} }
value={formState.subject_detection} value={formState.subject_detection}
> >
<SelectTrigger className={`${SOLID_PANEL_FIELD_CLASS} h-10`}> <SelectTrigger
className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
>
<SelectValue /> <SelectValue />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
@ -795,13 +804,13 @@ export function EnhanceProWorkspace({
{config.allowBatchSize ? ( {config.allowBatchSize ? (
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label <Label
className="text-foreground/80 text-xs" className="text-slate-600 text-xs"
htmlFor="enhance-workspace-seed" htmlFor="enhance-workspace-seed"
> >
Seed Seed
</Label> </Label>
<Input <Input
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
id="enhance-workspace-seed" id="enhance-workspace-seed"
onChange={(event) => onChange={(event) =>
handleNumericField( handleNumericField(
@ -816,13 +825,13 @@ export function EnhanceProWorkspace({
) : null} ) : null}
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label <Label
className="text-foreground/80 text-xs" className="text-slate-600 text-xs"
htmlFor="enhance-workspace-scale" htmlFor="enhance-workspace-scale"
> >
放大 放大
</Label> </Label>
<Input <Input
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
id="enhance-workspace-scale" id="enhance-workspace-scale"
max="32" max="32"
min="1" min="1"
@ -844,10 +853,8 @@ export function EnhanceProWorkspace({
</div> </div>
</div> </div>
<div className="space-y-2"> <div className={cn(PANEL_SHELL_CLASS, "space-y-3 px-4 py-4")}>
<div className="text-[11px] uppercase tracking-[0.08em] text-muted-foreground"> <div className={PANEL_SECTION_TITLE_CLASS}>增强开关</div>
增强开关
</div>
<div className="grid grid-cols-3 gap-3"> <div className="grid grid-cols-3 gap-3">
<div <div
className={cn( className={cn(
@ -901,165 +908,163 @@ export function EnhanceProWorkspace({
</div> </div>
{config.enableAdvancedControls ? ( {config.enableAdvancedControls ? (
<> <div className={cn(PANEL_SHELL_CLASS, "space-y-3 px-4 py-4")}>
<Separator className="bg-border/60" /> <div className="flex items-center justify-between gap-3">
<div className="space-y-2"> <div className={PANEL_SECTION_TITLE_CLASS}>高级调节</div>
<div className="text-[11px] uppercase tracking-[0.08em] text-muted-foreground"> <div className={PANEL_SECTION_NOTE_CLASS}>细修参数</div>
高级调节 </div>
<div className="grid grid-cols-3 gap-3">
<div className="space-y-1.5">
<Label className="text-slate-600 text-xs">创造力</Label>
<Input
className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
max="6"
min="1"
onChange={(event) =>
handleNumericField(
"creativity",
clampNumber(
Number.parseInt(event.target.value, 10) || 3,
1,
6
)
)
}
type="number"
value={formState.creativity}
/>
</div> </div>
<div className="grid grid-cols-3 gap-3"> <div className="space-y-1.5">
<div className="space-y-1.5"> <Label className="text-slate-600 text-xs">纹理</Label>
<Label className="text-foreground/80 text-xs">创造力</Label> <Input
<Input className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} max="5"
max="6" min="1"
min="1" onChange={(event) =>
onChange={(event) => handleNumericField(
handleNumericField( "texture",
"creativity", clampNumber(
clampNumber( Number.parseInt(event.target.value, 10) || 3,
Number.parseInt(event.target.value, 10) || 3, 1,
1, 5
6
)
) )
} )
type="number" }
value={formState.creativity} type="number"
/> value={formState.texture}
</div> />
<div className="space-y-1.5"> </div>
<Label className="text-foreground/80 text-xs">纹理</Label> <div className="space-y-1.5">
<Input <Label className="text-slate-600 text-xs">细节</Label>
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} <Input
max="5" className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
min="1" max="1"
onChange={(event) => min="0"
handleNumericField( onChange={(event) =>
"texture", handleNumericField(
clampNumber( "detail",
Number.parseInt(event.target.value, 10) || 3, clampNumber(
1, Number.parseFloat(event.target.value) || 0,
5 0,
) 1
) )
} )
type="number" }
value={formState.texture} step="0.1"
/> type="number"
</div> value={formState.detail}
<div className="space-y-1.5"> />
<Label className="text-foreground/80 text-xs">细节</Label> </div>
<Input <div className="space-y-1.5">
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} <Label className="text-slate-600 text-xs">锐化</Label>
max="1" <Input
min="0" className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
onChange={(event) => max="1"
handleNumericField( min="0"
"detail", onChange={(event) =>
clampNumber( handleNumericField(
Number.parseFloat(event.target.value) || 0, "sharpen",
0, clampNumber(
1 Number.parseFloat(event.target.value) || 0,
) 0,
1
) )
} )
step="0.1" }
type="number" step="0.1"
value={formState.detail} type="number"
/> value={formState.sharpen}
</div> />
<div className="space-y-1.5"> </div>
<Label className="text-foreground/80 text-xs">锐化</Label> <div className="space-y-1.5">
<Input <Label className="text-slate-600 text-xs">降噪</Label>
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} <Input
max="1" className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
min="0" max="1"
onChange={(event) => min="0"
handleNumericField( onChange={(event) =>
"sharpen", handleNumericField(
clampNumber( "denoise",
Number.parseFloat(event.target.value) || 0, clampNumber(
0, Number.parseFloat(event.target.value) || 0,
1 0,
) 1
) )
} )
step="0.1" }
type="number" step="0.1"
value={formState.sharpen} type="number"
/> value={formState.denoise}
</div> />
<div className="space-y-1.5"> </div>
<Label className="text-foreground/80 text-xs">降噪</Label> <div className="space-y-1.5">
<Input <Label className="text-slate-600 text-xs">脸部力度</Label>
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} <Input
max="1" className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
min="0" max="1"
onChange={(event) => min="0"
handleNumericField( onChange={(event) =>
"denoise", handleNumericField(
clampNumber( "face_enhancement_strength",
Number.parseFloat(event.target.value) || 0, clampNumber(
0, Number.parseFloat(event.target.value) || 0,
1 0,
) 1
) )
} )
step="0.1" }
type="number" step="0.1"
value={formState.denoise} type="number"
/> value={formState.face_enhancement_strength}
</div> />
<div className="space-y-1.5"> </div>
<Label className="text-foreground/80 text-xs">脸部力度</Label> <div className="space-y-1.5">
<Input <Label className="text-slate-600 text-xs">脸部创意</Label>
className={`${SOLID_PANEL_FIELD_CLASS} h-10`} <Input
max="1" className={`${SOLID_PANEL_FIELD_CLASS} h-11 rounded-[18px]`}
min="0" max="1"
onChange={(event) => min="0"
handleNumericField( onChange={(event) =>
"face_enhancement_strength", handleNumericField(
clampNumber( "face_enhancement_creativity",
Number.parseFloat(event.target.value) || 0, clampNumber(
0, Number.parseFloat(event.target.value) || 0,
1 0,
) 1
) )
} )
step="0.1" }
type="number" step="0.1"
value={formState.face_enhancement_strength} type="number"
/> value={formState.face_enhancement_creativity}
</div> />
<div className="space-y-1.5">
<Label className="text-foreground/80 text-xs">脸部创意</Label>
<Input
className={`${SOLID_PANEL_FIELD_CLASS} h-10`}
max="1"
min="0"
onChange={(event) =>
handleNumericField(
"face_enhancement_creativity",
clampNumber(
Number.parseFloat(event.target.value) || 0,
0,
1
)
)
}
step="0.1"
type="number"
value={formState.face_enhancement_creativity}
/>
</div>
</div> </div>
</div> </div>
</> </div>
) : null} ) : null}
</div> </div>
<div className="border-border/60 border-t bg-background/90 px-4 py-3"> <div className="border-[#e7e1d4] border-t bg-white/72 px-4 py-3 backdrop-blur-xl">
<div className="mb-3 flex items-center justify-between text-muted-foreground text-xs"> <div className="mb-3 flex items-center justify-between text-muted-foreground text-xs">
<span> <span>
{generatedImages.length > 0 {generatedImages.length > 0
@ -1075,7 +1080,7 @@ export function EnhanceProWorkspace({
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Button <Button
className="h-10 flex-1 rounded-2xl bg-primary text-primary-foreground hover:bg-primary/90" className="h-10 flex-1 rounded-2xl bg-[#2563eb] text-white shadow-sm hover:bg-[#1d4ed8] disabled:bg-slate-200 disabled:text-slate-500"
disabled={isSubmitting || !sourceImageUrl} disabled={isSubmitting || !sourceImageUrl}
onClick={handleSubmit} onClick={handleSubmit}
type="button" type="button"
@ -1088,7 +1093,7 @@ export function EnhanceProWorkspace({
开始增强 Pro 开始增强 Pro
</Button> </Button>
<Button <Button
className="h-10 rounded-2xl border-border/60 bg-background px-4 text-foreground hover:bg-muted" className="h-10 rounded-2xl border-[#bfdbfe] bg-[#eff6ff] px-4 text-[#1d4ed8] shadow-sm hover:bg-[#dbeafe] hover:text-[#1e40af] disabled:border-slate-200 disabled:bg-slate-100 disabled:text-slate-400"
disabled={!selectedGeneratedImage} disabled={!selectedGeneratedImage}
onClick={handleApply} onClick={handleApply}
type="button" type="button"

View File

@ -2959,7 +2959,7 @@ export function RealtimeCanvasDialog({
<DialogDescription>左侧绘制草图,右侧实时预览。</DialogDescription> <DialogDescription>左侧绘制草图,右侧实时预览。</DialogDescription>
</DialogHeader> </DialogHeader>
)} )}
<div className="pointer-events-none absolute top-6 left-6 z-50 flex flex-col gap-3"> <div className="pointer-events-none absolute top-6 left-6 right-24 z-50 flex flex-wrap items-start gap-3">
<button <button
className="pointer-events-auto flex items-center gap-3 rounded-full border border-border/60 bg-background/95 px-4 py-2 text-foreground shadow-xl backdrop-blur-sm transition hover:bg-background" className="pointer-events-auto flex items-center gap-3 rounded-full border border-border/60 bg-background/95 px-4 py-2 text-foreground shadow-xl backdrop-blur-sm transition hover:bg-background"
onClick={handleGoHome} onClick={handleGoHome}
@ -2986,7 +2986,7 @@ export function RealtimeCanvasDialog({
</span> </span>
</button> </button>
<div className="pointer-events-auto inline-flex w-fit items-center gap-1 rounded-full border border-border/60 bg-background/95 p-1.5 shadow-xl backdrop-blur-sm"> <div className="pointer-events-auto inline-flex w-fit max-w-full items-center gap-1 rounded-full border border-border/60 bg-background/95 p-1.5 shadow-xl backdrop-blur-sm">
<button <button
className={cn( className={cn(
"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm transition", "inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm transition",