2 lines
9.6 KiB
JavaScript
2 lines
9.6 KiB
JavaScript
import{_ as K}from"./index-DIKmrNCq.js?v=1773287522785";import{_ as L}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{u as O}from"./useLoading-CZ2gSAW7.js?v=1773287522785";import{u as V,v as j}from"./index-CpV61Xte.js?v=1773287522785";import{k as x,a6 as J,c as Z,R as z,r as D,e as M,$ as m,Z as _,a0 as o,a9 as s,S as r,j as y,aa as i,F as g,ak as w,a8 as W,_ as f}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{t as G,h as Q,j as X}from"./index-B1UAKxq5.js?v=1773287522785";import{a1 as Y,b as ee,a3 as te,ag as ae,k as oe,_ as re,B as se,a6 as le}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./index-BTglIPU2.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-DgjjuUjT.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-B7YvCBmY.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-C5hb-Th7.js?v=1773287522785";import"./data-BVsViUMm.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-HxsqzSKU.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-BeO8Hyma.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-D2Bk83Ev.js?v=1773287522785";import"./useTableData-BmkIKQ_R.js?v=1773287522785";import"./useTableColumns-DDeyYvje.js?v=1773287522785";import"./index-S15tYq5l.js?v=1773287522785";import"./copy-D-wIKr0q.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-DeTfbeeM.js?v=1773287522785";import"./index-Cg6fMjw6.js?v=1773287522785";import"./index-BGYvyLDv.js?v=1773287522785";import"./index-DhzSj-2g.js?v=1773287522785";import"./xterm-dpUsuiNl.js?v=1773287522785";import"./useSocket-DTHwGZgK.js?v=1773287522785";import"./xterm-addon-canvas-DELv9KNm.js?v=1773287522785";const ne={class:"p-20px"},pe=["textContent"],Ke=x({__name:"index",props:{row:{type:Object,default:()=>({})},onRefresh:{type:Function,default:()=>{}}},setup(P,{expose:I}){const E=V(),{categoryList:C}=J(E),N=Z(()=>C.value.filter(t=>t.value!=="")),{t:u}=z(),n=P,c=D(null),e=M({name:"",type:"api",group_id:0,url:"",key:"",host:"",port:22,ssh_type:"password",password:"",private_key:"",private_key_password:""}),U={name:{required:!0,message:u("Enter node name"),trigger:"blur"},url:[{required:!0,message:u("Panel address cannot be empty"),trigger:["blur","input"]},{validator:(t,a)=>{if(!a)return!0;if(e.url=e.url.trim(),/^(https?):\/\/(?:(?:[\w-]+\.)+[a-zA-Z]{2,}|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|(?:\[(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}|:(?::[0-9a-fA-F]{1,4}){1,7}|:(?::[0-9a-fA-F]{1,4}){1,6}:|(?:[0-9a-fA-F]{1,4}:){1,6}:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\])(?::\d{1,5})?(?:\/.*)?$/.test(e.url)){const p=new URL(e.url);return e.url=p.origin,!0}return new Error(u("Invalid panel address format"))},trigger:"blur"}],key:{required:!0,message:u("Enter API key"),trigger:"blur"},host:{required:!0,trigger:"blur",validator:(t,a)=>!a||j(a)?!0:new Error(u("Invalid IP address format"))},port:{required:!0,message:u("Enter SSH port"),trigger:"blur",type:"number"},password:{required:!0,message:u("Enter SSH password"),trigger:"blur"},private_key:{required:!0,message:u("Enter SSH key"),trigger:"blur"}},{loading:h,setLoading:b}=O(),H=()=>({host:e.host,port:e.port,test_case:1,pkey:e.ssh_type==="key"?e.private_key:"",pkey_passwd:e.ssh_type==="key"?e.private_key_password:"",password:e.ssh_type==="password"?e.password:""}),$=async()=>{var t;try{b(!0),await((t=c.value)==null?void 0:t.validate()),await G(H())}finally{b(!1)}},S=()=>e.type==="api"?{remarks:e.name,address:e.url,api_key:e.key,category_id:e.group_id||0}:{remarks:e.name,ssh_conf:e.ssh_type==="password"?JSON.stringify({host:e.host,port:e.port,password:e.password}):JSON.stringify({host:e.host,port:e.port,pkey:e.private_key,pkey_passwd:e.private_key_password}),category_id:e.group_id||0};return I({onConfirm:async()=>{var t;await((t=c.value)==null?void 0:t.validate()),n.row&&n.row.id?await Q({id:n.row.id,...S()}):await X(S()),n.onRefresh()}}),n.row&&n.row.id&&(e.name=n.row.remarks,e.type=Object.keys(n.row.ssh_conf).length>0?"ssh":"api",e.group_id=n.row.category_id,e.url=n.row.address,e.key=n.row.api_key,e.host=n.row.ssh_conf.host,e.port=n.row.ssh_conf.port,e.ssh_type=n.row.ssh_conf.password?"password":"key",e.password=n.row.ssh_conf.password,e.private_key=n.row.ssh_conf.pkey,e.private_key_password=n.row.ssh_conf.pkey_passwd),(t,a)=>{const d=ee,p=Y,v=ae,A=te,R=re,k=oe,F=se,T=le,q=L,B=K;return m(),_("div",ne,[o(q,{ref_key:"formRef",ref:c,model:r(e),rules:U},{default:s(()=>[o(p,{label:t.$t("Node Name"),path:"name"},{default:s(()=>[o(d,{class:"w-350px!",value:r(e).name,"onUpdate:value":a[0]||(a[0]=l=>r(e).name=l),placeholder:t.$t("Enter node name")},null,8,["value","placeholder"])]),_:1},8,["label"]),o(p,{label:t.$t("Verification Type"),path:"type"},{default:s(()=>[o(A,{value:r(e).type,"onUpdate:value":a[1]||(a[1]=l=>r(e).type=l),type:"button"},{default:s(()=>[o(v,{value:"api"},{default:s(()=>[y(i(t.$t("API Key")),1)]),_:1}),o(v,{value:"ssh"},{default:s(()=>a[11]||(a[11]=[y("SSH")])),_:1,__:[11]})]),_:1},8,["value"])]),_:1},8,["label"]),r(e).type==="api"?(m(),_(g,{key:0},[o(p,{label:t.$t("Panel Address"),path:"url"},{default:s(()=>[o(d,{class:"w-350px!",value:r(e).url,"onUpdate:value":a[2]||(a[2]=l=>r(e).url=l),placeholder:"Example: http://192.168.1.1:88 or https://domain.com:88"},null,8,["value"])]),_:1},8,["label"]),o(p,{label:t.$t("API Key"),path:"key"},{default:s(()=>[o(d,{class:"w-350px!",value:r(e).key,"onUpdate:value":a[3]||(a[3]=l=>r(e).key=l),placeholder:t.$t("Enter API key")},null,8,["value","placeholder"])]),_:1},8,["label"])],64)):w("",!0),r(e).type==="ssh"?(m(),_(g,{key:1},[o(k,{class:"flex-nowrap!"},{default:s(()=>[o(p,{label:t.$t("Node IP"),path:"host"},{default:s(()=>[o(d,{class:"w-240px!",value:r(e).host,"onUpdate:value":a[4]||(a[4]=l=>r(e).host=l),placeholder:t.$t("Example:192.168.1.1")},null,8,["value","placeholder"])]),_:1},8,["label"]),o(p,{label:t.$t("SSH port"),path:"port"},{default:s(()=>[o(R,{class:"w-98px!",value:r(e).port,"onUpdate:value":a[5]||(a[5]=l=>r(e).port=l),"show-button":!1,placeholder:t.$t("SSH port")},null,8,["value","placeholder"])]),_:1},8,["label"])]),_:1}),o(p,{label:t.$t("Authentication"),path:"ssh_type"},{default:s(()=>[o(A,{value:r(e).ssh_type,"onUpdate:value":a[6]||(a[6]=l=>r(e).ssh_type=l),type:"button"},{default:s(()=>[o(v,{value:"password"},{default:s(()=>[y(i(t.$t("Login.index_2")),1)]),_:1}),o(v,{value:"key"},{default:s(()=>[y(i(t.$t("Key")),1)]),_:1})]),_:1},8,["value"])]),_:1},8,["label"]),r(e).ssh_type==="password"?(m(),W(p,{key:0,label:t.$t("SSH Password"),path:"password"},{default:s(()=>[o(k,{class:"flex-nowrap! items-center"},{default:s(()=>[o(d,{class:"w-220px!",value:r(e).password,"onUpdate:value":a[7]||(a[7]=l=>r(e).password=l),type:"password","show-password-on":"click",placeholder:t.$t("Example:123456")},null,8,["value","placeholder"]),o(F,{onClick:$,loading:r(h)},{default:s(()=>[y(i(t.$t("Test connection")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["label"])):w("",!0),r(e).ssh_type==="key"?(m(),_(g,{key:1},[o(p,{label:t.$t("SSH Key"),path:"private_key"},{default:s(()=>[o(k,{class:"flex-nowrap! items-center"},{default:s(()=>[o(d,{class:"w-220px!",value:r(e).private_key,"onUpdate:value":a[8]||(a[8]=l=>r(e).private_key=l),type:"textarea",placeholder:t.$t("Enter private key content")},null,8,["value","placeholder"]),o(F,{onClick:$,loading:r(h)},{default:s(()=>[y(i(t.$t("Test connection")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["label"]),o(p,{label:t.$t("SSH Key Password")},{default:s(()=>[o(k,{class:"flex-nowrap! items-center"},{default:s(()=>[o(d,{class:"w-350px!",value:r(e).private_key_password,"onUpdate:value":a[9]||(a[9]=l=>r(e).private_key_password=l),type:"password","show-password-on":"click",placeholder:t.$t("Please leave blank if no password is provided")},null,8,["value","placeholder"])]),_:1})]),_:1},8,["label"])],64)):w("",!0)],64)):w("",!0),o(p,{label:t.$t("Category"),path:"group_id"},{default:s(()=>[o(T,{class:"w-350px!",value:r(e).group_id,"onUpdate:value":a[10]||(a[10]=l=>r(e).group_id=l),options:r(N),placeholder:t.$t("Select Category")},null,8,["value","options","placeholder"])]),_:1},8,["label"])]),_:1},8,["model"]),o(B,null,{default:s(()=>[r(e).type==="api"?(m(),_(g,{key:0},[a[12]||(a[12]=f("li",null,"Step 1: Fill in the panel URL address, example: https://192.168.1.2:8888",-1)),a[13]||(a[13]=f("li",null,"Step 2: Open the panel, go to the [Panel Settings] page, click [Advanced Features]",-1)),a[14]||(a[14]=f("li",{class:"color-error"},"Step 3: Configure the [IP Whitelist]. Enter your computer's public fixed IP. If you don't have a fixed IP, please fill in an asterisk (*) ",-1)),f("li",null,i(t.$t("Step 4: Copy [API secret key] in the [API Configuration] window")),1),f("li",null,i(t.$t("Step 5: Back to the node management window, paste it into the [API Key] input box")),1)],64)):w("",!0),r(e).type==="ssh"?(m(),_(g,{key:1},[f("li",null,i(t.$t("Enter root account information")),1),f("li",{class:"color-warning",textContent:i(t.$t("The current authentication method does not support file transfer functionality"))},null,8,pe)],64)):w("",!0)]),_:1})])}}});export{Ke as default};
|