import{d as a,r as e,o as t,c as l,w as s,g as o,i as u,b as c,e as n,f as i,h as d,S as r,j as f,F as _,k as v,z as g,t as h,n as m,l as p,p as y}from"./index-Co9nPWLO.js";import{u as b}from"./audio.DwsFIuQc.js";import{_ as k}from"./_plugin-vue_export-helper.BCo6x5W8.js";const w=k(a({__name:"index",setup(a){const k=b(),w=e([{id:1,name:"全部"},{id:2,name:"今天"},{id:3,name:"本周"},{id:4,name:"本月"}]),D=e(1),S=e([]),$=e(1),x=e(0),M=e(!1),C=e(!0),I={cherry:["#667eea","#764ba2"],ethan:["#f093fb","#f5576c"],serena:["#4facfe","#00f2fe"],chelsie:["#43e97b","#38f9d7"],momo:["#fa709a","#fee140"],vivian:["#a8edea","#fed6e3"],moon:["#5ee7df","#b490ca"],maia:["#d299c2","#fef9d7"],kai:["#89f7fe","#66a6ff"],nofish:["#cd9cf2","#f6f3ff"]};function j(a){const e=I[a]||["#667eea","#764ba2"];return`linear-gradient(135deg, ${e[0]} 0%, ${e[1]} 100%)`}async function O(a=!1){if(!M.value){a||($.value=1),M.value=!0;try{let e="";const t=new Date;switch(D.value){case 2:e=new Date(t.setHours(0,0,0,0)).toISOString();break;case 3:const a=new Date(t);a.setDate(a.getDate()-7),e=a.toISOString();break;case 4:const l=new Date(t);l.setMonth(l.getMonth()-1),e=l.toISOString()}const l={page:$.value,pageSize:20};e&&(l.startDate=e);const s=await o("/history",l);a?S.value.push(...s.list):S.value=s.list,x.value=s.total,C.value=$.value<s.totalPages}catch(e){console.error("获取历史记录失败:",e)}finally{M.value=!1}}}function z(){C.value&&!M.value&&($.value++,O(!0))}function T(a){const e=new Date(a),t=(new Date).getTime()-e.getTime(),l=Math.floor(t/864e5);return 0===l?"今天":1===l?"昨天":l<7?`${l}天前`:`${e.getMonth()+1}/${e.getDate()}`}return t(async()=>{await O()}),(a,e)=>{const t=i,o=u,b=r;return c(),l(o,{class:"page"},{default:s(()=>[n(o,{class:"search-bar"},{default:s(()=>[n(o,{class:"search-inner"},{default:s(()=>[n(t,{class:"search-icon"},{default:s(()=>[d("🔍")]),_:1}),n(t,{class:"search-placeholder"},{default:s(()=>[d("搜索历史记录...")]),_:1})]),_:1})]),_:1}),n(o,{class:"tab-bar"},{default:s(()=>[n(b,{class:"tab-scroll","scroll-x":"true","show-scrollbar":!1},{default:s(()=>[n(o,{class:"tab-list"},{default:s(()=>[(c(!0),f(_,null,v(w.value,a=>(c(),l(o,{key:a.id,class:g(["tab-item",{active:D.value===a.id}]),onClick:e=>async function(a){D.value=a,$.value=1,await O()}(a.id)},{default:s(()=>[n(t,null,{default:s(()=>[d(h(a.name),1)]),_:2},1024)]),_:2},1032,["class","onClick"]))),128))]),_:1})]),_:1})]),_:1}),n(b,{"scroll-y":"",class:"audio-list",onScrolltolower:z},{default:s(()=>[0!==S.value.length||M.value?(c(),l(o,{key:1,class:"audio-grid"},{default:s(()=>[(c(!0),f(_,null,v(S.value,a=>(c(),l(o,{key:a._id,class:"audio-card",onClick:e=>function(a){k.play(a),y({url:`/pages/player/index?id=${a._id}`})}(a)},{default:s(()=>[n(o,{class:"audio-cover",style:m({background:j(a.voiceId)})},{default:s(()=>[n(t,{class:"cover-icon"},{default:s(()=>[d("🎵")]),_:1}),n(o,{class:"play-overlay"},{default:s(()=>[n(t,{class:"play-icon"},{default:s(()=>[d("▶")]),_:1})]),_:1}),n(t,{class:"audio-duration-badge"},{default:s(()=>{return[d(h((e=a.audioDuration,`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`)),1)];var e}),_:2},1024)]),_:2},1032,["style"]),n(o,{class:"audio-info"},{default:s(()=>[n(t,{class:"audio-title"},{default:s(()=>[d(h(a.title),1)]),_:2},1024),n(t,{class:"audio-meta"},{default:s(()=>[d(h(a.wordCount)+"字 · "+h(T(a.createdAt)),1)]),_:2},1024)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})):(c(),l(o,{key:0,class:"empty"},{default:s(()=>[n(t,{class:"empty-icon"},{default:s(()=>[d("📚")]),_:1}),n(t,{class:"empty-text"},{default:s(()=>[d("暂无历史记录")]),_:1}),n(t,{class:"empty-hint"},{default:s(()=>[d("快去生成第一个音频吧")]),_:1})]),_:1})),M.value?(c(),l(o,{key:2,class:"loading"},{default:s(()=>[n(t,null,{default:s(()=>[d("加载中...")]),_:1})]),_:1})):p("",!0),!C.value&&S.value.length>0?(c(),l(o,{key:3,class:"no-more"},{default:s(()=>[n(t,null,{default:s(()=>[d("没有更多了")]),_:1})]),_:1})):p("",!0)]),_:1})]),_:1})}}}),[["__scopeId","data-v-ef1d16c5"]]);export{w as default};
