import{n as h,a8 as d}from"./index-b54f5418.js";import{J as v}from"./index-cf27e902.js";import"./three-dc46505d.js";var y=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("div",{staticClass:"headerOperation-container"},[t("div",{staticClass:"operate-history"},[t("vis-icon",{attrs:{code:"#iconbianjiantouzuo"},nativeOn:{click:function(i){return(function(){e.$store.commit("componentLibrary/backOffHistory")}).apply(null,arguments)}}}),t("vis-icon",{attrs:{code:"#iconbianjiantouyou"},nativeOn:{click:function(i){return(function(){e.$store.commit("componentLibrary/forwardHistory")}).apply(null,arguments)}}})],1),t("div",{staticClass:"operate-address"},e._l(e.addressList,function(i,l){return t("span",{key:l,staticClass:"address-sign-box",on:{click:function(a){return e.chouseFile(i)}}},[l>0?t("vis-icon",{style:{transform:"scale(0.6)"},attrs:{code:"#iconsanjiaojiantouyou"}}):e._e(),t("span",{staticClass:"address-title",domProps:{textContent:e._s(i.name)}})],1)}),0),t("div",{staticClass:"operate-operation"},[t("el-popover",{attrs:{placement:"bottom",width:"200",trigger:"click"},model:{value:e.classifyVisible,callback:function(i){e.classifyVisible=i},expression:"classifyVisible"}},[t("el-input",{staticClass:"popover-input",attrs:{size:"mini",placeholder:"输入分类名称"},model:{value:e.classifyName,callback:function(i){e.classifyName=i},expression:"classifyName"}}),t("div",{staticClass:"popover-operation"},[t("el-button",{attrs:{size:"mini",type:"text"},on:{click:e.addClassify}},[e._v(" 确定 ")])],1),e.canAddClassify?t("vis-icon",{directives:[{name:"tooltip",rawName:"v-tooltip.top",value:"新增分类",expression:"'新增分类'",modifiers:{top:!0}}],attrs:{slot:"reference",code:"#iconjia1"},slot:"reference"}):e._e()],1),e.canUpload?t("vis-icon",{directives:[{name:"tooltip",rawName:"v-tooltip.top",value:"上传UI组件zip压缩包，包含index.js入口文件，package.json包描述文件，preview.png预览图片",expression:`
        '上传UI组件zip压缩包，包含index.js入口文件，package.json包描述文件，preview.png预览图片'
      `,modifiers:{top:!0}}],attrs:{code:"#iconshangchuan-fill"},nativeOn:{click:function(i){return e.upload.apply(null,arguments)}}}):e._e(),t("input",{ref:"uploadInput",staticStyle:{display:"none"},attrs:{type:"file",accept:".zip, .tgz"},on:{change:e.fileHandler}})],1)])},g=[];const _={data(){return{classifyName:"",classifyVisible:!1}},computed:{currentFloder(){return this.$store.getters["componentLibrary/currentFloder"]},canUpload(){const e=this.currentFloder.children;return this.currentFloder.parent?e.length&&!e[0].dir?!0:!e.length&&this.currentFloder.url!=="/":!1},canAddClassify(){const e=this.currentFloder.children;return e.length&&e[0].dir?!0:!e.length},addressList(){const e=[this.currentFloder],s=t=>{t.parent&&(e.unshift(t.parent),s(t.parent))};return s(this.currentFloder),e}},methods:{chouseFile(e){e.dir&&this.$store.commit("componentLibrary/currentFloder",e)},upload(){this.$tool.safeTips().then(()=>{this.$refs.uploadInput.click()})},async fileHandler(e){const s=e.target.files[0],t=this.currentFloder.id,a=(await new v().loadAsync(s)).files;if(!a["package.json"]){this.$message.warning("上传失败！找不到配置文件：package.json"),this.$refs.uploadInput.value="";return}const c=JSON.parse(await a["package.json"].async("string"));let n=c.module||c.main;if(!n){this.$message.warning("上传失败！无法从package.json中获取有效的入口路径。"),this.$refs.uploadInput.value="";return}if(n.startsWith("/")?n=n.slice(1):n.startsWith("./")&&(n=n.slice(2)),!a[n]){this.$message.warning("上传失败！无法根据package.json的相关字段获取入口文件。"),this.$refs.uploadInput.value="";return}let o=a[n];o=await o.async("string"),o=new Blob([o],{type:"application/javascript"});const m=["jpg","png","jpeg"];let p;for(const r of m)a[`preview.${r}`]&&(p=`data:image/${r};base64,`+await a[`preview.${r}`].async("base64"));d.uploadComponent({classifyId:t,name:s.name.split(".").shift(),component:o,pkg:c,preview:p,size:Object.values(a).reduce((r,u)=>u.dir?r:r+u._data.uncompressedSize,0)}).then(r=>{this.$store.commit("componentLibrary/addChildren",r)}).finally(()=>{this.$refs.uploadInput.value=""})},addClassify(){this.classifyName.trim()?d.addClassify({name:this.classifyName.trim(),parentId:this.currentFloder.id}).then(e=>{this.$store.commit("componentLibrary/addChildren",e),this.classifyName="",this.classifyVisible=!1,this.$message.success("添加分类成功！")}):(this.classifyName="",this.classifyVisible=!1)}}},f={};var b=h(_,y,g,!1,$,"27aef5d8",null,null);function $(e){for(let s in f)this[s]=f[s]}const w=function(){return b.exports}();export{w as default};
