File: /www/server/panel/BTPanel/static/js/index544.js
import{k as P,jB as ae,M as y,X as se,c7 as le,jC as oe,w as re,jD as ne,cZ as G,jE as O,e as ue,_ as ie,jF as Z,hK as pe,cP as ce,cR as me}from"./utils-lib.js?v=1777008528";import{c as L,r as x,g as W,e as r,z as J,x as A,j as C,k,p,q as F,F as K,B as Q,s as I,o as X,v as E,y as T,I as de,J as fe,C as R,L as _e,Q as q,U as ve,ay as ge,aA as he,D as be,aE as Y,aG as Ce,a8 as Fe}from"./base-lib.js?v=1777008528";import{s as V,t as H}from"./index32.js?v=1777008528";import{F as S,g as N,d as xe}from"./form-item.js?v=1777008528";import{a9 as ye}from"./index3.js?v=1777008528";import"./file-icon.js?v=1777008528";import{F as ke}from"./files-path.js?v=1777008528";import"./__commonjsHelpers__.js?v=1777008528";import"./useStore5.js?v=1777008528";import"./index116.js?v=1777008528";import"./useMethods.js?v=1777008528";import"./vue-virtual-scroller.esm.js?v=1777008528";import"./vue-virtual-scroller.js?v=1777008528";import"./useController20.js?v=1777008528";import"./useController19.js?v=1777008528";import"./site.js?v=1777008528";import"./useStore2.js?v=1777008528";import"./useController13.js?v=1777008528";import"./index119.js?v=1777008528";import"./useMethod12.js?v=1777008528";import"./index192.js?v=1777008528";import"./index.vue_vue_type_style_index_0_lang.js?v=1777008528";import"./add-host.vue_vue_type_script_setup_true_lang.js?v=1777008528";import"./useController3.js?v=1777008528";import"./marked.esm.js?v=1777008528";import"./index130.js?v=1777008528";import"./ace.js?v=1777008528";const{isSaveGitConfig:Be}=V(),Ee=async c=>{const{git_url:m,git_branch:a,password:n,name:o}=c.value;P({request:ae({git_url:m,git_branch:a,password:n,name:o}),loading:"正在保存git配置...",message:!0,success:t=>{if(!t.status)return y.error(t.msg||"保存git配置失败");Be.value=!0,y.success("保存git配置成功")}})},Ae={class:"app-import-git-container"},we=L({__name:"git-import",setup(c,{expose:m}){const{apphubGitConfig:a,isSaveGitConfig:n,usingHelpLink:o}=V(),t=x(!1),{BtForm:_,submit:u,param:s}=se({data:a.value||{},options:i=>W(()=>[S("Git地址","git_url",{attrs:{class:"!w-[44rem]",placeholder:"请输入Git地址"},rules:[{required:!0,message:"Git地址不能为空"}]}),S("分支","git_branch",{attrs:{class:"!w-[44rem]",placeholder:"请输入Git分支"},rules:[{required:!0,message:"分支不能为空"}]}),N(" ",()=>r("div",null,[r("span",{class:"text-primary cursor-pointer text-small flex items-center",onClick:()=>t.value=!t.value},[t.value?"更多设置,点击收起":"更多设置,点击查看",r("i",{class:"ml-2 ".concat(t.value?"svgtofont-el-arrow-up":"svgtofont-el-arrow-down")},null)])]),""),...t.value?[S("用户名(可选)","name",{attrs:{class:"!w-[44rem]",placeholder:"如果是私有仓库请输入用户名",onInput:()=>{s.value.user=i.value.user}}}),S("访问令牌(可选)","password",{attrs:{class:"!w-[44rem]",placeholder:"如果是私有仓库请输入访问令牌",showPassword:!0,onInput:()=>{s.value.password=i.value.password}}})]:[],N(" ",()=>r("div",null,[r(J,{type:"default",onClick:()=>Ee(s)},{default:()=>[A("保存配置")]})]),""),xe(" ",[{content:r("span",null,[A("使用帮助:如果您在导入应用的过程中遇到问题,请点击 "),r(le,{href:o.value},{default:()=>["使用教程"]})])},{content:r("span",{class:"text-red-500"},[A("安全提醒:请甄别导入应用的安全性,否则将存在安全风险!")])}])]),submit:async(i,d,v)=>{const g=y.load("正在导入应用,请稍后...");try{if(await d(),!n.value)return y.error("导入失败,请先保存git配置"),!1;const h=await oe();return!h.status&&h.msg=="缺少git环境,请先安装git"?(g==null||g.close(),await re({title:"提示",content:"缺少git环境,是否进行安装?",icon:"warning-filled",confirmText:"安装"}),await P({request:ne(),loading:"正在安装环境,请稍后...",message:!0}),!1):h.status?(y.success("导入成功"),H(!0),h.status):(y.error(h.msg||"导入失败"),!1)}catch(h){return!1}finally{g==null||g.close()}}});return m({onConfirm:u}),(i,d)=>(C(),k("div",Ae,[r(p(_))]))}}),$e=G(we,[["__scopeId","data-v-a05669d6"]]),De={class:"app-import-check-list"},ze={class:"max-h-[32rem] overflow-auto pr-2"},Le={class:"flex flex-col justify-center text-small leading-[1.2]"},Ie={class:"mb-3 font-bold"},Pe={class:"mb-2 text-gray-400 break-all leading-[1.5]"},Ge={class:"text-gray-400"},Ue=L({__name:"app-import-check-list",props:{list:{}},setup(c){const m=c,a=W(()=>m.list.map(n=>({appid:n.appid,apptitle:n.apptitle,appdesc:n.appdesc,appversion:n.appversion[0].m_version||""})));return(n,o)=>(C(),k("div",De,[o[0]||(o[0]=F("div",{class:"flex items-center mb-2 text-small justify-between"},[F("div",null,"应用列表")],-1)),F("div",ze,[(C(!0),k(K,null,Q(p(a),t=>(C(),k("div",{key:t.appid,class:"flex items-center p-[1rem] mb-4 rounded-xl bg-white border border-gray-200 transition-all w-full hover:border-[rgba(var(--el-color-primary-rgb),0.8)]"},[F("div",Le,[F("div",Ie,I(t.apptitle),1),F("div",Pe,I(t.appdesc),1),F("div",Ge,"版本:"+I(t.appversion),1)])]))),128))])]))}}),ee=G(Ue,[["__scopeId","data-v-89819a0e"]]),Re=()=>{const c=x([]),m=x([]),a=async()=>{const t=await ye({path:"/tmp/apphub"}),_=["zip","tar","gz","tar.gz","tgz","rar","7z","bz2","war"],u=(t.data.files||[]).filter(s=>{if(!s.nm)return!1;const i=s.nm.toLowerCase();return _.some(d=>i.endsWith("."+d))}).map(s=>"/tmp/apphub/".concat(s.nm));c.value=u,u.length?await P({request:O({sfile:u}),loading:"正在获取应用列表,请稍后...",success:s=>{const i=s.data.data||[];let d=[];i.forEach((v,g)=>{(Array.isArray(v)?v:[v]).forEach(w=>{d.push({...w,appdesc:w.parser_from?"从上传文件解析:".concat(w.parser_from):w.appdesc||"",sfile:u[g]})})}),m.value=d}}):m.value=[]};return{fileList:c,appList:m,onConfirm:async()=>{if(!m.value.length)return y.error("应用列表为空,请上传文件"),!1;const t=await P({request:Z({sfile:c.value}),loading:"正在导入应用,请稍后...",message:!0});return t.status?(H(!0),!0):(y.error((t==null?void 0:t.msg)||"导入失败"),!1)},openFilesUpload:async()=>{await ue({title:"上传文件到【/tmp/apphub】",area:72,component:()=>ie(()=>import("./index424.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{path:"/tmp/apphub"},onCancel:async()=>{await a()}})},getApphubFiles:a}},Se=()=>{const c=x("/tmp/apphub"),m=x([]),a=x([]),n=x(!1),o=x([]),t=x([]),_=e=>e&&e.isFile&&/\.(zip|tar|gz|tar\.gz|tgz|rar)$/i.test(e.name),u=e=>a.value.some(l=>l.fullpath===e.fullpath),s=async e=>{var $;if(!_(e))return;const l=a.value.findIndex(b=>b.fullpath===e.fullpath);if(l>-1)a.value.splice(l,1),o.value=o.value.filter(b=>b.fullpath!==e.fullpath);else{const b=y.load("正在解析文件中,请稍后..."),D=await O({sfile:e.fullpath}),B=Array.isArray(D.data)?D.data:(($=D.data)==null?void 0:$.data)||[];if(!B.length||typeof B[0]!="object"||B[0]===null||!("appid"in B[0])&&!("appname"in B[0])){y.error("解析失败,无法从该压缩包文件中获取应用信息"),b.close();return}b.close(),B.forEach(z=>{const f=z.parser_from||e.fullpath;o.value.push({...z,fullpath:f,appdesc:"从服务器文件解析:".concat(f)})}),a.value.push(e)}t.value=o.value.map(b=>b.appid)},i=e=>e.isDir?"icon-bg folder-icon":["zip","rar","7z","gz","tar.gz","tgz","war"].includes(e.ext)?"icon-bg compress-icon":"icon-bg file-icon",d=(e,l=!1,$="")=>{const[b,D,B,z,f]=e.split(";"),U=l?(b.split(".").pop()||"").toLowerCase():"",te=$.endsWith("/")?$+b:$+"/"+b;return{name:b,mtime:D,size:B,perm:z,owner:f,isFile:l,isDir:!l,ext:U,fullpath:te}},v=async()=>{n.value=!0;const e=await pe({path:c.value,disk:!1});e.data.PATH&&c.value!==e.data.PATH&&(c.value=e.data.PATH),m.value=[...(e.data.DIR||[]).map(l=>d(l,!1,c.value)),...(e.data.FILES||[]).map(l=>d(l,!0,c.value))],n.value=!1},g=e=>{a.value=a.value.filter(l=>l.fullpath!==e.fullpath),o.value=o.value.filter(l=>l.fullpath!==e.fullpath),t.value=o.value.map(l=>l.appid)},h=e=>{c.value=e,v()},w=()=>{v()},j=e=>{if(e.isDir){let l=c.value.replace(/\/$/,"");l===""&&(l="/"),c.value=l==="/"?"/".concat(e.name):"".concat(l,"/").concat(e.name),v()}};return X(()=>{v()}),{currentPath:c,fileList:m,selectedFiles:a,loading:n,parsedAppList:o,selectedApps:t,isSelectable:_,isChecked:u,toggleSelection:s,getIconClass:i,removeFile:g,handlePathChange:h,refresh:w,enterDir:j,onConfirm:async()=>{if(!o.value.length)return y.error("请选择要导入的文件"),!1;const e=await P({request:Z({sfile:a.value.map(l=>l.fullpath)}),loading:"正在导入应用,请稍后...",message:!0});return e.status?(H(!0),!0):(y.error((e==null?void 0:e.msg)||"导入失败"),!1)}}},Te={class:"docker-app-import-files-local-upload"},Ve={class:"flex items-center mb-6"},je={key:0},qe=L({__name:"local-upload",setup(c,{expose:m}){const{appList:a,onConfirm:n,openFilesUpload:o,getApphubFiles:t}=Re();return X(t),m({onConfirm:n}),(_,u)=>{const s=J;return C(),k("div",Te,[F("div",Ve,[r(s,{type:"primary",onClick:p(o)},{default:E(()=>[...u[0]||(u[0]=[A("上传文件",-1)])]),_:1},8,["onClick"]),u[1]||(u[1]=F("span",{class:"flex items-center text-small text-gray-400 ml-4"},[F("i",{class:"svgtofont-el-warning-filled mr-1 mt-[2px]"}),F("span",null,"支持 .zip, .tar.gz,.gz 格式")],-1))]),p(a).length?(C(),k("div",je,[r(ee,{list:p(a)},null,8,["list"])])):T("",!0)])}}}),He=G(qe,[["__scopeId","data-v-a6c581f7"]]),Me={class:"docker-import-server-upload-container"},Ne={class:"flex items-center justify-between px-2 w-full"},Oe=["onClick"],Ze={key:0,class:"mt-4 mb-4"},We=L({__name:"server-upload",setup(c,{expose:m}){const{currentPath:a,fileList:n,selectedFiles:o,loading:t,parsedAppList:_,selectedApps:u,isSelectable:s,isChecked:i,toggleSelection:d,getIconClass:v,removeFile:g,handlePathChange:h,refresh:w,enterDir:j,onConfirm:M}=Se();return m({onConfirm:M}),(e,l)=>{const $=ve,b=ge,D=he,B=be,z=de("bt-loading");return C(),k("div",Me,[r(ke,{initialPath:p(a),onPathChange:p(h),onRefresh:p(w),class:"mb-6"},null,8,["initialPath","onPathChange","onRefresh"]),fe((C(),R(D,{data:p(n),"row-key":f=>f.name,"show-header":!1,height:"300",class:"server-upload-table"},{default:E(()=>[r(b,null,{default:E(({row:f})=>[F("div",Ne,[F("span",{onClick:U=>f.isDir&&p(j)(f),class:"flex items-center gap-2 cursor-pointer file-row files-list"},[F("i",{class:_e(p(v)(f))},null,2),A(" "+I(f.name),1)],8,Oe),p(s)(f)?(C(),R($,{key:0,"model-value":p(i)(f),onChange:U=>p(d)(f)},null,8,["model-value","onChange"])):T("",!0)])]),_:1})]),_:1},8,["data","row-key"])),[[z,p(t)]]),p(o).length?(C(),k("div",Ze,[l[1]||(l[1]=F("div",{class:"mb-3"},"已选择的文件:",-1)),(C(!0),k(K,null,Q(p(o),f=>(C(),R(B,{key:f.name,closable:"",onClose:U=>p(g)(f),class:"mr-2 mb-2"},{default:E(()=>[A(I(f.name),1)]),_:2},1032,["onClose"]))),128))])):T("",!0),p(_).length?(C(),R(ee,{key:1,list:p(_),modelValue:p(u),"onUpdate:modelValue":l[0]||(l[0]=f=>q(u)?u.value=f:null)},null,8,["list","modelValue"])):T("",!0)])}}}),Je=G(We,[["__scopeId","data-v-fb6693f3"]]),Ke={class:"docker-app-import-files-container"},Qe=L({__name:"index",setup(c,{expose:m}){const{usingHelpLink:a}=V(),n=x("upload"),o=x(),t=x(),_=[{content:()=>r("span",null,[A("使用帮助:如果您在导入应用的过程中遇到问题,请点击")," ",r("a",{class:"bt-link text-blue-500",href:a.value,target:"_blank"},[A("使用教程")])])},{content:()=>r("span",{class:"text-red-500"},[A("安全提醒:请甄别导入应用的安全性,否则将存在安全风险!")])}];function u(){var s,i,d,v,g,h;return n.value==="upload"?(d=(i=(s=o.value)==null?void 0:s.onConfirm)==null?void 0:i.call(s))!=null?d:Promise.reject(!1):(h=(g=(v=t.value)==null?void 0:v.onConfirm)==null?void 0:g.call(v))!=null?h:Promise.reject(!1)}return m({onConfirm:u}),(s,i)=>{const d=Y,v=Ce,g=ce;return C(),k("div",Ke,[r(v,{modelValue:p(n),"onUpdate:modelValue":i[0]||(i[0]=h=>q(n)?n.value=h:null),class:"mb-4"},{default:E(()=>[r(d,{label:"上传文件",name:"upload"},{default:E(()=>[r(He,{ref_key:"localUploadRef",ref:o},null,512)]),_:1}),r(d,{lazy:"",label:"服务器目录",name:"server"},{default:E(()=>[r(Je,{ref_key:"serverUploadRef",ref:t},null,512)]),_:1})]),_:1},8,["modelValue"]),r(g,{options:_,class:"text-small text-gray-500"})])}}}),Xe=G(Qe,[["__scopeId","data-v-4f58130d"]]),Ye={class:"p-2rem app-import-container"},At=L({__name:"index",setup(c,{expose:m}){const{activeTabs:a,isSaveGitConfig:n}=V(),o=x(),t=x();return m({onConfirm:()=>{var _,u,s,i;if(a.value==="git")return(u=(_=o.value)==null?void 0:_.onConfirm)==null?void 0:u.call(_);if(a.value==="files")return(i=(s=t.value)==null?void 0:s.onConfirm)==null?void 0:i.call(s)}}),Fe(()=>{n.value=!1}),(_,u)=>{const s=Y,i=me;return C(),k("div",Ye,[r(i,{modelValue:p(a),"onUpdate:modelValue":u[0]||(u[0]=d=>q(a)?a.value=d:null)},{default:E(()=>[r(s,{label:"从GIT导入",name:"git"},{default:E(()=>[r($e,{ref_key:"gitImportRef",ref:o},null,512)]),_:1}),r(s,{lazy:"",label:"从文件导入",name:"files"},{default:E(()=>[r(Xe,{ref_key:"filesImportRef",ref:t},null,512)]),_:1})]),_:1},8,["modelValue"])])}}});export{At as default};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = []
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}