import{d as a,r as s,o as e,g as t,c as l,w as c,i as n,b as i,e as o,f as u,h as d,j as r,F as f,k as _,t as v,D as p,U as m,y,p as k,J as g}from"./index-Co9nPWLO.js";import{_ as h}from"./_plugin-vue_export-helper.BCo6x5W8.js";const x=h(a({__name:"index",setup(a){const h=s([]),x=s(!0);function C(){g()}return e(async()=>{await async function(){x.value=!0;try{const a=await t("/favorites");h.value=a||[]}catch(a){console.error("获取收藏列表失败:",a)}finally{x.value=!1}}()}),(a,s)=>{const e=u,t=n;return i(),l(t,{class:"page"},{default:c(()=>[o(t,{class:"nav-bar"},{default:c(()=>[o(t,{class:"nav-btn",onClick:C},{default:c(()=>[o(e,{class:"nav-icon"},{default:c(()=>[d("←")]),_:1})]),_:1}),o(e,{class:"nav-title"},{default:c(()=>[d("我的收藏")]),_:1}),o(t,{class:"nav-btn"})]),_:1}),x.value?(i(),l(t,{key:0,class:"loading"},{default:c(()=>[o(e,null,{default:c(()=>[d("加载中...")]),_:1})]),_:1})):0===h.value.length?(i(),l(t,{key:1,class:"empty"},{default:c(()=>[o(e,{class:"empty-icon"},{default:c(()=>[d("❤️")]),_:1}),o(e,{class:"empty-text"},{default:c(()=>[d("暂无收藏")]),_:1}),o(e,{class:"empty-hint"},{default:c(()=>[d("去听书页面收藏喜欢的音频吧")]),_:1})]),_:1})):(i(),l(t,{key:2,class:"list"},{default:c(()=>[(i(!0),r(f,null,_(h.value,a=>(i(),l(t,{key:a.id,class:"item",onClick:s=>{var e;(e=a.audio)&&k({url:`/pages/player/index?id=${e.id}`})}},{default:c(()=>[o(t,{class:"item-cover"},{default:c(()=>[o(e,{class:"cover-icon"},{default:c(()=>[d("🎵")]),_:1})]),_:1}),o(t,{class:"item-info"},{default:c(()=>[o(e,{class:"item-title"},{default:c(()=>{var s;return[d(v((null==(s=a.audio)?void 0:s.title)||"未知标题"),1)]}),_:2},1024),o(e,{class:"item-meta"},{default:c(()=>{var s;return[d(v((null==(s=a.audio)?void 0:s.wordCount)||0)+"字",1)]}),_:2},1024)]),_:2},1024),o(t,{class:"item-action",onClick:p(s=>async function(a){try{await m(`/favorites/${a}`),y({title:"已取消收藏",icon:"success"}),h.value=h.value.filter(s=>s.audioId!==a)}catch(s){console.error("取消收藏失败:",s),y({title:"操作失败",icon:"none"})}}(a.audioId),["stop"])},{default:c(()=>[o(e,{class:"action-icon"},{default:c(()=>[d("❤️")]),_:1})]),_:2},1032,["onClick"])]),_:2},1032,["onClick"]))),128))]),_:1}))]),_:1})}}}),[["__scopeId","data-v-a0441ccc"]]);export{x as default};
