import{i as R}from"./echarts.72dc8373.js";import{a as U}from"./api.2785c8dc.js";import{_ as W}from"./index.vue_vue_type_script_setup_true_lang.3fa6db13.js";import{d as x,E as A}from"./elementPlus.4833989a.js";/* empty css                   */import{d as I,r as i,j as F,A as $,ai as h,aq as q,P as K,o as d,c as w,a as c,U as z,F as L,a8 as T,M as C,O as D,T as N,J as G,aF as J,aG as P}from"./vue.adf17aba.js";import{_ as H}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.ad3efb29.js";const Q=n=>(J("data-v-340c2de0"),n=n(),P(),n),X={class:"flex justify-between items-center mb-4"},Z=Q(()=>c("span",{class:"my-4 mx-1.5",style:{"font-size":"18px","font-weight":"bold",color:"#464646"}},"谷歌关键词趋势",-1)),ee={class:"keyword-select"},te={style:{"font-weight":"bold","font-size":"13px"}},ae=I({__name:"keywordTrendsChart",props:{keywordList:{}},setup(n){const u=i([x().subtract(2,"week").startOf("day").format("YYYY-MM-DD"),x().subtract(1,"week").endOf("day").format("YYYY-MM-DD")]),{keywordList:S}=n,a=i(S.slice(0,5)),g=["#0098ed","#229b32","#35e6ee","#ff4a4c","#f8cb4b"];let o;const b=i(null),_=i(!1),V=i([]);F(()=>{M(),v()}),$(()=>{o&&(o.dispose(),o=null),j()});const p={dataset:{source:[]},tooltip:{trigger:"axis"},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0},xAxis:{type:"category"},yAxis:{type:"value",show:!0,splitLine:{show:!0},axisLine:{show:!0,lineStyle:{color:"#0090e4"}}},series:[{id:0,name:"1",type:"line",stack:"Total",data:[]},{id:1,name:"2",type:"line",stack:"Total",data:[]},{id:2,name:"",type:"line",stack:"Total",data:[]},{id:3,name:"",type:"line",stack:"Total",data:[]},{id:4,name:"",type:"line",stack:"Total",data:[]}]};async function v(){await Y(),o=R(b.value),p.dataset.source=V.value,o.setOption(p,!0)}async function Y(){try{_.value=!0;const s={keyword:a.value.join(","),date_start:u.value[0],date_end:u.value[1]},l=(await U(s)).data;p.xAxis.data=l.date,p.series=a.value.map((r,m)=>({id:m,name:r,type:"line",data:l[r],itemStyle:{color:g[m]}}))}catch{A.error("加载数据失败，请稍后再试")}finally{_.value=!1}}function k(){o.resize()}function M(){window.addEventListener("resize",k)}function j(){window.removeEventListener("resize",k)}function B(s){return 50+s.length*10+15}return(s,e)=>{const l=h("el-option"),r=h("el-tag"),m=h("el-select"),E=q("loading");return K((d(),w("div",null,[c("div",X,[Z,z(W,{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=f=>u.value=f),onChange:e[1]||(e[1]=f=>v())},null,8,["modelValue"])]),c("div",ee,[(d(!0),w(L,null,T(a.value,(f,y)=>(d(),C(m,{key:y,modelValue:a.value[y],"onUpdate:modelValue":t=>a.value[y]=t,onChange:e[2]||(e[2]=t=>v()),style:G({width:B(f)+"px",border:"none","box-shadow":"none"})},{label:D(({label:t,value:O})=>[z(r,{color:g[y],size:"small"},null,8,["color"]),c("span",te,N(O),1)]),default:D(()=>[(d(!0),w(L,null,T(s.keywordList,t=>(d(),C(l,{key:t,disabled:a.value.includes(t),label:t,value:t},null,8,["disabled","label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","style"]))),128))]),c("div",{ref_key:"chartRef",ref:b,style:{height:"350px"}},null,512)])),[[E,_.value]])}}});const ue=H(ae,[["__scopeId","data-v-340c2de0"]]);export{ue as default};
