import{d as a,r as t,O as e,o as l,c as s,w as n,y as o,i as u,b as i,e as r,f as c,h as d,$ as v,m as f,l as p,t as _,J as y,M as m,N as k}from"./index-Co9nPWLO.js";import{e as b,a as h,b as w}from"./video-generator-api.Cip3yDj1.js";import{_ as U}from"./_plugin-vue_export-helper.BCo6x5W8.js";const g="http://localhost:3000",x=U(a({__name:"preview",setup(a){const U=t(null);function x(){y()}function C(a){if(!a)return"--:--";return`${Math.floor(a/60)}:${(a%60).toString().padStart(2,"0")}`}async function I(a){try{U.value=await b(a)}catch(t){console.error("加载项目失败:",t),o({title:"加载失败",icon:"none"})}}async function S(){var a;if(!(null==(a=U.value)?void 0:a.outputUrl))return;const t=g+U.value.outputUrl;window.open(t,"_blank")}async function j(){var a;if(!(null==(a=U.value)?void 0:a.outputUrl))return;const t=g+U.value.outputUrl;uni.share({provider:"weixin",scene:"WXSession",title:U.value.title,type:5,videoUrl:t})}async function M(){var a;if(null==(a=U.value)?void 0:a.id)try{m({title:"正在重新生成..."}),await h(U.value.id);const a=setInterval(async()=>{const t=await w(U.value.id);"completed"===t.status?(clearInterval(a),k(),o({title:"重新生成成功",icon:"success"}),I(U.value.id)):"failed"===t.status&&(clearInterval(a),k(),o({title:"生成失败",icon:"none"}))},2e3)}catch(t){k(),console.error("重新生成失败:",t),o({title:"重新生成失败",icon:"none"})}}return e(a=>{(null==a?void 0:a.id)&&I(Number(a.id))}),l(()=>{}),(a,t)=>{const e=c,l=u,o=v,y=f;return i(),s(l,{class:"page"},{default:n(()=>{var a;return[r(l,{class:"nav-bar"},{default:n(()=>[r(l,{class:"nav-content"},{default:n(()=>[r(l,{class:"nav-left",onClick:x},{default:n(()=>[r(e,{class:"back-icon"},{default:n(()=>[d("←")]),_:1})]),_:1}),r(e,{class:"page-title"},{default:n(()=>[d("视频预览")]),_:1}),r(l,{class:"nav-right"})]),_:1})]),_:1}),(null==(a=U.value)?void 0:a.outputUrl)?(i(),s(l,{key:0,class:"video-container"},{default:n(()=>[r(o,{src:g+U.value.outputUrl,class:"video-player",controls:"",autoplay:"","show-fullscreen-btn":""},null,8,["src"])]),_:1})):(i(),s(l,{key:1,class:"empty-state"},{default:n(()=>[r(e,{class:"empty-icon"},{default:n(()=>[d("🎥")]),_:1}),r(e,{class:"empty-text"},{default:n(()=>[d("暂无视频")]),_:1})]),_:1})),r(l,{class:"action-buttons"},{default:n(()=>{var a,t;return[(null==(a=U.value)?void 0:a.outputUrl)?(i(),s(y,{key:0,class:"action-btn download",onClick:S},{default:n(()=>[d(" 📥 下载视频 ")]),_:1})):p("",!0),(null==(t=U.value)?void 0:t.outputUrl)?(i(),s(y,{key:1,class:"action-btn share",onClick:j},{default:n(()=>[d(" 📤 分享视频 ")]),_:1})):p("",!0),r(y,{class:"action-btn regenerate",onClick:M},{default:n(()=>[d(" 🔄 重新生成 ")]),_:1})]}),_:1}),U.value?(i(),s(l,{key:2,class:"video-info"},{default:n(()=>[r(e,{class:"info-title"},{default:n(()=>[d(_(U.value.title),1)]),_:1}),r(l,{class:"info-meta"},{default:n(()=>[r(e,{class:"meta-item"},{default:n(()=>[d("时长: "+_(C(U.value.duration)),1)]),_:1}),r(e,{class:"meta-item"},{default:n(()=>{return[d("大小: "+_((a=U.value.fileSize,a?a<1048576?(a/1024).toFixed(1)+"KB":(a/1048576).toFixed(1)+"MB":"--")),1)];var a}),_:1})]),_:1})]),_:1})):p("",!0)]}),_:1})}}}),[["__scopeId","data-v-af91d089"]]);export{x as default};
