header.4ae4bb8c.js 3.9 KB

1
  1. import{d as O,g as N,S as f,P as I,O as H,bD as E,a2 as M,U as x,Q as A,j as t,M as _,R as K,aR as y,Z as P}from"./index.394decd7.js";import{T as V}from"./index.dab716ce.js";import"./index.3bbf4ddb.js";import"./index.f1b52763.js";import{T as U,a as j}from"./index.ae00317c.js";import{S as z}from"./index.ada5e712.js";import{d as B}from"./index.75a0444f.js";import{c as J}from"./index.926ca9c5.js";import{S as D}from"./select-tag.9412794d.js";import{g as L}from"./music.8e2b5f5b.js";import{S as Q}from"./select-subject.2c6b1606.js";import{a as b,S as h}from"./hooks.9e5ee122.js";import{C as W}from"./index.e6e212d8.js";import{T as Z}from"./index.88270f6d.js";function $(a){return{all:a=a||new Map,on:function(r,c){var o=a.get(r);o?o.push(c):a.set(r,[c])},off:function(r,c){var o=a.get(r);o&&(c?o.splice(o.indexOf(c)>>>0,1):a.set(r,[]))},emit:function(r,c){var o=a.get(r);o&&o.slice().map(function(i){i(c)}),(o=a.get("*"))&&o.slice().map(function(i){i(r,c)})}}}const q="_search_152bw_1",F="_sticky_152bw_9",G="_title_152bw_12",X="_keywords_152bw_18",Y="_content_152bw_25",ee="_searchKeyword_152bw_35",te="_remove_152bw_43",oe="_label_152bw_46";var u={search:q,sticky:F,title:G,keywords:X,content:Y,searchKeyword:ee,remove:te,label:oe};function ae(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!P(a)}const p=$(),k=f();var se=O({name:"MusicSearchHeader",setup(){if(!b(h.SEARCH).id){const e=N.user.data,n=e.subjectId?Number(e.subjectId.split(",")[0]):"",m=e.subjectName?e.subjectName.split(",")[0]:"";n&&b(h.SEARCH,JSON.stringify({id:n,name:m}),"set")}const r=f();localStorage.setItem("behaviorId",L());const c=I(),o=H(),i=f(""),g=f(""),v=f(!1),l=B("music-search",[]),d=f("songe");E(()=>{var n,m;const e=b(h.SEARCH);if(s.name=e.name||"\u5168\u90E8\u58F0\u90E8",s.id=e.id,o.path==="/music-songbook/search"){i.value="",g.value="",d.value="songe";try{(m=(n=k.value)==null?void 0:n.resetTags)==null||m.call(n)}catch(T){console.log(T)}}return!0}),M(d,e=>{p.emit("changeTab",e)});const S=e=>{i.value=e;const n=l.value.indexOf(e);n>-1&&l.value.splice(n,1),e&&(l.value.unshift(e),l.value.length=Math.min(l.value.length,5)),p.emit("search",e)},C=(e,n="")=>{const m=Object.values(e).flat().filter(Boolean).join(",");g.value=m,p.emit("confirm",e),v.value=!1},R=e=>{s.name=e.name,s.id=e.id,b(h.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set"),p.emit("confirmSubject",s),s.show=!1};x(()=>{});const w=b(h.SEARCH),s=A({show:!1,name:w.name||"\u5168\u90E8\u58F0\u90E8",id:w.id||""});return()=>t("div",{class:u.search},[t(Z,{class:u.sticky},{default:()=>[t(W,{border:!1},null),t(z,{modelValue:i.value,ref:r,onSearch:S,onClick:()=>{o.path==="/music-songbook"&&c.push({path:"/music-songbook/search"})}},{left:()=>t("div",{class:u.label,onClick:()=>s.show=!0},[s.name,t(_,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),o.path==="/music-songbook/search"&&t(U,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:d.value,"onUpdate:active":e=>d.value=e,onChange:e=>d.value=e},{default:()=>[t(j,{title:"\u5355\u66F2",name:"songe"},null),t(j,{title:"\u4E13\u8F91",name:"album"},null)]})]}),l.value.length>0&&o.path==="/music-songbook/search"&&t("div",{class:J(u.keywords,"van-hairline--bottom")},[t("div",{class:u.content},[l.value.map(e=>t(V,{round:!0,class:u.searchKeyword,key:e,onClick:()=>S(e)},ae(e)?e:{default:()=>[e]}))]),t(_,{class:u.remove,name:"delete-o",onClick:()=>l.value=[]},null)]),t(K,null,null),t(y,{show:v.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>v.value=e},{default:()=>[t(D,{ref:k,onConfirm:C,onCancel:()=>{}},null)]}),t(y,{show:s.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>s.show=!1,onClosed:()=>s.show=!1},{default:()=>[t(Q,{searchParams:s,onComfirm:R},null)]})])}}),Se=Object.freeze(Object.defineProperty({__proto__:null,mitter:p,default:se},Symbol.toStringTag,{value:"Module"}));export{Se as h,p as m,u as s};