1 |
- import{T as k}from"./index-876d8b60-1720699367816.js";import{d as B,u as E,e as w,q as T,f as n,x as S,F as _,j as x,k as W,aC as P,E as O,w as R,aO as J,r as F,A as L}from"./index-b48b51d2-1720699367816.js";import{a as V,b as D}from"./api-d49c298b-1720699367816.js";import{T as M}from"./index-a2dc20f3-1720699367816.js";import{u as U}from"./catchData-309c65ac-1720699367816.js";const X="_container_7qbzu_1",$="_tools_7qbzu_8",G="_tagWrap_7qbzu_26",H="_tags_7qbzu_30",K="_firstButton_7qbzu_33",Q="_content_7qbzu_51",Y="_loadingContent_7qbzu_61",Z="_itemWrap_7qbzu_64",j="_itemWrapBox_7qbzu_69",ee="_item_7qbzu_64",te="_cover_7qbzu_84",ae="_itemImg_7qbzu_101",ne="_itemBg_7qbzu_131",ie="_itemName_7qbzu_156",le="_popSelect1_7qbzu_164",ce="_textBtn_7qbzu_174",se="_iconArrow_7qbzu_174",re="_textBtnActive_7qbzu_186",l={container:X,tools:$,tagWrap:G,tags:H,firstButton:K,content:Q,loadingContent:Y,itemWrap:Z,itemWrapBox:j,item:ee,cover:te,itemImg:ae,itemBg:ne,itemName:ie,popSelect1:le,textBtn:ce,iconArrow:se,textBtnActive:re},z=B({name:"ChildNodeSearch",props:{activeRow:{type:Object,default:()=>({})},list:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["selectChildTag"],setup(g,{emit:p}){const{activeRow:s}=J(g),o=F({});L(()=>g.activeRow,()=>{s.value=g.activeRow,v()});const v=()=>{s.value.activeIndex?(s.value.children||[]).forEach(e=>{if(e.id===s.value.activeIndex){let r,m="";e.children&&(r=[{columnName:e.children[0].columnName,name:"全部",id:""},...e.children],m=e.children[0].columnName,o.value={...e,columnName:m,activeIndex:e.activeIndex,children:r})}}):o.value={}};return T(()=>{v()}),()=>{var c;return n(_,null,[((c=s.value)==null?void 0:c.id)&&n(_,null,[n("div",{class:l.tags},[n(S,{size:[12,8]},{default:()=>{var e;return[n("span",{class:l.firstButton},[s.value.columnName]),(e=s.value)==null?void 0:e.children.map(r=>n(_,null,[n(x,{round:!0,secondary:(s.value.activeIndex||"")!=r.id,type:(s.value.activeIndex||"")==r.id?"primary":"default",onClick:()=>{if(g.loading)return;s.value.activeIndex=r.id;let m,f="";r.children?(m=[{columnName:r.children[0].columnName,name:"全部",id:""},...r.children],f=r.children[0].columnName,o.value={...r,columnName:f,activeIndex:"",children:m}):o.value={},p("selectChildTag",s.value.activeIndex)}},{default:()=>[r.name]})]))]}})]),n(z,{activeRow:o.value,onSelectChildTag:e=>{p("selectChildTag",e||s.value.activeIndex)}},null)])])}}}),Ie=B({name:"XiaokuAi",setup(){const g=U(),p=E(),s=localStorage.getItem("xiaoku-ai-search"),o=s?JSON.parse(s):{},v=o.childSelectId||o.tagActiveId,c=w({musicTagIds:v?[v]:[],enable:!0,instrumentId:o.instrumentId||null,keyword:"",page:1,rows:9999}),e=w({tags:[],tagChildren:[],tagActiveId:o.tagActiveId||"",tagActive:{},tagIndex:o.instrumentId||0,list:[],loading:!1,selectParents:{},childSelectId:o.childSelectId||null}),r=(t,i,a=[])=>{for(const u of i){if(u.children&&u.children.length>0){const d=r(t,u.children,[...a,u.id]);if(d.includes(t))return d}if(u.id===t)return[...a,t]}return a},m=(t,i)=>{for(const a of i){if(t.includes(a.id)&&a.children&&a.children.length>0){let u;a.children.forEach(d=>{t.includes(d.id)&&(u=d.id)}),a.activeIndex=u}a.children&&a.children.length>0&&m(t,a.children)}},f=t=>{for(const i of t)i.children&&i.children.length>0,i.activeIndex="",i.children&&i.children.length>0&&f(i.children)},q=t=>{if(e.loading)return;e.tagActiveId=t.id,e.childSelectId=null,f(e.tags);let i,a="";t.children?(i=[{columnName:t.children[0].columnName,name:"全部",id:""},...t.children],a=t.children[0].columnName,e.selectParents={...t,columnName:a,activeIndex:"",children:i}):e.selectParents={},localStorage.setItem("xiaoku-ai-search",JSON.stringify({tagActiveId:e.tagActiveId,instrumentId:c.instrumentId,childSelectId:e.childSelectId})),I()},b=async()=>{const t=await V();if(Array.isArray(t==null?void 0:t.data)&&t.data.length){const i=t.data||[];if(e.tags=[{columnName:i[0].columnName,name:"全部",id:""},...i],!e.tagActiveId)e.tagActiveId=e.tags[0].id;else{let a=r(o.childSelectId,e.tags);const u=a.findIndex(d=>d===o.childSelectId);a=a.slice(0,u+1),m(a,e.tags),e.tags.forEach(d=>{if(d.id===e.tagActiveId){let A,N="";if(d.children){A=[{columnName:d.children[0].columnName,name:"全部",id:""},...d.children],N=d.children[0].columnName;let y;d.children.forEach(C=>{a.includes(C.id)&&(y=C.id)}),e.selectParents={...d,columnName:N,activeIndex:y||"",children:A}}else e.selectParents={}}})}}},I=async()=>{var t;e.loading=!0;try{const i=e.childSelectId||e.tagActiveId,a=await D({...c,musicTagIds:[i]});Array.isArray((t=a==null?void 0:a.data)==null?void 0:t.rows)&&(e.list=a.data.rows)}catch(i){}e.loading=!1};T(async()=>{e.loading=!0;try{if(await b(),await I(),await g.getSubjects(),localStorage.setItem("xiaoku-ai-search",JSON.stringify({tagActiveId:e.tagActiveId,instrumentId:c.instrumentId,childSelectId:e.childSelectId,musicTagIds:c.musicTagIds})),c.instrumentId){let t=[];g.getSubjectInstruments.forEach(i=>{Array.isArray(i.instruments)&&i.instruments.forEach(a=>{c.instrumentId===a.value&&(t=i.instruments||[])})}),t.length>0&&h(t)}}catch(t){}e.loading=!1});const h=t=>{const i={};return t==null||t.forEach(a=>{a.id===e.tagIndex&&(i.selected=!0,i.name=a.name)}),i};return()=>n("div",{class:l.container},[n("div",{class:l.tools},[n("div",{class:l.tagWrap},[n("div",{class:l.tags},[n(S,{size:[12,8]},{default:()=>{var t,i;return[n("span",{class:l.firstButton},[(i=(t=e.tags)==null?void 0:t[0])==null?void 0:i.columnName]),e.tags.map(a=>n(_,null,[n(x,{round:!0,secondary:e.tagActiveId!==a.id,type:e.tagActiveId===a.id?"primary":"default",onClick:()=>q(a)},{default:()=>[a.name]})]))]}})]),n(z,{activeRow:e.selectParents,loading:e.loading,onSelectChildTag:t=>{e.childSelectId=t,localStorage.setItem("xiaoku-ai-search",JSON.stringify({tagActiveId:e.tagActiveId,instrumentId:c.instrumentId,childSelectId:e.childSelectId,musicTagIds:c.musicTagIds})),I()}},null),n("div",{class:l.tags},[n(S,{size:[12,8]},{default:()=>[n("span",{class:l.firstButton},[W("乐器")]),g.getSubjectInstruments.map(t=>t.instruments&&t.instruments.length>1?n(P,{options:t.instruments,trigger:"hover",value:e.tagIndex,"onUpdate:value":[i=>e.tagIndex=i,()=>{c.instrumentId=e.tagIndex,localStorage.setItem("xiaoku-ai-search",JSON.stringify({tagActiveId:e.tagActiveId,instrumentId:e.tagIndex,musicTagIds:c.musicTagIds})),I()}],scrollable:!0,key:t.value,class:[l.popSelect1]},{default:()=>[n(x,{round:!0,textColor:h(t.instruments).selected?"#fff":"#000",color:h(t.instruments).selected?"#198CFE":"rgba(46, 51, 56, .05)",type:h(t.instruments).selected?"primary":"default",class:[l.textBtn,h(t.instruments).selected&&l.textBtnActive]},{default:()=>[h(t.instruments).name||t.name,n("i",{class:l.iconArrow},null)]})]}):n(x,{round:!0,textColor:e.tagIndex===(t.value||0)?"#fff":"#000",color:e.tagIndex===(t.value||0)?"#198CFE":"rgba(46, 51, 56, .05)",type:e.tagIndex===(t.value||0)?"primary":"default",onClick:()=>{e.tagIndex=t.value||0,c.instrumentId=t.value,localStorage.setItem("xiaoku-ai-search",JSON.stringify({tagActiveId:e.tagActiveId,instrumentId:t.value,musicTagIds:c.musicTagIds})),I()}},{default:()=>[t.name]}))]})])]),n(k,{round:!0,onSearch:t=>{c.keyword=t,I()}},null)]),n(O,{show:e.loading},{default:()=>[n("div",{class:[l.content,e.loading?l.loadingContent:""]},[e.list.length>0?e.list.map((t,i)=>n("div",{class:l.itemWrap},[n("div",{class:l.itemWrapBox},[n("div",{class:l.item,key:"item-".concat(i),onClick:()=>{sessionStorage.setItem("musicSubjectList",JSON.stringify(t.subjects)),p.push({path:"/xiaoku-music",query:{id:t.id,name:t.name}})}},[n("div",{class:l.cover},[n("div",{class:l.itemImg},[n("div",{class:l.itemBg},null),n(R,{objectFit:"cover",src:t.coverImg,lazy:!0,previewDisabled:!0,onLoad:a=>{a.target.dataset.loaded="true"}},null)])]),n("div",{class:l.itemName},[t.name])])])])):"",!e.loading&&e.list.length<=0&&n(M,null,null)])]})])}});export{Ie as default};
|