header.ceee9546.js 4.0 KB

1
  1. import{d as O,l as m,k as T,u as I,aC as A,_ as E,m as H,h as K,a as o,S as M,K as _,v as V,w as y,U as P,x as U,R as z,P as w}from"./vendor.0f683fb2.js";/* empty css *//* empty css *//* empty css *//* empty css */import{C as B}from"./index.30f2de60.js";import{c as J}from"./index.3db72433.js";import{c as D}from"./index.926ca9c5.js";import{S as F}from"./select-tag.7a8c72d9.js";import{g as L}from"./music.cdfcdec2.js";import{S as W}from"./select-subject.93f4e3d7.js";import{u as h,S as b}from"./hooks.cbace03b.js";import{s as k}from"./index.7abc2ed3.js";function $(s){return{all:s=s||new Map,on:function(c,r){var t=s.get(c);t?t.push(r):s.set(c,[r])},off:function(c,r){var t=s.get(c);t&&(r?t.splice(t.indexOf(r)>>>0,1):s.set(c,[]))},emit:function(c,r){var t=s.get(c);t&&t.slice().map(function(l){l(r)}),(t=s.get("*"))&&t.slice().map(function(l){l(c,r)})}}}const q="_search_ngdof_1",G="_sticky_ngdof_9",Q="_title_ngdof_15",X="_keywords_ngdof_21",Y="_content_ngdof_28",Z="_searchKeyword_ngdof_38",ee="_remove_ngdof_46",oe="_label_ngdof_49";var d={search:q,sticky:G,title:Q,keywords:X,content:Y,searchKeyword:Z,remove:ee,label:oe};function te(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!U(s)}const g=$(),C=m();var se=O({name:"MusicSearchHeader",setup(){console.log(k.user.data,"music-search-header");const s=h(b.SEARCH);if(!s.id){const e=k.user.data,n=e.subjectId?Number(e.subjectId.split(",")[0]):"",u=e.subjectName?e.subjectName.split(",")[0]:"";console.log(u,n,s),n&&h(b.SEARCH,JSON.stringify({id:n,name:u}),"set")}const c=m();localStorage.setItem("behaviorId",L());const r=T(),t=I(),l=m(""),v=m(""),p=m(!1),i=J("music-search",[]),f=m("songe");A(()=>{var n,u;const e=h(b.SEARCH);if(a.name=e.name||"\u5168\u90E8\u58F0\u90E8",a.id=e.id,t.path==="/music-songbook/search"){l.value="",v.value="",f.value="songe";try{(u=(n=C.value)==null?void 0:n.resetTags)==null||u.call(n)}catch(N){console.log(N)}}return!0}),E(f,e=>{g.emit("changeTab",e)});const j=e=>{l.value=e;const n=i.value.indexOf(e);n>-1&&i.value.splice(n,1),e&&(i.value.unshift(e),i.value.length=Math.min(i.value.length,5)),g.emit("search",e)},x=(e,n="")=>{const u=Object.values(e).flat().filter(Boolean).join(",");v.value=u,g.emit("confirm",e),p.value=!1},R=e=>{a.name=e.name,a.id=e.id,h(b.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set"),g.emit("confirmSubject",a),a.show=!1};H(()=>{});const S=h(b.SEARCH),a=K({show:!1,name:S.name||"\u5168\u90E8\u58F0\u90E8",id:S.id||""});return()=>o("div",{class:d.search},[o(M,{class:d.sticky},{default:()=>[o(B,{modelValue:l.value,showAction:!0,ref:c,onSearch:j,onFilter:()=>p.value=!0,filterDot:!!v.value,onClick:()=>{t.path==="/music-songbook"&&r.push({path:"/music-songbook/search"})}},{left:()=>o("div",{class:d.label,onClick:()=>a.show=!0},[a.name,o(_,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),t.path==="/music-songbook/search"&&o(V,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:f.value,"onUpdate:active":e=>f.value=e,onChange:e=>f.value=e},{default:()=>[o(y,{title:"\u5355\u66F2",name:"songe"},null),o(y,{title:"\u4E13\u8F91",name:"album"},null)]})]}),i.value.length>0&&t.path==="/music-songbook/search"&&o("div",{class:D(d.keywords,"van-hairline--bottom")},[o("div",{class:d.content},[i.value.map(e=>o(P,{round:!0,class:d.searchKeyword,key:e,onClick:()=>j(e)},te(e)?e:{default:()=>[e]}))]),o(_,{class:d.remove,name:"delete-o",onClick:()=>i.value=[]},null)]),o(z,null,null),o(w,{show:p.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>p.value=e},{default:()=>[o(F,{ref:C,onConfirm:x,onCancel:()=>{}},null)]}),o(w,{show:a.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>a.show=!1,onClosed:()=>a.show=!1},{default:()=>[o(W,{isReset:!0,searchParams:a,onComfirm:R},null)]})])}}),pe=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",mitter:g,default:se});export{pe as h,g as m,d as s};