From 46538f5010679ac5cdc5c5e815100658979ebd41 Mon Sep 17 00:00:00 2001 From: yibo Date: Fri, 30 Oct 2026 22:58:35 +0800 Subject: [PATCH] h3-console: 修复列表翻页无效(前端传 page,服务端只认 offset) --- h3-console/frontend/src/api.js | 3 ++- h3-console/static/index.html | 42 +++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/h3-console/frontend/src/api.js b/h3-console/frontend/src/api.js index a3bca81..1d75877 100644 --- a/h3-console/frontend/src/api.js +++ b/h3-console/frontend/src/api.js @@ -29,7 +29,8 @@ export async function fetchJobs({ page = 1, limit = 20, q = '', status = '', kin params.set('trash', 'true'); params.set('limit', '50'); } else { - params.set('page', String(page)); + // 服务端分页参数是 offset 不是 page,传 page 会被忽略(永远返回第一页) + params.set('offset', String((page - 1) * limit)); params.set('limit', String(limit)); if (q) params.set('q', q); if (status) params.set('status', status); diff --git a/h3-console/static/index.html b/h3-console/static/index.html index c4522a0..71ba482 100644 --- a/h3-console/static/index.html +++ b/h3-console/static/index.html @@ -7,7 +7,7 @@ - +大约需要耗时 15-20 秒,重置完成前无法提交新任务。`,isDanger:!0,onConfirm:async()=>{Le(w=>({...w,isOpen:!1}));try{await Ay(),q("已触发 GPU 重启,正在回收显存…","info"),M&&M()}catch(w){q("重置失败: "+w.message,"error")}}})},de=Math.max(1,Math.ceil(D/20));return c.jsxs("aside",{className:"w-full md:w-[390px] lg:w-[420px] shrink-0 border-r border-slate-200 bg-white flex flex-col h-full select-none shadow-xs",children:[c.jsxs("div",{className:"p-4 border-b border-slate-200 flex flex-col gap-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 shadow-xs shadow-emerald-500/50"}),c.jsx("h1",{className:"text-sm font-bold tracking-wide text-slate-800",children:"H3 Console"})]}),c.jsx("span",{className:"text-[11px] font-mono text-slate-400",children:"AI Video Studio"})]}),c.jsxs("button",{onClick:O,className:`w-full py-2.5 px-4 rounded-xl text-xs font-semibold flex items-center justify-center gap-2 transition-all cursor-pointer shadow-xs ${!se&&!o?"bg-emerald-600 hover:bg-emerald-700 text-white shadow-emerald-600/30":"bg-slate-50 hover:bg-slate-100 text-slate-700 border border-slate-200"}`,children:[c.jsx(sy,{className:"w-4 h-4 text-emerald-500"}),c.jsx("span",{children:"新建生成任务"})]})]}),se?c.jsxs("div",{className:"p-3 border-b border-slate-200 flex items-center justify-between bg-slate-100/70",children:[c.jsxs("span",{className:"text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[c.jsx(Gf,{className:"w-4 h-4 text-rose-500"}),c.jsx("span",{children:"回收站视图"})]}),c.jsx("button",{onClick:()=>Q(!1),className:"text-xs text-emerald-600 hover:underline cursor-pointer font-medium",children:"← 返回列表"})]}):c.jsxs("div",{className:"p-3 border-b border-slate-200 flex flex-col gap-2 bg-slate-50/60",children:[c.jsxs("div",{className:"relative",children:[c.jsx(fy,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-slate-400"}),c.jsx("input",{type:"text",placeholder:"搜索 Prompt 或任务 ID…",value:le,onChange:w=>ie(w.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-white border border-slate-200 rounded-xl text-xs text-slate-800 placeholder-slate-400 outline-none focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500/20 transition-all"})]}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("select",{value:F,onChange:w=>De(w.target.value),className:"flex-1 bg-white border border-slate-200 rounded-xl px-2 py-1.5 text-xs text-slate-700 outline-none focus:border-emerald-500 cursor-pointer",children:[c.jsx("option",{value:"",children:"全部状态"}),c.jsx("option",{value:"queued",children:"排队中"}),c.jsx("option",{value:"running",children:"运行中"}),c.jsx("option",{value:"done",children:"已完成"}),c.jsx("option",{value:"failed",children:"失败"}),c.jsx("option",{value:"cancelled",children:"已取消"})]}),c.jsxs("select",{value:ve,onChange:w=>Re(w.target.value),className:"flex-1 bg-white border border-slate-200 rounded-xl px-2 py-1.5 text-xs text-slate-700 outline-none focus:border-emerald-500 cursor-pointer",children:[c.jsx("option",{value:"",children:"全部类型"}),c.jsx("option",{value:"text",children:"文生视频"}),c.jsx("option",{value:"fl2va",children:"首尾帧"}),c.jsx("option",{value:"ref2va",children:"多参考图"})]}),c.jsx("button",{onClick:()=>R(Z==="desc"?"asc":"desc"),className:"p-1.5 bg-white hover:bg-slate-100 border border-slate-200 rounded-xl text-slate-600 transition-colors cursor-pointer shrink-0",title:"切换排序",children:c.jsx(Qx,{className:"w-3.5 h-3.5"})})]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-3 flex flex-col gap-2.5 bg-slate-50/40",children:se?P.length>0?P.map(w=>c.jsxs("div",{className:"p-3 bg-white border border-slate-200 rounded-xl flex items-center justify-between text-xs shadow-xs",children:[c.jsxs("div",{className:"min-w-0 flex-1 pr-2",children:[c.jsxs("span",{className:"font-mono text-slate-500 font-semibold",children:["#",w.id.substring(0,8)]}),c.jsx("p",{className:"text-slate-700 truncate mt-0.5",children:w.req?.prompt||"(无 prompt)"})]}),c.jsx("button",{onClick:()=>K(w.id),className:"px-3 py-1 bg-emerald-50 hover:bg-emerald-100 text-emerald-700 border border-emerald-200 rounded-lg shrink-0 cursor-pointer transition-colors font-medium",children:"恢复"})]},w.id)):c.jsx("div",{className:"py-12 text-center text-xs text-slate-400",children:"回收站是空的"}):k.length>0?k.map(w=>c.jsx(Ny,{job:w,isSelected:o===w.id,onSelect:b,onRerun:r,onPrioritize:je,onDelete:A},w.id)):c.jsx("div",{className:"py-12 text-center text-xs text-slate-400",children:qe?"正在加载任务…":"暂无符合筛选条件的任务"})}),!se&&D>0&&c.jsxs("div",{className:"p-3 border-t border-slate-200 bg-white flex items-center justify-between text-xs text-slate-600",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("button",{disabled:j<=1,onClick:()=>{const w=j-1;X(w),Ye(w)},className:"p-1 hover:bg-slate-100 disabled:opacity-30 rounded-lg cursor-pointer transition-colors",children:c.jsx(Lx,{className:"w-4 h-4"})}),c.jsxs("span",{className:"font-medium",children:[j," / ",de]}),c.jsx("button",{disabled:j>=de,onClick:()=>{const w=j+1;X(w),Ye(w)},className:"p-1 hover:bg-slate-100 disabled:opacity-30 rounded-lg cursor-pointer transition-colors",children:c.jsx(Zx,{className:"w-4 h-4"})})]}),c.jsxs("span",{className:"text-[11px] text-slate-400",children:["共 ",D," 条记录"]})]}),c.jsxs("div",{className:"p-3 border-t border-slate-200 bg-slate-50/80 flex flex-col gap-2",children:[T&&c.jsxs("div",{className:"flex items-center justify-between text-[11px] text-slate-600 bg-white px-2.5 py-1.5 rounded-lg border border-slate-200 font-mono shadow-xs",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(ry,{className:"w-3.5 h-3.5 text-emerald-600"}),c.jsxs("span",{className:"font-semibold",children:["GPU: ",T.ready,"/",T.total," 就绪"]})]}),c.jsxs("span",{className:"text-slate-400",children:["fl2va: ",T.partitions?.fl2va||0," | ref2va: ",T.partitions?.ref2va||0]})]}),c.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-slate-500",children:[c.jsx("a",{href:`${ul()}/docs/api.md`,target:"_blank",rel:"noreferrer",className:"hover:text-slate-800 underline-offset-2 hover:underline",children:"API 文档"}),c.jsx("a",{href:`${ul()}/skill.md`,target:"_blank",rel:"noreferrer",className:"hover:text-slate-800 underline-offset-2 hover:underline",children:"skill.md"})]}),c.jsxs("div",{className:"flex items-center justify-between pt-1 text-[11px]",children:[c.jsxs("button",{onClick:()=>Q(!se),className:"flex items-center gap-1 text-slate-500 hover:text-slate-800 transition-colors cursor-pointer",children:[c.jsx(Gf,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:"回收站"})]}),c.jsxs("button",{onClick:$,className:"flex items-center gap-1 text-slate-500 hover:text-slate-800 transition-colors cursor-pointer font-mono",title:"点击配置访问令牌",children:[c.jsx(ny,{className:"w-3.5 h-3.5 text-emerald-600"}),c.jsx("span",{children:Ki()?"Token:已配":"Token:未设"})]}),c.jsxs("button",{onClick:J,className:"flex items-center gap-1 text-amber-600 hover:text-amber-700 transition-colors cursor-pointer font-medium",title:"硬重启服务打断任务并回收显存",children:[c.jsx(nh,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:"重置显存"})]})]})]}),c.jsx(ph,{isOpen:Ne.isOpen,title:Ne.title,content:Ne.content,isDanger:Ne.isDanger,onConfirm:Ne.onConfirm,onCancel:()=>Le(w=>({...w,isOpen:!1}))})]})}function ou({label:o,accept:b="image/*",type:O="image",multiple:r=!1,maxCount:T=99,value:M,onChange:$,hint:q}){const[k,I]=H.useState(""),[D,S]=H.useState(!1),[j,X]=H.useState(!1),le=H.useRef(null),ie=r?Array.isArray(M)?M:[]:M?[M]:[],F=async Z=>{if(!(!Z||Z.length===0)){S(!0);try{const R=[];for(const se of Array.from(Z)){if(ie.length+R.length>=T)break;const Q=await Ty(se);Q.url&&R.push(Q.url)}r?$([...ie,...R].slice(0,T)):R.length>0&&$(R[0])}catch(R){alert("上传失败: "+R.message)}finally{S(!1),le.current&&(le.current.value="")}}},De=Z=>{if(Z.key==="Enter"){Z.preventDefault();const R=k.trim();if(!R)return;if(r){if(ie.length>=T){alert(`最多只允许添加 ${T} 个`);return}$([...ie,R])}else $(R);I("")}},ve=Z=>{if(r){const R=ie.filter((se,Q)=>Q!==Z);$(R)}else $(null)},Re=Z=>{const R=Z.clipboardData?.files;R&&R.length>0&&(Z.preventDefault(),F(R))};return c.jsxs("div",{className:"flex flex-col gap-2.5",onPaste:Re,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("label",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-300",children:[o," ",T<99&&c.jsxs("span",{className:"text-zinc-500 font-normal",children:["(",ie.length,"/",T,")"]})]}),q&&c.jsx("span",{className:"text-xs text-zinc-500",children:q})]}),(ie.length{Z.preventDefault(),X(!0)},onDragLeave:()=>X(!1),onDrop:Z=>{Z.preventDefault(),X(!1),F(Z.dataTransfer.files)},className:`relative border-2 border-dashed rounded-xl p-3.5 transition-all flex flex-col sm:flex-row items-center gap-3 bg-zinc-900/60 ${j?"border-emerald-500 bg-emerald-950/20 shadow-inner":"border-zinc-800 hover:border-zinc-700"}`,children:[c.jsx("input",{type:"file",ref:le,accept:b,multiple:r,className:"hidden",onChange:Z=>F(Z.target.files)}),c.jsxs("button",{type:"button",disabled:D,onClick:()=>le.current?.click(),className:"w-full sm:w-auto px-4 py-2 bg-zinc-800 hover:bg-zinc-700/80 text-zinc-200 text-xs font-medium rounded-lg flex items-center justify-center gap-2 border border-zinc-700/60 transition-colors shrink-0 cursor-pointer shadow-sm disabled:opacity-50",children:[c.jsx(xy,{className:"w-4 h-4 text-emerald-400"}),c.jsx("span",{children:D?"正在上传…":"选择或拖拽文件"})]}),c.jsxs("div",{className:"relative flex-1 w-full",children:[c.jsx(iy,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-zinc-500"}),c.jsx("input",{type:"url",placeholder:"或粘贴 URL,回车添加(支持 Ctrl+V 粘贴截图)",value:k,onChange:Z=>I(Z.target.value),onKeyDown:De,className:"w-full pl-9 pr-3 py-1.5 bg-zinc-950/60 border border-zinc-800 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/40 rounded-lg text-xs text-zinc-200 placeholder-zinc-500 outline-none transition-all"})]})]}),ie.length>0&&c.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 mt-1",children:ie.map((Z,R)=>{const se=py(Z);return c.jsxs("div",{className:"group relative bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden flex flex-col shadow-md hover:border-zinc-700 transition-all",children:[c.jsxs("div",{className:"relative aspect-video bg-black flex items-center justify-center overflow-hidden",children:[O==="image"&&c.jsx("img",{src:ru(Z),alt:se,className:"w-full h-full object-cover transition-transform group-hover:scale-105 duration-300"}),O==="video"&&c.jsx("video",{src:Zi(Z),controls:!0,className:"w-full h-full object-contain bg-black"}),O==="audio"&&c.jsxs("div",{className:"p-2 w-full flex flex-col items-center justify-center gap-1 text-zinc-400",children:[c.jsx(ey,{className:"w-6 h-6 text-emerald-400 mb-1"}),c.jsx("audio",{src:Zi(Z),controls:!0,className:"w-full h-8"})]}),c.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 z-10",children:[c.jsx("a",{href:Z,target:"_blank",rel:"noreferrer",className:"p-1 bg-black/60 hover:bg-black/90 text-zinc-300 hover:text-white rounded-md backdrop-blur-md transition-colors",title:"打开原图",children:c.jsx(ly,{className:"w-3.5 h-3.5"})}),c.jsx("button",{type:"button",onClick:()=>ve(R),className:"p-1 bg-rose-950/80 hover:bg-rose-600 text-rose-300 hover:text-white rounded-md backdrop-blur-md transition-colors cursor-pointer",title:"删除",children:c.jsx(Vf,{className:"w-3.5 h-3.5"})})]})]}),c.jsx("div",{className:"px-2.5 py-1.5 bg-zinc-900/90 text-[11px] text-zinc-400 truncate border-t border-zinc-800/80 font-mono",title:se,children:se||"媒体文件"})]},R)})})]})}const Xi=[{value:"1344x768",width:1344,height:768,label:"1344×768 (横屏 · 官方默认)",maxFrames:412,isLandscape:!0,aspect:"16:9"},{value:"768x1344",width:768,height:1344,label:"768×1344 (竖屏 · 官方默认)",maxFrames:412,isLandscape:!1,aspect:"9:16"},{value:"832x480",width:832,height:480,label:"832×480 (横屏 · 标准)",maxFrames:1125,isLandscape:!0,aspect:"16:9"},{value:"480x832",width:480,height:832,label:"480×832 (竖屏 · 推荐短剧)",maxFrames:1125,isLandscape:!1,aspect:"9:16"},{value:"1024x576",width:1024,height:576,label:"1024×576 (横屏 · 高清)",maxFrames:743,isLandscape:!0,aspect:"16:9"},{value:"576x1024",width:576,height:1024,label:"576×1024 (竖屏 · 高清)",maxFrames:743,isLandscape:!1,aspect:"9:16"},{value:"448x256",width:448,height:256,label:"448×256 (横屏 · 超长)",maxFrames:1200,isLandscape:!0,aspect:"16:9"},{value:"256x448",width:256,height:448,label:"256×448 (竖屏 · 超长)",maxFrames:1200,isLandscape:!1,aspect:"9:16"}],jm="480x832",qf="243",Vi=[{value:"124",frames:124,label:"5秒 (124帧)"},{value:"243",frames:243,label:"10秒 (243帧 · 默认)"},{value:"362",frames:362,label:"15秒 (362帧)"},{value:"412",frames:412,label:"17秒 (412帧 · 1344上限)"},{value:"600",frames:600,label:"25秒 (600帧)"},{value:"743",frames:743,label:"31秒 (743帧 · 1024上限)"},{value:"900",frames:900,label:"37.5秒 (900帧)"},{value:"1125",frames:1125,label:"47秒 (1125帧 · 832上限)"},{value:"1200",frames:1200,label:"50秒 (1200帧 · 256画质上限)"}],Uy={true:[{value:"4",label:"4 步 (极速推荐 · LoRA 蒸馏)"},{value:"8",label:"8 步 (上限)"}],false:[{value:"20",label:"20 步 (平衡标准)"},{value:"50",label:"50 步 (全质量 · 约9.6倍耗时)"}]},Ry=[{value:"0",label:"0 (默认固定)"},{value:"42",label:"42"},{value:"123",label:"123"},{value:"2024",label:"2024"},{value:"random",label:"🎲 随机 Seed"}];function Hy({initialValues:o,onCreated:b}){const{addToast:O}=Ji(),[r,T]=H.useState("text"),[M,$]=H.useState(""),[q,k]=H.useState(jm),[I,D]=H.useState(qf),[S,j]=H.useState(!1),[X,le]=H.useState("20"),[ie,F]=H.useState("0"),[De,ve]=H.useState(""),[Re,Z]=H.useState(""),[R,se]=H.useState(!1),[Q,P]=H.useState(!1),[Ve,qe]=H.useState(""),[Ae,Ne]=H.useState(null),[Le,Ye]=H.useState(null),[je,A]=H.useState([]),[K,J]=H.useState([]),[de,w]=H.useState([]);H.useEffect(()=>{if(!o)return;const N=o;N.first_frame_url||N.last_frame_url?(T("fl2va"),Ne(N.first_frame_url||null),Ye(N.last_frame_url||null)):(N.reference_image_urls||[]).length||(N.reference_video_urls||[]).length||(N.reference_audio_urls||[]).length?(T("ref2va"),A(N.reference_image_urls||[]),J(N.reference_video_urls||[]),w(N.reference_audio_urls||[])):T("text"),$(N.prompt||"");const fe=Xi.find(B=>B.width===N.width&&B.height===N.height);fe&&k(fe.value);const ae=Vi.find(B=>B.frames===N.frames);ae&&D(ae.value);const ce=N.turbo!==!1;j(ce),N.steps!=null&&le(String(N.steps)),N.seed!=null&&F(String(N.seed)),N.cfg_scale!=null&&ve(String(N.cfg_scale)),N.negative_prompt&&Z(N.negative_prompt)},[o]);const G=Xi.find(N=>N.value===q)||Xi[0],Ee=Vi.filter(N=>N.frames<=G.maxFrames),il=Vi.filter(N=>N.frames>G.maxFrames);H.useEffect(()=>{Ee.some(N=>N.value===I)||D(Ee[0]?.value||qf)},[q]);const m=Uy[S];H.useEffect(()=>{m.some(N=>N.value===X)||le(m[0].value)},[S]);const E=()=>{confirm("确定清空当前表单所有内容?")&&($(""),k(jm),D(qf),j(!1),le("20"),F("0"),ve(""),Z(""),Ne(null),Ye(null),A([]),J([]),w([]),qe(""),O("已恢复默认配置","info"))},V=async N=>{if(N.preventDefault(),qe(""),!M.trim()){qe("请填写 Prompt 提示词");return}const fe=Vi.find(ce=>ce.value===I),ae={prompt:M.trim(),width:G.width,height:G.height,frames:fe?fe.frames:243,turbo:S,steps:parseInt(X,10),seed:ie==="random"?Math.floor(Math.random()*2**31):parseInt(ie,10)};if(De.trim()!==""&&(ae.cfg_scale=parseFloat(De)),Re.trim()!==""&&(ae.negative_prompt=Re.trim()),r==="fl2va"){if(!Ae){qe("首尾帧模式下必须上传【首帧图】");return}ae.first_frame_url=Ae,Le&&(ae.last_frame_url=Le)}else if(r==="ref2va"){if(je.length===0&&K.length===0&&de.length===0){qe("参考模式下至少需要上传 1 张参考图、1 段参考视频或 1 个音频");return}ae.reference_image_urls=je,ae.reference_video_urls=K,ae.reference_audio_urls=de}P(!0);try{const ce=await _y(ae);O(`任务提交成功 (#${ce.id.substring(0,8)})`,"success"),b(ce.id)}catch(ce){qe("提交失败: "+ce.message),O("提交失败: "+ce.message,"error")}finally{P(!1)}};return c.jsxs("div",{className:"max-w-4xl mx-auto py-6 px-4 sm:px-8",children:[c.jsx("div",{className:"flex items-center gap-1.5 p-1.5 bg-slate-100 dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-2xl w-fit shadow-xs mb-6",children:[{key:"text",label:"文生视频",desc:"Text to Video"},{key:"fl2va",label:"首尾帧生视频",desc:"FL2VA"},{key:"ref2va",label:"多参考图生视频",desc:"Ref2VA"}].map(N=>c.jsxs("button",{onClick:()=>T(N.key),className:`flex flex-col items-start px-4 py-2 rounded-xl text-xs transition-all cursor-pointer ${r===N.key?"bg-emerald-600 text-white font-semibold shadow-sm":"text-slate-600 hover:text-slate-900 hover:bg-white/80 dark:text-zinc-400 dark:hover:text-zinc-200 dark:hover:bg-zinc-800/60"}`,children:[c.jsx("span",{children:N.label}),c.jsx("span",{className:`text-[10px] ${r===N.key?"text-emerald-100":"text-slate-400 dark:text-zinc-500"}`,children:N.desc})]},N.key))}),c.jsxs("form",{onSubmit:V,className:"flex flex-col gap-6",children:[c.jsxs("div",{className:"bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-2xl p-5 shadow-xs",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[c.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-zinc-300 flex items-center gap-2",children:[c.jsx(hy,{className:"w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400"}),c.jsx("span",{children:"Prompt 提示词"})]}),c.jsxs("span",{className:"text-xs text-slate-400 dark:text-zinc-500",children:[M.length," 字"]})]}),c.jsx("textarea",{rows:5,value:M,onChange:N=>$(N.target.value),placeholder:r==="fl2va"?"描述首帧到尾帧之间的动态演变过程,例如:女子缓缓端起茶杯,轻轻抿了一口,微风拂动发丝...":"描述您想要生成的电影级视频画面、光影运镜与角色动作...",className:"w-full bg-slate-50 dark:bg-zinc-950/70 border border-slate-200 dark:border-zinc-800 focus:bg-white focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500/20 rounded-xl p-3.5 text-sm text-slate-900 dark:text-zinc-100 placeholder-slate-400 dark:placeholder-zinc-500 outline-none transition-all resize-y min-h-[120px] leading-relaxed"})]}),r==="fl2va"&&c.jsxs("div",{className:"bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-2xl p-5 shadow-xs flex flex-col gap-5",children:[c.jsx(ou,{label:"首帧图片 (必填)",accept:"image/*",type:"image",value:Ae,onChange:Ne,hint:"视频起始画面"}),c.jsx("div",{className:"border-t border-slate-100 dark:border-zinc-800/80 pt-4",children:c.jsx(ou,{label:"尾帧图片 (可选)",accept:"image/*",type:"image",value:Le,onChange:Ye,hint:"视频结束画面,不填则自由发散"})})]}),r==="ref2va"&&c.jsxs("div",{className:"bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-2xl p-5 shadow-xs flex flex-col gap-5",children:[c.jsx(ou,{label:"参考图片 (可多选)",accept:"image/*",type:"image",multiple:!0,value:je,onChange:A,hint:"角色/场景设定图,无数量限制"}),c.jsx("div",{className:"border-t border-slate-100 dark:border-zinc-800/80 pt-4",children:c.jsx(ou,{label:"参考视频 (可选 · 最多3段)",accept:"video/*",type:"video",multiple:!0,maxCount:3,value:K,onChange:J,hint:"2-15秒动态参考,自动保留音轨"})}),c.jsx("div",{className:"border-t border-slate-100 dark:border-zinc-800/80 pt-4",children:c.jsx(ou,{label:"独立音频参考 (可选 · 最多3首)",accept:"audio/*",type:"audio",multiple:!0,maxCount:3,value:de,onChange:w,hint:"背景音乐或台词声音参考"})})]}),c.jsxs("div",{className:"bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-2xl p-5 shadow-xs flex flex-col gap-5",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-zinc-300",children:[c.jsx(my,{className:"w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400"}),c.jsx("span",{children:"生成参数与画质规格"})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400 font-medium",children:"分辨率与画幅"}),c.jsx("select",{value:q,onChange:N=>k(N.target.value),className:"bg-slate-50 dark:bg-zinc-950/80 border border-slate-200 dark:border-zinc-800 rounded-xl px-3 py-2.5 text-xs text-slate-800 dark:text-zinc-200 outline-none focus:border-emerald-500 cursor-pointer",children:Xi.map(N=>c.jsx("option",{value:N.value,children:N.label},N.value))})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400 font-medium",children:"生成时长 (帧数)"}),c.jsx("select",{value:I,onChange:N=>D(N.target.value),className:"bg-slate-50 dark:bg-zinc-950/80 border border-slate-200 dark:border-zinc-800 rounded-xl px-3 py-2.5 text-xs text-slate-800 dark:text-zinc-200 outline-none focus:border-emerald-500 cursor-pointer",children:Ee.map(N=>c.jsx("option",{value:N.value,children:N.label},N.value))})]})]}),il.length>0&&c.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-amber-50 border border-amber-200 dark:bg-amber-950/30 dark:border-amber-600/30 rounded-xl text-xs text-amber-800 dark:text-amber-300",children:[c.jsx(Yf,{className:"w-4 h-4 shrink-0 text-amber-600 dark:text-amber-400"}),c.jsxs("span",{children:[G.label," 实测上限 ",G.maxFrames," 帧,已自动过滤超出显存承受的超长档位。"]})]}),c.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-3 border-t border-slate-100 dark:border-zinc-800/80 items-center",children:[c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400 font-medium",children:"Turbo 加速 LoRA"}),c.jsxs("div",{className:"flex p-1 bg-slate-100 dark:bg-zinc-950/80 border border-slate-200 dark:border-zinc-800 rounded-xl",children:[c.jsx("button",{type:"button",onClick:()=>j(!1),className:`flex-1 py-1.5 text-xs font-medium rounded-lg transition-colors cursor-pointer ${S?"text-slate-500 dark:text-zinc-400 hover:text-slate-800":"bg-white dark:bg-zinc-800 text-slate-800 dark:text-white shadow-xs"}`,children:"关 (稳健多步)"}),c.jsx("button",{type:"button",onClick:()=>j(!0),className:`flex-1 py-1.5 text-xs font-medium rounded-lg transition-colors cursor-pointer ${S?"bg-emerald-600 text-white shadow-xs":"text-slate-500 dark:text-zinc-400 hover:text-slate-800"}`,children:"开 (4步极速)"})]})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400 font-medium",children:"采样步数 (Steps)"}),c.jsx("select",{value:X,onChange:N=>le(N.target.value),className:"bg-slate-50 dark:bg-zinc-950/80 border border-slate-200 dark:border-zinc-800 rounded-xl px-3 py-2 text-xs text-slate-800 dark:text-zinc-200 outline-none focus:border-emerald-500 cursor-pointer",children:m.map(N=>c.jsx("option",{value:N.value,children:N.label},N.value))})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400 font-medium",children:"随机种子 (Seed)"}),c.jsx("select",{value:ie,onChange:N=>F(N.target.value),className:"bg-slate-50 dark:bg-zinc-950/80 border border-slate-200 dark:border-zinc-800 rounded-xl px-3 py-2 text-xs text-slate-800 dark:text-zinc-200 outline-none focus:border-emerald-500 cursor-pointer",children:Ry.map(N=>c.jsx("option",{value:N.value,children:N.label},N.value))})]})]}),c.jsxs("div",{className:"pt-2",children:[c.jsxs("button",{type:"button",onClick:()=>se(!R),className:"flex items-center gap-1.5 text-xs font-medium text-slate-600 dark:text-zinc-400 hover:text-slate-900 dark:hover:text-zinc-200 transition-colors cursor-pointer",children:[c.jsx("span",{children:"高级调参 (CFG / 负面提示词)"}),R?c.jsx(Kx,{className:"w-3.5 h-3.5"}):c.jsx(Vx,{className:"w-3.5 h-3.5"})]}),R&&c.jsxs("div",{className:"mt-3 p-4 bg-slate-50 dark:bg-zinc-950/50 border border-slate-200 dark:border-zinc-800/80 rounded-xl flex flex-col gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400",children:"CFG Scale (留空默认 1.0)"}),c.jsx("input",{type:"number",step:"0.1",min:"0",placeholder:"留空 = 1.0 (蒸馏 LoRA 调太高易出伪影)",value:De,onChange:N=>ve(N.target.value),className:"bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-xl px-3 py-2 text-xs text-slate-800 dark:text-zinc-200 outline-none focus:border-emerald-500"})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-xs text-slate-600 dark:text-zinc-400",children:"负面提示词 Negative Prompt"}),c.jsx("textarea",{rows:2,placeholder:"例如:模糊,低画质,肢体变形,拖影,五官扭曲",value:Re,onChange:N=>Z(N.target.value),className:"bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-xl p-2.5 text-xs text-slate-800 dark:text-zinc-200 outline-none focus:border-emerald-500 resize-none"})]})]})]})]}),Ve&&c.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-200 dark:bg-rose-950/60 dark:border-rose-500/40 rounded-xl text-xs text-rose-700 dark:text-rose-300 flex items-center gap-2",children:[c.jsx(Yf,{className:"w-4 h-4 shrink-0 text-rose-500"}),c.jsx("span",{children:Ve})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 pb-8",children:[c.jsx("button",{type:"button",onClick:E,className:"px-5 py-2.5 bg-slate-100 hover:bg-slate-200 dark:bg-zinc-800 dark:hover:bg-zinc-700 text-slate-700 dark:text-zinc-300 text-xs font-medium rounded-xl transition-colors cursor-pointer border border-slate-200 dark:border-zinc-700",children:"清空表单"}),c.jsxs("button",{type:"submit",disabled:Q,className:"px-7 py-2.5 bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-semibold rounded-xl transition-all shadow-md shadow-emerald-600/30 flex items-center gap-2 cursor-pointer disabled:opacity-50",children:[Q?c.jsx(nh,{className:"w-4 h-4 animate-spin"}):c.jsx(oy,{className:"w-4 h-4"}),c.jsx("span",{children:Q?"正在提交…":"立即生成视频"})]})]})]})]})}function qy({taskId:o,onBack:b,onRerun:O}){const{addToast:r}=Ji(),[T,M]=H.useState(null),[$,q]=H.useState(!0),[k,I]=H.useState(!1),[D,S]=H.useState(null),[j,X]=H.useState(!1),[le,ie]=H.useState(!1),[F,De]=H.useState(!1),[ve,Re]=H.useState({isOpen:!1,title:"",content:"",isDanger:!1,onConfirm:null}),Z=async()=>{try{const G=await zy(o);M(G)}catch(G){console.error(G)}finally{q(!1)}};if(H.useEffect(()=>{Z();const G=setInterval(()=>{T&&(T.status==="queued"||T.status==="running")&&Z()},2500);return()=>clearInterval(G)},[o,T?.status]),$&&!T)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-slate-500 text-sm",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"w-5 h-5 border-2 border-emerald-500 border-t-transparent rounded-full animate-spin"}),c.jsx("span",{children:"正在加载任务详情…"})]})});if(!T)return c.jsxs("div",{className:"p-8 text-center flex flex-col items-center gap-4 text-slate-500",children:[c.jsx("p",{children:"未找到该任务或已被彻底删除"}),c.jsx("button",{onClick:b,className:"px-4 py-2 bg-slate-100 hover:bg-slate-200 text-xs rounded-xl text-slate-700 cursor-pointer font-medium",children:"返回创建视图"})]});const R=T.req||{},se=T.status==="done",Q=T.status==="running",P=T.status==="queued",Ve=T.status==="failed",qe=T.status==="cancelled",Ae=T.step||0,Ne=T.total_steps||R.steps||20,Le=Ne>0?Math.min(100,Math.max(Ae>0?5:2,Math.round(Ae/Ne*100))):0,Ye=T.elapsed_seconds||0;let je=null;if(Ae>0&&Ne>Ae){const G=Ye/Ae,Ee=Math.round(G*(Ne-Ae));je=Ee>60?`约 ${Math.round(Ee/60)} 分钟`:`约 ${Ee} 秒`}const A=se?yh(`${ul()}/v1/videos/${T.id}/file`):null,K=()=>{R.prompt&&(navigator.clipboard.writeText(R.prompt),I(!0),r("已复制 Prompt 提示词到剪贴板","success"),setTimeout(()=>I(!1),2e3))},J=async()=>{try{const G=await gh(T.id);r(`已成功插队至第 ${G.queue_position} 位`,"success"),Z()}catch(G){r("插队失败: "+G.message,"error")}},de=G=>{Re({isOpen:!0,title:G?"停止正在运行的任务":"取消排队任务",content:G?`确定停止当前正在运行的任务? +这会硬重启后台 Raylight 服务以释放 GPU 显存(约耗时 15-20 秒),重启完成前将暂时无法提交新任务。`:"确定取消这条排队中的任务?",isDanger:G,onConfirm:async()=>{Re(Ee=>({...Ee,isOpen:!1}));try{await Oy(T.id),r(G?"已发出停止与 GPU 重置指令":"已取消任务","info"),Z()}catch(Ee){r("操作失败: "+Ee.message,"error")}}})},w=async()=>{if(!le&&!D){X(!0);try{const G=await Dy(T.id);S(G)}catch(G){r("获取 ComfyUI History 失败: "+G.message,"error")}finally{X(!1)}}ie(!le)};return c.jsxs("div",{className:"max-w-5xl mx-auto py-6 px-4 sm:px-8 flex flex-col gap-6",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 pb-4 border-b border-slate-200",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{onClick:b,className:"p-2 hover:bg-slate-100 rounded-xl text-slate-500 hover:text-slate-800 transition-colors cursor-pointer",title:"返回新建",children:c.jsx(Gx,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsxs("h2",{className:"text-base font-mono font-bold text-slate-800",children:["#",T.id]}),se&&c.jsx("span",{className:"px-2.5 py-0.5 text-xs font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200 rounded-full",children:"已完成"}),Q&&c.jsxs("span",{className:"px-2.5 py-0.5 text-xs font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200 rounded-full flex items-center gap-1.5 animate-pulse",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"正在采样 · ",Le,"%"]}),P&&c.jsxs("span",{className:"px-2.5 py-0.5 text-xs font-semibold bg-slate-100 text-slate-700 border border-slate-200 rounded-full",children:["排队中 ",T.queue_position?`(第 ${T.queue_position} 位)`:""]}),Ve&&c.jsx("span",{className:"px-2.5 py-0.5 text-xs font-semibold bg-rose-50 text-rose-700 border border-rose-200 rounded-full",children:"执行失败"}),qe&&c.jsx("span",{className:"px-2.5 py-0.5 text-xs font-semibold bg-slate-100 text-slate-500 border border-slate-200 rounded-full",children:"已取消"})]}),c.jsxs("div",{className:"text-xs text-slate-400 mt-0.5",children:["创建于 ",gy(T.created_at)]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("button",{onClick:()=>O(T),className:"px-3.5 py-2 bg-slate-50 hover:bg-slate-100 text-slate-700 text-xs font-medium rounded-xl flex items-center gap-1.5 transition-colors cursor-pointer border border-slate-200 shadow-xs",children:[c.jsx(ih,{className:"w-3.5 h-3.5 text-emerald-600"}),c.jsx("span",{children:"复用此任务重跑"})]}),P&&c.jsxs(c.Fragment,{children:[c.jsxs("button",{onClick:J,className:"px-3.5 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 border border-indigo-200 text-xs font-medium rounded-xl flex items-center gap-1.5 transition-colors cursor-pointer",children:[c.jsx(wm,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:"优先插队"})]}),c.jsxs("button",{onClick:()=>de(!1),className:"px-3.5 py-2 bg-slate-50 hover:bg-slate-100 text-slate-600 text-xs font-medium rounded-xl flex items-center gap-1.5 transition-colors cursor-pointer border border-slate-200",children:[c.jsx($x,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:"取消"})]})]}),Q&&c.jsxs("button",{onClick:()=>de(!0),className:"px-3.5 py-2 bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-200 text-xs font-medium rounded-xl flex items-center gap-1.5 transition-colors cursor-pointer shadow-xs",children:[c.jsx(kx,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:"强行终止任务"})]})]})]}),c.jsx("div",{className:"relative bg-slate-900 border border-slate-200 rounded-2xl overflow-hidden shadow-xs flex flex-col items-center justify-center min-h-[360px]",children:se&&A?c.jsxs("div",{className:"w-full flex flex-col items-center p-4",children:[c.jsx("video",{src:A,controls:!0,autoPlay:!0,loop:!0,playsInline:!0,className:"max-h-[560px] w-auto max-w-full rounded-xl shadow-xl bg-black"}),c.jsxs("div",{className:"w-full flex items-center justify-between mt-3 px-2",children:[c.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:["规格:",R.width,"×",R.height," · ",R.frames," 帧 (约 ",(R.frames/24).toFixed(1),"s)"]}),c.jsxs("a",{href:A,download:`h3_${T.id.substring(0,8)}.mp4`,className:"px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-medium rounded-xl flex items-center gap-2 transition-all shadow-sm",children:[c.jsx(Px,{className:"w-4 h-4"}),c.jsxs("span",{children:["下载 MP4 视频 ",T.size_bytes?`(${by(T.size_bytes)})`:""]})]})]})]}):Q?c.jsxs("div",{className:"w-full max-w-2xl p-8 flex flex-col items-center gap-6",children:[c.jsxs("div",{className:"flex items-center gap-2 text-emerald-400 text-xs font-bold uppercase tracking-wider bg-emerald-950/60 px-3 py-1 rounded-full border border-emerald-500/30",children:[c.jsx(Yx,{className:"w-3.5 h-3.5 animate-spin"}),c.jsx("span",{children:"GPU 扩散采样中 · 实时推演"})]}),c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("div",{className:"text-5xl font-extrabold font-mono text-white tracking-tight flex items-baseline gap-1",children:[c.jsx("span",{children:Le}),c.jsx("span",{className:"text-2xl text-emerald-400 font-semibold",children:"%"})]}),c.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:["正在执行第 ",c.jsx("span",{className:"text-white font-mono font-bold",children:Ae})," 步 / 共 ",c.jsx("span",{className:"text-slate-300 font-mono",children:Ne})," 步"]})]}),c.jsxs("div",{className:"w-full flex flex-col gap-2",children:[c.jsx("div",{className:"w-full bg-slate-800/90 h-3.5 rounded-full overflow-hidden p-0.5 border border-slate-700 shadow-inner",children:c.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-400 h-full rounded-full transition-all duration-300 relative overflow-hidden",style:{width:`${Le}%`},children:c.jsx("div",{className:"absolute inset-0 bg-white/25 animate-pulse"})})}),c.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 px-1 font-mono",children:[c.jsxs("span",{className:"flex items-center gap-1 text-slate-300",children:[c.jsx(Li,{className:"w-3.5 h-3.5 text-emerald-400"}),c.jsxs("span",{children:["已耗时: ",Ye," 秒"]})]}),je&&c.jsxs("span",{className:"text-emerald-400 font-medium",children:["预计还需: ",je]})]})]}),c.jsxs("div",{className:"grid grid-cols-4 w-full gap-2 pt-4 border-t border-slate-800 text-center",children:[c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsx("div",{className:"w-6 h-6 rounded-full bg-emerald-500/20 text-emerald-400 text-xs font-bold flex items-center justify-center border border-emerald-500/40",children:"✓"}),c.jsx("span",{className:"text-[11px] text-slate-400",children:"1. 排队调度"})]}),c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsx("div",{className:"w-6 h-6 rounded-full bg-emerald-500/20 text-emerald-400 text-xs font-bold flex items-center justify-center border border-emerald-500/40",children:"✓"}),c.jsx("span",{className:"text-[11px] text-slate-400",children:"2. 模型装载"})]}),c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsx("div",{className:"w-6 h-6 rounded-full bg-emerald-500 text-white text-xs font-bold flex items-center justify-center shadow-md animate-pulse",children:"3"}),c.jsx("span",{className:"text-[11px] text-white font-semibold",children:"3. 扩散计算"})]}),c.jsxs("div",{className:"flex flex-col items-center gap-1 opacity-40",children:[c.jsx("div",{className:"w-6 h-6 rounded-full bg-slate-800 text-slate-400 text-xs font-bold flex items-center justify-center border border-slate-700",children:"4"}),c.jsx("span",{className:"text-[11px] text-slate-400",children:"4. 压制出片"})]})]})]}):P?c.jsxs("div",{className:"p-12 flex flex-col items-center gap-3 text-center",children:[c.jsx(Li,{className:"w-10 h-10 text-blue-400 animate-pulse"}),c.jsxs("div",{children:[c.jsxs("h3",{className:"text-base font-semibold text-blue-300",children:["正在等待空闲的 ",T.partition||"GPU"," 后端…"]}),c.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:["当前排队第 ",T.queue_position||1," 位,空闲节点就绪后将自动调度启动"]})]})]}):c.jsxs("div",{className:"p-12 flex flex-col items-center gap-3 text-center max-w-lg",children:[c.jsx(dy,{className:"w-10 h-10 text-rose-400"}),c.jsx("h3",{className:"text-base font-semibold text-rose-300",children:Ve?"生成失败":"任务已取消"}),c.jsx("div",{className:"p-3 bg-rose-950/40 border border-rose-500/30 rounded-xl text-xs text-rose-200/90 font-mono text-left w-full max-h-48 overflow-y-auto whitespace-pre-wrap",children:T.error||"无详细错误日志"})]})}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3.5",children:[c.jsxs("div",{className:"p-4 bg-white border border-slate-200 rounded-xl flex flex-col gap-1 shadow-xs",children:[c.jsxs("span",{className:"text-[11px] uppercase tracking-wider text-slate-500 font-semibold flex items-center gap-1.5",children:[c.jsx(Li,{className:"w-3.5 h-3.5 text-emerald-600"}),c.jsx("span",{children:"生成耗时"})]}),c.jsx("span",{className:"text-sm font-bold font-mono text-slate-800",children:T.started_at&&T.finished_at?`${(T.finished_at-T.started_at).toFixed(1)} 秒`:Q?`${T.elapsed_seconds||0} 秒 (进行中)`:"—"})]}),c.jsxs("div",{className:"p-4 bg-white border border-slate-200 rounded-xl flex flex-col gap-1 shadow-xs",children:[c.jsxs("span",{className:"text-[11px] uppercase tracking-wider text-slate-500 font-semibold flex items-center gap-1.5",children:[c.jsx(Ix,{className:"w-3.5 h-3.5 text-indigo-600"}),c.jsx("span",{children:"峰值显存"})]}),c.jsx("span",{className:"text-sm font-bold font-mono text-slate-800",children:T.peak_vram_gb?`${T.peak_vram_gb} GB`:"—"})]}),c.jsxs("div",{className:"p-4 bg-white border border-slate-200 rounded-xl flex flex-col gap-1 shadow-xs",children:[c.jsxs("span",{className:"text-[11px] uppercase tracking-wider text-slate-500 font-semibold flex items-center gap-1.5",children:[c.jsx(uy,{className:"w-3.5 h-3.5 text-amber-600"}),c.jsx("span",{children:"分配后端卡"})]}),c.jsx("span",{className:"text-sm font-bold font-mono text-slate-800 truncate",children:T.backend||"自动弹性调度"})]}),c.jsxs("div",{className:"p-4 bg-white border border-slate-200 rounded-xl flex flex-col gap-1 shadow-xs",children:[c.jsxs("span",{className:"text-[11px] uppercase tracking-wider text-slate-500 font-semibold flex items-center gap-1.5",children:[c.jsx(Fx,{className:"w-3.5 h-3.5 text-teal-600"}),c.jsx("span",{children:"采样规格"})]}),c.jsxs("span",{className:"text-sm font-bold font-mono text-slate-800",children:[R.turbo===!1?"常规":"Turbo"," · ",R.steps??"?","步 · seed=",R.seed??0]})]})]}),c.jsxs("div",{className:"p-5 bg-white border border-slate-200 rounded-2xl flex flex-col gap-3 shadow-xs",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-600",children:"Prompt 提示词"}),c.jsxs("button",{onClick:K,className:"flex items-center gap-1.5 text-xs text-slate-500 hover:text-emerald-600 transition-colors cursor-pointer",children:[k?c.jsx(Xx,{className:"w-3.5 h-3.5 text-emerald-600"}):c.jsx(Wx,{className:"w-3.5 h-3.5"}),c.jsx("span",{children:k?"已复制":"复制文本"})]})]}),c.jsx("p",{className:"text-sm text-slate-800 leading-relaxed font-normal bg-slate-50 p-3.5 rounded-xl border border-slate-200 whitespace-pre-wrap",children:R.prompt||"(无提示词)"}),R.negative_prompt&&c.jsxs("div",{className:"text-xs text-slate-600 flex flex-col gap-1 pt-1",children:[c.jsx("span",{className:"font-semibold text-slate-500",children:"负面提示词:"}),c.jsx("span",{className:"bg-slate-50 p-2.5 rounded-xl border border-slate-200 text-slate-600",children:R.negative_prompt})]})]}),(R.first_frame_url||R.last_frame_url||(R.reference_image_urls||[]).length>0||(R.reference_video_urls||[]).length>0||(R.reference_audio_urls||[]).length>0)&&c.jsxs("div",{className:"p-5 bg-white border border-slate-200 rounded-2xl flex flex-col gap-3.5 shadow-xs",children:[c.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-600",children:"输入素材与参考源"}),c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 md:grid-cols-6 gap-3",children:[R.first_frame_url&&c.jsxs("div",{className:"relative group bg-slate-100 rounded-xl overflow-hidden border border-slate-200 shadow-xs",children:[c.jsx("img",{src:ru(R.first_frame_url),alt:"首帧",className:"w-full aspect-square object-cover"}),c.jsx("div",{className:"absolute bottom-0 inset-x-0 bg-slate-900/80 px-2 py-1 text-[10px] text-white font-medium text-center",children:"首帧"})]}),R.last_frame_url&&c.jsxs("div",{className:"relative group bg-slate-100 rounded-xl overflow-hidden border border-slate-200 shadow-xs",children:[c.jsx("img",{src:ru(R.last_frame_url),alt:"尾帧",className:"w-full aspect-square object-cover"}),c.jsx("div",{className:"absolute bottom-0 inset-x-0 bg-slate-900/80 px-2 py-1 text-[10px] text-white font-medium text-center",children:"尾帧"})]}),(R.reference_image_urls||[]).map((G,Ee)=>c.jsxs("div",{className:"relative group bg-slate-100 rounded-xl overflow-hidden border border-slate-200 shadow-xs",children:[c.jsx("img",{src:ru(G),alt:`参考图${Ee+1}`,className:"w-full aspect-square object-cover"}),c.jsxs("div",{className:"absolute bottom-0 inset-x-0 bg-slate-900/80 px-2 py-1 text-[10px] text-white font-medium text-center truncate",children:["参考图 ",Ee+1]})]},Ee)),(R.reference_video_urls||[]).map((G,Ee)=>c.jsxs("div",{className:"relative group bg-slate-100 rounded-xl overflow-hidden border border-slate-200 shadow-xs",children:[c.jsx("video",{src:Zi(G),controls:!0,className:"w-full aspect-square object-cover"}),c.jsxs("div",{className:"absolute bottom-0 inset-x-0 bg-slate-900/80 px-2 py-1 text-[10px] text-white font-medium text-center truncate",children:["参考视频 ",Ee+1]})]},Ee))]})]}),c.jsxs("div",{className:"flex flex-col gap-3 pt-2 pb-12",children:[c.jsxs("div",{className:"border border-slate-200 rounded-xl overflow-hidden bg-slate-50/60",children:[c.jsxs("button",{onClick:()=>De(!F),className:"w-full px-4 py-3 text-left text-xs font-mono text-slate-600 hover:text-slate-900 hover:bg-slate-100 flex items-center justify-between cursor-pointer",children:[c.jsx("span",{children:"用户提交的原始请求参数 (JSON)"}),c.jsx("span",{className:"text-[11px] text-slate-400",children:F?"收起":"展开"})]}),F&&c.jsx("pre",{className:"p-4 text-[11px] font-mono text-slate-700 overflow-x-auto border-t border-slate-200 bg-white leading-relaxed",children:JSON.stringify(R,null,2)})]}),T.comfy_prompt_id&&c.jsxs("div",{className:"border border-slate-200 rounded-xl overflow-hidden bg-slate-50/60",children:[c.jsxs("button",{onClick:w,className:"w-full px-4 py-3 text-left text-xs font-mono text-slate-600 hover:text-slate-900 hover:bg-slate-100 flex items-center justify-between cursor-pointer",children:[c.jsx("span",{children:"ComfyUI 执行图谱与日志 (History)"}),c.jsx("span",{className:"text-[11px] text-slate-400",children:le?"收起":"展开"})]}),le&&c.jsx("pre",{className:"p-4 text-[11px] font-mono text-slate-700 overflow-x-auto border-t border-slate-200 bg-white leading-relaxed max-h-96",children:j?"正在拉取 ComfyUI History…":D?JSON.stringify(D,null,2):"无可用数据"})]})]}),c.jsx(ph,{isOpen:ve.isOpen,title:ve.title,content:ve.content,isDanger:ve.isDanger,onConfirm:ve.onConfirm,onCancel:()=>Re(G=>({...G,isOpen:!1}))})]})}function Em(){if(typeof window>"u")return null;let o=window.location.pathname;const b=ul();b&&o.startsWith(b)&&(o=o.slice(b.length));const O=o.match(/^\/task\.html\/(.+)$/);return O?decodeURIComponent(O[1]):null}function By(){const{addToast:o}=Ji(),[b,O]=H.useState(()=>Em()),[r,T]=H.useState(null),[M,$]=H.useState(null);H.useEffect(()=>{const j=()=>{const X=Em();O(X)};return window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)},[]);const q=async()=>{const j=await My();j&&$(j)};H.useEffect(()=>{q();const j=setInterval(q,6e3);return()=>clearInterval(j)},[]);const k=j=>{O(j);const X=ul();window.history.pushState(null,"",`${X}/task.html/${encodeURIComponent(j)}`)},I=()=>{O(null),T(null);const j=ul();window.history.pushState(null,"",`${j}/newtask.html`)},D=j=>{O(null),T(j.req||{});const X=ul();window.history.pushState(null,"",`${X}/newtask.html`),o("已将历史任务参数灌入表单,可直接微调或提交","info")},S=()=>{const j=Ki(),X=window.prompt("设置 H3 访问令牌 (Access Token),留空清除:",j);X!==null&&(Qf(X),o(X?"令牌已保存":"令牌已清除","info"))};return c.jsxs("div",{className:"flex h-screen w-screen overflow-hidden bg-slate-50 text-slate-800 font-sans",children:[c.jsx(wy,{selectedId:b,onSelectTask:k,onCreateTask:I,onRerunTask:D,backendInfo:M,onRefreshBackends:q,onManageToken:S}),c.jsx("main",{className:"flex-1 h-full overflow-y-auto relative flex flex-col bg-white",children:c.jsx("div",{className:"flex-1 w-full",children:b?c.jsx(qy,{taskId:b,onBack:I,onRerun:D}):c.jsx(Hy,{initialValues:r,onCreated:k})})})]})}function Yy(){return c.jsx(Cy,{children:c.jsx(By,{})})}Ox.createRoot(document.getElementById("root")).render(c.jsx(px.StrictMode,{children:c.jsx(Yy,{})})); -- libgit2 0.21.4