header.a5bf6aec.js 3.9 KB

1
  1. import{d as O,g as N,V as f,S as H,Q as I,bH as E,a4 as V,W as x,U as A,j as t,O as _,R as K,aT as y,a0 as M}from"./ResizeObserver.es.62ab429c.js";import{T as P}from"./index.0eba5ce9.js";import"./index.b0c6821a.js";import"./index.3d6f6bcd.js";import{T as U,a as j}from"./index.ffd89e39.js";import{S as z}from"./index.002d8e53.js";import{d as B}from"./index.a6e5e68b.js";import{c as J}from"./index.926ca9c5.js";import{S as W}from"./select-tag.bdc20ffa.js";import{g as L}from"./music.56762674.js";import{S as Q}from"./select-subject.3a445c69.js";import{b,S as h}from"./hooks.3b599d36.js";import{C as $}from"./index.786e83cc.js";import{T as q}from"./index.1db64c88.js";function D(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 F="_search_152bw_1",G="_sticky_152bw_9",X="_title_152bw_12",Y="_keywords_152bw_18",Z="_content_152bw_25",ee="_searchKeyword_152bw_35",te="_remove_152bw_43",oe="_label_152bw_46";var u={search:F,sticky:G,title:X,keywords:Y,content:Z,searchKeyword:ee,remove:te,label:oe};function ae(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!M(a)}const p=D(),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=H(),o=I(),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(R){console.log(R)}}return!0}),V(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},T=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(q,{class:u.sticky},{default:()=>[t($,{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(P,{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(W,{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:T},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};