1import{u as re,m as J,q as ce}from"./index-mlzjwNsr.js";import"./[email protected]";import{m as pe}from"./[email protected]";import{d as de,B as ue,v as me,o as fe,x as j,z as _e,O as ge,D as ve,A as D}from"./[email protected]";import{a as k,b as he}from"./[email protected][email protected][email protected]_-CDzk2unA.js";import{d as M,n as ye,v as be,e as ke,P as c,V as Ce,c as w,o as p,a as n,U as we,i as r,H as d,y as v,z as y,F as W,L as q,J as V,I as Ve}from"./@[email protected]";import{u as $e}from"./[email protected][email protected][email protected]_-COb3-BQF.js";import{u as B,m as Se,y as N}from"./@[email protected]_IpifZ0.js";import{p as xe,P as u}from"./@[email protected]_XuvhAE7.js";import{_ as ze}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./@[email protected]";import"./@[email protected][email protected]";import"./@[email protected][email protected]";import"./[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./[email protected]";import"./[email protected]";import"./@[email protected]";import"./[email protected][email protected][email protected][email protected]_-DOOfhHC6.js";import"./[email protected][email protected][email protected]_-BHreiRVx.js";import"./comm-DJc1RYhw.js";import"./@[email protected][email protected][email protected]_-DfOiEg-M.js";import"./[email protected]_@vue_runt_eb61130aa03f824ee7f9227f564849c7-B3eQMo1d.js";import"./[email protected]";import"./[email protected]";import"./[email protected]_nyUt.js";import"./[email protected]";import"./[email protected]";import"./[email protected]";import"./@[email protected][email protected][email protected]_-CkxJgaR_.js";import"./@[email protected][email protected][email protected]_-BOBtmqFR.js";import"./@[email protected]_chPuIy.js";import"./@[email protected]";import"./[email protected]";import"./[email protected]";import"./[email protected]";import"./[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";import"./@[email protected]";const Be={class:"plugins"},Ne={class:"plugins__header"},Oe={class:"plugins__container"},Pe={class:"item"},Ue={class:"item-inner is-add"},We={class:"item"},qe={class:"item-inner"},Ee={key:0,class:"op"},Fe=["onClick"],Le=["onClick"],Te={class:"c"},Ie={class:"det"},Je={class:"tag"},je={class:"title line-clamp-1"},De={class:"desc line-clamp-2"},Me={class:"author"},Re={class:"f"},Ae={class:"plugins__pics"},He={class:"list"},Xe=["onClick"],Ye=["src"],Ge={class:"op"},Ke={class:"flex align-center mb-[10px] select-none"},Qe={class:"mr-[20px]"},Ze={class:"flex align-center"},eo=M({name:"undefined"}),oo=M({...eo,name:"helper-plugins-vue",setup(to){const{router:R,service:$,refs:C,setRefs:O,mitt:E}=re(),A=J.get("helper"),{t:_}=$e(),{install:H}=ce(),m=B({active:"installed",p:"",list:[{label:_("å·²å®è£
"),value:"installed"},{label:_("å
¨é¨æä»¶"),value:"shop"},{label:_("æä»¶å¼å"),value:"dev"}],change(e){m.active=e},onChange(e){e=="dev"?(m.active=m.p||"installed",ye(()=>{window.open("https://cool-js.com/plugin/create")})):(m.p=e,l.refresh())}}),S=be(()=>m.active=="installed"),l=B({installed:[],shop:[],data:null,init(){l.refresh(),E.off("plugin.refresh"),E.on("plugin.refresh",()=>{m.change("installed"),l.refresh()})},remove(e,t){he.confirm(_("ç¡®å®è¦å¸è½½æä»¶ã{name}ãåï¼",{name:e.name}),_("æç¤º"),{type:"warning"}).then(()=>{$.plugin.info.delete({ids:[e.id]}).then(()=>{l.installed.splice(t,1),k.success(_("å¸è½½æå"))}).catch(o=>{k.error(o.message)})}).catch(()=>null)},async doc(e){e.readme?(l.data=e,C.editorPreview.open(await pe.parse(e.readme))):e.doc&&window.open(e.doc)},onEnable(e){e.isVue?$.request({url:"/__cool_updatePlugin",method:"POST",data:{name:e.name,data:e.config,enable:e.status==1},proxy:!1}):$.plugin.info.update({id:e.id,status:e.status?1:0}).then(()=>{k.success(e.status?_("å¯ç¨æå"):_("ç¦ç¨æå"))}).catch(t=>{k.error(t.message)})},keyWord:"",params:{page:1,size:24,isMy:!1},loaded:!1,loading:!1,async refresh(e){if(m.active=="shop"){ue(l.params,e||{});const t={keyWord:l.keyWord||void 0,...l.params};if((l.loaded||l.loading)&&t.page!=1)return;l.loading=!0,await $.request({url:`${A.options.api}/app/plugin/info/page`,method:"POST",data:t}).then(o=>{const a=o.list.map(h=>({...h,label:h.name,name:"",logo:h.avatarUrl,author:h.nickName,doc:`https://cool-js.com/plugin/${h.id}`}));t.page==1?l.shop=a:l.shop.push(...a),l.loaded=l.shop.length>=o.pagination.total,l.params.page=o.pagination.page}).catch(o=>{k.error(o.message)}),l.loading=!1}else $.plugin.info.page({size:1e3}).then(t=>{l.installed=t.list.concat(me(J.list.filter(o=>o.type=="plugins"&&o.label),"order","desc")).map(o=>{o.author=="COOL"&&(o.logo="https://cool-js.com/logo.png");const a=o.type=="plugins";return a?{...o,label:o.label||o.name,status:o.enable===!1?0:1,config:o.options||{},children:o.views,isVue:a}:{...o,logo:"data:image/jpg;base64,"+o.logo,label:o.name,name:o.keyName,config:o.config||{}}}).filter(o=>l.keyWord?o.label.toLocaleLowerCase().includes(l.keyWord.toLocaleLowerCase()):!0)})},onScroll:de(({scrollTop:e})=>{const{clientHeight:t,scrollHeight:o}=C.scrollbar.wrapRef;e+t>=o&&m.active=="shop"&&l.refresh({page:l.params.page+1})},100)}),x=B({insert(e){const t=C.configInput.ref,o=t.selectionStart;t.value=t.value.slice(0,o)+(e||"")+t.value.slice(o)},formatter(){var e;try{return(e=C.config)==null||e.setForm("config",JSON.stringify(JSON.parse(C.config.form.config),null,4)),!0}catch(t){return k.error(_("åæ°æ ¼å¼é误")+"ï¼"+t),!1}},onFileConfirm(e){const t=e.map(a=>a.url),o=t.length>1?JSON.stringify(t):t[0];x.insert(o)},open(e){var t;(t=C.config)==null||t.open({title:_("设置"),form:{id:e.id,config:e.config},items:[{label:_("åæ°"),prop:"config",component:{name:"el-input",props:{type:"textarea",rows:15},ref:O("configInput")}},{component:{name:"slot-tools"}}],on:{open(o){if(o.config||(o.config={}),j(o.config))try{o.config=JSON.parse(o.config)}catch{o.config={}}_e(o.config)&&(o.config=JSON.stringify(o.config)),x.formatter()},submit(o,{done:a,close:h}){if(!x.formatter()){a();return}$.plugin.info.update(o).then(()=>{k.success(_("ä¿®æ¹æå")),fe(e,o),h()}).catch(z=>{k.error(z.message),a()})}}})},close(){var e;(e=C.config)==null||e.close()}}),f=B({visible:!1,title:"",active:0,tabs:[],async open(e){j(e.demo)?ge(e.demo,"http")?window.open(e.demo):R.push(e.demo):(f.visible=!0,f.active=0,f.tabs=[],f.title=e.label,f.tabs=await Promise.all((e.demo||[]).map(async t=>{if(t){const o=await(ve(t.component)?t.component():t.component);return{...t,component:Se(o.default)}}})))},close(){f.visible=!1}}),i=B({visible:!1,show:!1,index:0,list:[],preview(e){i.visible=!0,i.list=e},open(e){i.show=!0,i.index=e},close(){i.visible=!1},onClose(){i.show=!1},prev(){var e;(e=document.querySelector(".plugins__pics .list"))==null||e.scrollBy({left:-500,behavior:"smooth"})},next(){var e;(e=document.querySelector(".plugins__pics .list"))==null||e.scrollBy({left:500,behavior:"smooth"})}});function X(e){return H(e),!1}function Y(e){if(!S.value)return!1;document.querySelectorAll(".plugins .list .item").forEach(o=>{const a=o.getBoundingClientRect(),h=e.clientX-a.left-250,z=e.clientY-a.top-250;e.type!=="scroll"&&requestAnimationFrame(()=>{o.style.setProperty("--x",`${h}px`),o.style.setProperty("--y",`${z}px`)})})}return ke(()=>{l.init()}),(e,t)=>{var T,I;const o=c("cl-select-button"),a=c("cl-svg"),h=c("el-input"),z=c("cl-upload"),F=c("el-col"),G=c("cl-image"),U=c("el-tag"),K=c("cl-switch"),P=c("el-button"),Q=c("el-row"),Z=c("el-empty"),ee=c("el-scrollbar"),oe=c("el-tab-pane"),te=c("el-tabs"),L=c("cl-dialog"),se=c("el-image-viewer"),le=c("cl-editor-preview"),ne=c("cl-upload-space"),ie=c("cl-form"),ae=Ce("loading");return p(),w("div",Be,[n("div",Ne,[r(o,{modelValue:m.active,"onUpdate:modelValue":t[0]||(t[0]=s=>m.active=s),options:m.list,onChange:m.onChange},null,8,["modelValue","options","onChange"]),r(h,{class:"search",modelValue:l.keyWord,"onUpdate:modelValue":t[1]||(t[1]=s=>l.keyWord=s),placeholder:e.$t("æç´¢æä»¶åç§°"),clearable:"",onChange:t[2]||(t[2]=s=>l.refresh({page:1}))},{prefix:d(()=>[r(a,{name:"search",size:16})]),_:1},8,["modelValue","placeholder"])]),we((p(),w("div",Oe,[r(ee,{ref:N(O)("scrollbar"),onScroll:l.onScroll},{default:d(()=>[n("div",{class:xe(["list",{"is-installed":S.value}]),onMousemove:Y},[r(Q,{gutter:10},{default:d(()=>[S.value?(p(),v(F,{key:0,xs:24,sm:12,md:8,lg:6},{default:d(()=>[n("div",Pe,[r(z,{"before-upload":X,accept:".cool"},{default:d(()=>[n("div",Ue,[r(a,{name:"plus"})])]),_:1})])]),_:1})):y("",!0),(p(!0),w(W,null,q(l[m.active],(s,g)=>(p(),v(F,{key:g,xs:24,sm:12,md:8,lg:6},{default:d(()=>[n("div",We,[n("div",qe,[S.value&&!s.isVue?(p(),w("div",Ee,[n("div",{class:"cl-comm__icon is-delete",onClick:b=>l.remove(s,g)},[r(a,{name:"delete"})],8,Fe),n("div",{class:"cl-comm__icon is-set",onClick:b=>
1x.open(s)},[r(a,{name:"set"})],8,Le)])):y("",!0),n("div",Te,[r(G,{class:"mr-[15px]",radius:6,src:s.logo,size:40},null,8,["src"]),n("div",Ie,[n("div",Je,[s.name?(p(),v(U,{key:0,"disable-transitions":"",size:"small",effect:"dark"},{default:d(()=>[V(u(s.name),1)]),_:2},1024)):y("",!0),r(U,{"disable-transitions":"",size:"small",effect:"plain"},{default:d(()=>[V(" v"+u(s.version||"1.0.0"),1)]),_:2},1024),S.value?(p(),v(U,{key:1,"disable-transitions":"",size:"small",effect:"plain",type:s.isVue?"success":"info"},{default:d(()=>[V(u(s.isVue?"Vue":e.$t("å端")),1)]),_:2},1032,["type"])):y("",!0)]),n("p",je,u(s.label||e.$t("æªç¥")),1),n("p",De,u(s.description||e.$t("ææ æè¿°")),1),n("div",Me,[n("span",null,u(s.author||"Ta")+"ï¼",1),n("span",null,u(s.updateTime||"2025-01-01"),1)])])]),n("div",Re,[S.value&&(!s.isVue||s.enable!==void 0)?(p(),v(K,{key:0,modelValue:s.status,"onUpdate:modelValue":b=>s.status=b,onChange:b=>l.onEnable(s)},null,8,["modelValue","onUpdate:modelValue","onChange"])):y("",!0),t[9]||(t[9]=n("span",{class:"mr-auto"},null,-1)),s.demo?(p(),v(P,{key:1,type:"success",onClick:b=>f.open(s)},{default:d(()=>[V(u(e.$t("示ä¾")),1)]),_:2},1032,["onClick"])):y("",!0),N(D)(s.pics)?y("",!0):(p(),v(P,{key:2,type:"success",onClick:b=>i.preview(s.pics)},{default:d(()=>[V(u(e.$t("é¢è§")),1)]),_:2},1032,["onClick"])),s.doc||s.readme?(p(),v(P,{key:3,onClick:b=>l.doc(s)},{default:d(()=>[V(u(e.$t("ææ¡£")),1)]),_:2},1032,["onClick"])):y("",!0)])])])]),_:2},1024))),128))]),_:1})],34),N(D)(l[m.active])?(p(),v(Z,{key:0,"image-size":80})):y("",!0)]),_:1},8,["onScroll"])])),[[ae,l.loading]]),r(L,{modelValue:f.visible,"onUpdate:modelValue":t[4]||(t[4]=s=>f.visible=s),title:f.title,width:"60%"},{default:d(()=>[r(te,{modelValue:f.active,"onUpdate:modelValue":t[3]||(t[3]=s=>f.active=s),type:"card"},{default:d(()=>[(p(!0),w(W,null,q(f.tabs,(s,g)=>(p(),v(oe,{key:g,label:s.name,name:g,lazy:g!=0},{default:d(()=>[(p(),v(Ve(s.component)))]),_:2},1032,["label","name","lazy"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["modelValue","title"]),r(L,{modelValue:i.visible,"onUpdate:modelValue":t[8]||(t[8]=s=>i.visible=s),title:e.$t("å¾çé¢è§"),width:"80%",padding:"0","hide-header":"",transparent:""},{default:d(()=>[n("div",Ae,[n("div",{class:"close",onClick:t[5]||(t[5]=(...s)=>i.close&&i.close(...s))},[r(a,{name:"close"})]),n("div",He,[(p(!0),w(W,null,q(i.list,(s,g)=>(p(),w("div",{class:"item",key:g,onClick:b=>i.open(g)},[n("img",{src:s},null,8,Ye)],8,Xe))),128))]),n("div",Ge,[n("div",{class:"prev",onClick:t[6]||(t[6]=(...s)=>i.prev&&i.prev(...s))},[r(a,{name:"left"})]),n("div",{class:"next",onClick:t[7]||(t[7]=(...s)=>i.next&&i.next(...s))},[r(a,{name:"right"})])])]),i.visible&&i.show?(p(),v(se,{key:0,"url-list":i.list,infinite:"","initial-index":i.index,teleported:"",onClose:i.onClose},null,8,["url-list","initial-index","onClose"])):y("",!0)]),_:1},8,["modelValue","title"]),r(le,{ref:N(O)("editorPreview"),name:"wang","show-btn":!1,title:`${(T=l.data)==null?void 0:T.name}ï¼v${(I=l.data)==null?void 0:I.version}ï¼${e.$t("è¯´æææ¡£")}`},{prepend:d(()=>{var s,g;return[n("div",Ke,[n("span",Qe,u(e.$t("ä½è
"))+"ï¼"+u((s=l.data)==null?void 0:s.author),1),n("span",null,u(e.$t("æ´æ°æ¶é´"))+"ï¼"+u((g=l.data)==null?void 0:g.updateTime),1)])]}),_:1},8,["title"]),r(ie,{ref:N(O)("config")},{"slot-tools":d(()=>[n("div",Ze,[r(P,{type:"success",onClick:x.formatter},{default:d(()=>[V(u(e.$t("æ ¼å¼å")),1)]),_:1},8,["onClick"]),r(ne,{"show-list":!1,text:e.$t("æå
¥æä»¶é¾æ¥"),onConfirm:x.onFileConfirm},null,8,["text","onConfirm"])])]),_:1},512)])}}}),Qo=ze(oo,[["__scopeId","data-v-1f56c759"]]);export{Qo as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.