File: /www/server/panel/BTPanel/static/js/index577.js
import{O as F,M as p,S as u,F as c,w as O,ao as A,j as E,P as U,p as j,_ as L}from"./utils-lib.js?v=1777008528";import{_ as M}from"./index110.js?v=1777008528";import{c as N,r as b,g as P,v as T,I as H,J as R,z as a,x as B,y as z,e as n,C as i,O as J,A as o,G as K,B as f,n as Q,ad as X}from"./base-lib.js?v=1777008528";import{g as Y}from"./form-item.js?v=1777008528";import{updateGitmanagerSite as Z,getBranchList as ee,refreshWebhook as te,getGitmanager as ae}from"./site.js?v=1777008528";import{u as se}from"./useStore3.js?v=1777008528";import{w as oe,x as ne}from"./useController5.js?v=1777008528";import"./__commonjsHelpers__.js?v=1777008528";import"./column.js?v=1777008528";import"./useController4.js?v=1777008528";import"./validator.js?v=1777008528";import"./index107.js?v=1777008528";import"./useMethod3.js?v=1777008528";import"./index118.js?v=1777008528";const le={class:"overflow-auto max-h-63rem"},re={class:"flex flex-col pt-5px w-40rem leading-22px"},ie={class:"flex flex-col pt-5px w-40rem leading-22px"},ce={class:"flex items-center custom-refresh-select"},pe={class:"el-input-group__append !h-3rem !flex items-center"},ue={class:"flex flex-col gap-8px w-40rem leading-22px"},me=N({__name:"index",setup(de,{expose:D}){const{siteInfo:m}=se(),v=b(!1),k=b([]),d=b(!1),V=async t=>oe(t,h),y=async(t=!1)=>{try{if(!s.value.repo){p.error("请先填写仓库地址");return}u({request:ee({repo:s.value.repo,force:t?1:0}),data:{data:[Array,e=>e.map(l=>({label:l,value:l}))]},success:e=>{k.value=Array.isArray(e.data)?e.data:[],t&&p.success("分支列表已刷新")}})}catch(e){}},h=async()=>{try{const t=await ne();s.value.ssh_key=t.ssh_key.msg,d.value=t.webhook_install}catch(t){}},$=async()=>{await O({title:"重置令牌",content:"重置后旧链接将失效,Webhook 日志将被清空,且需要重新选择脚本。是否继续? URL将失效。"}),u({loading:"正在重置Webhook令牌,请稍后...",request:te({git_manager_id:m.value.git_manager.id}),success:t=>{t.data.data.webhook_url&&(s.value.webhook_url=t.data.data.webhook_url),p.request({status:t.data.status,msg:t.data.status?"重置成功":"重置失败"})}})},G=async()=>{try{await u({loading:v,request:ae({git_manager_id:m.value.git_manager.id}),data:{data:Object},success:t=>{Object.assign(s.value,{repo:t.repo_url,branch:t.branch,deploy_script:t.deploy_script,webhook_url:t.webhook_url})}})}catch(t){}},{BtForm:I,submit:S,param:s}=F({data:()=>({}),options:()=>P(()=>[{type:"slots",key:"gitconf",rules:{branch:[{required:!0,message:"请选择分支",trigger:["change","blur"]}]}},Y("保存",{attrs:{class:"!ml-[12rem]",type:"primary",onClick:S}})]),submit:async(t,e,l)=>{if(await e(),!d.value){p.error("Webhook 未安装,无法保存配置");return}const{branch:_,deploy_script:g}=t.value;return(await u({loading:"正在设置仓库配置,请稍后...",request:Z({git_manager_id:m.value.git_manager.id,branch:_,deploy_script:g}),message:!0,success:C=>{}})).status}}),x=async()=>{Q(async()=>{await G(),y(),h()})};return T(x),D({init:x}),(t,e)=>{const l=X,_=M,g=A,w=E,C=U,W=j,q=H("bt-loading");return R((B(),z("div",le,[n(a(I),{"label-width":"10rem"},{gitconf:i(()=>[a(d)?K("",!0):(B(),J(l,{key:0,label:"Webhook"},{default:i(()=>[o("span",{class:"bt-danger text-small",onClick:e[0]||(e[0]=r=>V("webhook"))}," 未安装Webhook,点击安装 ")]),_:1})),n(l,{label:"SSH Key",prop:"ssh_key",class:"!mb-1rem"},{default:i(()=>[o("div",re,[o("div",{onClick:e[1]||(e[1]=r=>a(c)({value:a(s).ssh_key}))},f(a(s).ssh_key),1),o("div",null,[o("span",{class:"bt-link",onClick:e[2]||(e[2]=r=>a(c)({value:a(s).ssh_key}))},"复制")])])]),_:1}),n(l,{label:"仓库",prop:"repo",class:"!mb-1rem"},{default:i(()=>[o("div",{onClick:e[3]||(e[3]=r=>a(c)({value:a(s).repo}))},f(a(s).repo),1)]),_:1}),n(l,{label:"Webhook URL",class:"!mb-1rem"},{default:i(()=>[o("div",ie,[o("div",{onClick:e[4]||(e[4]=r=>a(c)({value:a(s).webhook_url}))},f(a(s).webhook_url),1),o("div",null,[o("span",{class:"bt-link",onClick:e[5]||(e[5]=r=>a(c)({value:a(s).webhook_url}))},"复制"),n(_),o("span",{class:"bt-link",onClick:$},"重置令牌")])])]),_:1}),n(l,{label:"分支",prop:"branch"},{default:i(()=>[o("div",ce,[n(g,{modelValue:a(s).branch,"onUpdate:modelValue":e[6]||(e[6]=r=>a(s).branch=r),options:a(k),class:"!w-[30rem]",placeholder:"请选择分支"},null,8,["modelValue","options"]),o("div",pe,[n(C,{title:"刷新分支",class:"!flex",onClick:e[7]||(e[7]=r=>y(!0))},{default:i(()=>[n(w,{icon:"el-refresh",class:"!text-base"})]),_:1})])])]),_:1}),n(l,{label:"部署脚本",prop:"deploy_script"},{default:i(()=>[o("div",ue,[n(W,{type:"textarea",rows:10,class:"!w-40rem",placeholder:"请输入部署脚本",modelValue:a(s).deploy_script,"onUpdate:modelValue":e[8]||(e[8]=r=>a(s).deploy_script=r)},null,8,["modelValue"]),e[9]||(e[9]=o("div",{class:"text-small"},"* 脚本将会在获取最新代码(git pull)后执行",-1))])]),_:1})]),_:1})])),[[q,a(v)]])}}}),$e=L(me,[["__scopeId","data-v-31894326"]]);export{$e as default};