import{d as a,r as e,a as t,o as s,c as l,w as c,y as o,i as r,b as n,e as i,f as u,h as d,j as f,F as p,k as _,G as v,z as y,t as g,n as m,l as k,D as h,J as C,p as b,M as x,N as j,H as w}from"./index-Co9nPWLO.js";import{g as S,a as z,d as F}from"./video-generator-api.Cip3yDj1.js";import{_ as $}from"./_plugin-vue_export-helper.BCo6x5W8.js";const B=$(a({__name:"index",setup(a){const $=e([]),B=e(!1),M=e(1),U=e(!0);async function D(a=!1){if(!B.value){a&&(M.value=1,$.value=[],U.value=!0),B.value=!0;try{const e=await S({page:M.value,pageSize:10});if(!e||!e.items)return console.error("数据格式错误:",e),void o({title:"数据格式错误",icon:"none"});a?$.value=e.items:$.value.push(...e.items),U.value=10===e.items.length,M.value++}catch(e){console.error("加载项目列表失败:",e),o({title:"加载失败",icon:"none"})}finally{B.value=!1}}}function G(){U.value&&!B.value&&D()}function H(){C()}function I(){b({url:"/pages/video-generator/create"})}function J(a){a.outputUrl&&b({url:`/pages/video-generator/preview?id=${a.id}`})}return t(()=>{D(!0)}),s(()=>{D(!0)}),(a,e)=>{const t=u,s=r,C=v;return n(),l(s,{class:"page"},{default:c(()=>[i(s,{class:"nav-bar"},{default:c(()=>[i(s,{class:"nav-content"},{default:c(()=>[i(s,{class:"nav-left",onClick:H},{default:c(()=>[i(t,{class:"back-icon"},{default:c(()=>[d("←")]),_:1})]),_:1}),i(t,{class:"page-title"},{default:c(()=>[d("视频生成")]),_:1}),i(s,{class:"nav-right"})]),_:1})]),_:1}),i(s,{class:"main-content"},{default:c(()=>[i(s,{class:"create-card",onClick:I},{default:c(()=>[i(t,{class:"create-icon"},{default:c(()=>[d("🎬")]),_:1}),i(t,{class:"create-text"},{default:c(()=>[d("创建新视频")]),_:1}),i(t,{class:"create-hint"},{default:c(()=>[d("图片 + 音频 = 精美视频")]),_:1})]),_:1}),$.value.length>0?(n(),l(s,{key:0,class:"project-list"},{default:c(()=>[(n(!0),f(p,null,_($.value,a=>(n(),l(s,{key:a.id,class:"project-card",onClick:e=>function(a){"draft"===a.status?b({url:`/pages/video-generator/create?id=${a.id}`}):"completed"===a.status&&J(a)}(a)},{default:c(()=>[i(s,{class:"card-cover"},{default:c(()=>[a.coverUrl?(n(),l(C,{key:0,src:a.coverUrl,mode:"aspectFill",class:"cover-image"},null,8,["src"])):(n(),l(s,{key:1,class:"cover-placeholder"},{default:c(()=>[i(t,{class:"placeholder-icon"},{default:c(()=>[d("🎥")]),_:1})]),_:1})),i(s,{class:y(["status-badge",a.status])},{default:c(()=>{return[d(g((e=a.status,{draft:"草稿",processing:"生成中",completed:"已完成",failed:"失败"}[e]||e)),1)];var e}),_:2},1032,["class"]),"processing"===a.status?(n(),l(s,{key:2,class:"progress-overlay"},{default:c(()=>[i(s,{class:"progress-bar"},{default:c(()=>[i(s,{class:"progress-fill",style:m({width:a.progress+"%"})},null,8,["style"])]),_:2},1024),i(t,{class:"progress-text"},{default:c(()=>[d(g(a.progress)+"%",1)]),_:2},1024)]),_:2},1024)):k("",!0)]),_:2},1024),i(s,{class:"card-info"},{default:c(()=>[i(t,{class:"project-title"},{default:c(()=>[d(g(a.title),1)]),_:2},1024),i(s,{class:"project-meta"},{default:c(()=>[a.duration?(n(),l(t,{key:0,class:"meta-item"},{default:c(()=>{return[d(" ⏱️ "+g((e=a.duration,`${Math.floor(e/60)}:${(e%60).toString().padStart(2,"0")}`)),1)];var e}),_:2},1024)):k("",!0),a.fileSize?(n(),l(t,{key:1,class:"meta-item"},{default:c(()=>{return[d(" 📦 "+g((e=a.fileSize,e<1024?e+"B":e<1048576?(e/1024).toFixed(1)+"KB":(e/1048576).toFixed(1)+"MB")),1)];var e}),_:2},1024)):k("",!0)]),_:2},1024)]),_:2},1024),i(s,{class:"card-actions"},{default:c(()=>["completed"===a.status?(n(),l(s,{key:0,class:"action-btn primary",onClick:h(e=>J(a),["stop"])},{default:c(()=>[d(" 预览 ")]),_:2},1032,["onClick"])):k("",!0),"failed"===a.status?(n(),l(s,{key:1,class:"action-btn warning",onClick:h(e=>async function(a){try{x({title:"正在生成..."}),await z(a),j(),o({title:"开始生成",icon:"success"}),D(!0)}catch(e){j(),console.error("生成失败:",e),o({title:"生成失败",icon:"none"})}}(a.id),["stop"])},{default:c(()=>[d(" 重试 ")]),_:2},1032,["onClick"])):k("",!0),i(s,{class:"action-btn danger",onClick:h(e=>async function(a){w({title:"确认删除",content:"确定要删除这个视频项目吗？",success:async e=>{if(e.confirm)try{await F(a),o({title:"删除成功",icon:"success"}),D(!0)}catch(t){console.error("删除失败:",t),o({title:"删除失败",icon:"none"})}}})}(a.id),["stop"])},{default:c(()=>[d(" 删除 ")]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})):(n(),l(s,{key:1,class:"empty-state"},{default:c(()=>[i(t,{class:"empty-icon"},{default:c(()=>[d("🎥")]),_:1}),i(t,{class:"empty-text"},{default:c(()=>[d("暂无视频项目")]),_:1}),i(t,{class:"empty-hint"},{default:c(()=>[d("点击上方按钮创建第一个视频")]),_:1})]),_:1})),U.value?(n(),l(s,{key:2,class:"load-more",onClick:G},{default:c(()=>[B.value?(n(),l(t,{key:0},{default:c(()=>[d("加载中...")]),_:1})):(n(),l(t,{key:1},{default:c(()=>[d("加载更多")]),_:1}))]),_:1})):k("",!0)]),_:1})]),_:1})}}}),[["__scopeId","data-v-aa38bcd5"]]);export{B as default};
