2026-06-10 21:18:23 +08:00
import { a as e } from "./VDataTable-CvpeYUTC.js" ; import { n as t , t as n } from "./useSnackbar-BFeYjAzp.js" ; import { n as r , t as i } from "./VRow-ZHldweuW.js" ; import { At as a , Bt as o , Cr as s , Ct as c , Er as l , F as ee , Ft as te , Gt as ne , Ht as re , I as u , Mt as ie , Or as ae , Pr as oe , Pt as se , Rr as ce , Rt as le , Sr as d , Tr as f , Ur as p , Ut as ue , Vr as m , Vt as de , Wt as fe , Yr as h , Z as pe , Zr as g , _ as me , an as he , br as _ , di as v , en as y , gr as b , hi as x , hr as ge , ii as S , in as _e , jt as ve , pi as ye , qt as be , tt as xe , v as Se , xr as C , y as w , yr as T , zr as Ce , zt as we } from "./index-BKLG6eUi.js" ; import { t as E } from "./_plugin-vue_export-helper-BDNMzG2s.js" ; import { n as Te } from "./dataTable-esDY4cOk.js" ; import { t as Ee } from "./paginatedFetch-Bh_Ds7m8.js" ; import { _ as D , v as O } from "./VTextField-Bs8XQAKI.js" ; import { t as k } from "./VSelect-Dy70bHJm.js" ; import { t as De } from "./VDataTableServer-GLUwxaQu.js" ; import { t as A } from "./apiError-C9ZCize-.js" ; import { t as Oe } from "./useServerList-CfVe7wPe.js" ; import { n as ke , t as Ae } from "./execDetailGrouping-DHyfnMl2.js" ; import { i as je , n as Me , r as Ne , t as Pe } from "./VExpansionPanels-B_PhIoBw.js" ; var Fe = { class : `d-flex align-center flex-wrap ga-2 mb-4` }, Ie = { class : `text-h6` }, Le = { class : `text-caption text-medium-emphasis mb-2` }, Re = { key : 0 , class : `text-body-2 mb-3 pa-3 rounded bg-surface-variant overflow-auto` , style : { "max-height" : `100px` }}, ze = { key : 2 , class : `d-flex flex-wrap ga-2 mb-3` }, Be = { class : `text-body-2` }, Ve = { class : `d-flex align-center flex-wrap ga-2 mb-3` }, He = [ `onClick` ], Ue = { class : `font-weight-medium` }, We = { key : 0 , class : `text-caption text-medium-emphasis` }, Ge = [ `title` ], Ke = { key : 0 }, qe = { class : `d-flex align-center ga-2 flex-grow-1 min-width-0` }, Je = [ `title` ], Ye = { key : 0 , class : `text-medium-emphasis` }, Xe = { class : `d-flex align-center flex-wrap ga-2 mb-4` }, Ze = { class : `text-caption text-medium-emphasis` }, j = E ( ae ({ name : `ScriptRunsPage` , __name : `ScriptRunsPage` , setup ( ae ){ let E = _e (), j = he (), M = n (),{ servers : Qe , loadServers : $e } = Oe (), N = T (()=>{ let e = E . params . id ; if ( ! e ) return null ; let t = Number ( e ); return Number . isFinite ( t ) ? t : null }), P = T (()=> ie ( E . query . kind )), et = T (()=> ` ${ P . value === `server_batch` ? `服务器任务` : `脚本执行` } # ${ N . value ?? `` } ` ), F = S ( ! 1 ), I = S ([]), L = S ( 0 ), R = S ( 1 ), z = S ( 20 ), B = S ( null ), V = S ( null ), tt = [{ title : `执行中` , value : `running` },{ title : `已完成` , value : `completed` },{ title : `部分成功` , value : `partial` },{ title : `失败` , value : `failed` },{ title : `已取消` , value : `cancelled` }], nt = [{ title : `脚本` , value : `script` },{ title : `服务器` , value : `server_batch` }], rt = Te ([{ title : `ID` , key : `id` , width : 72 },{ title : `类型` , key : `kind` , width : 88 },{ title : `任务` , key : `label` },{ title : `状态` , key : `status` , width : 100 },{ title : `进度` , key : `progress` , width : 88 },{ title : `台数` , key : `server_count` , width : 72 },{ title : `操作人` , key : `operator` , width : 88 },{ title : `开始时间` , key : `started_at` , width : 168 },{ title : `操作` , key : `actions` , width : 88 }]), H = S ( null ), U = S ( ! 1 ), W = S ( `all` ), G = S ( `list` ), it = S ( null ), at = S ([]), K = null , ot = T (()=> new Map ( Qe . value . map ( e =>[ e . id , e ]))); function st ( e ){ return e || `—` } function ct ( e ){ if ( ! e ) return 0 ; try { let t = JSON . parse ( e ); return Array . isArray ( t ) ? t . length : 0 } catch { return 0 }} function lt ( e ){ if ( e . label ) return e . label ; let t = ( e . command || `` ). replace ( /^\[long_task\] / , `` ); return t . length > 48 ? t . slice ( 0 , 48 ) + `…` : t || `执行 # ${ e . id } ` } function ut ( e ){ let t = ( e . stderr || `` ). trim (), n = ( e . stdout || `` ). trim (), r = ( e . message || `` ). trim (), i = t || n || r || `—` ; return { summary : ( t || r || n || `` ). slice ( 0 , 200 ) || `—` , full : i }} let q = T (()=>{ if ( ! H . value ? . results ) return []; let e = ot . value ; return Object . entries ( H . value . results ). filter (([ e ])=> e !== `_meta` && /^\d+$/ . test ( e )). map (([ t , n ])=>{ let r = Number ( t ), i = e . get ( r ), a = String ( n . status || `` ), o = n . phase ? String ( n . phase ) : void 0 , s = n . exit_code ?? null , c = ut ( n ); return { serverId : t , serverIdNum : r , serverName : fe ( t , H . value ? . server_names , i ? . name ), serverDomain : i ? . domain || `` , status : a , phase : o , exitCode : s , summary : c . summary , fullOutput : c . full , failed : re ( a , o , s ), pending : ue ( o )}})}), dt = T (()=> W . value === `failed` ? q . value . filter ( e => e . failed ) : W . value === `success` ? q . value . filter ( e => ! e . failed &&! e . pending ) : q . value ), J = T (()=> ne ( H . value ? . results , H . value ? . server_ids )), Y = T (()=> q . value . filter ( e => e . failed ). map ( e => e . serverName )),
`),` 已复制分组摘要 `)}h(B,()=>{R.value=1,Z()}),h(V,()=>{R.value=1,Z()}),h([N,P],([e])=>{$(),H.value=null,e?(W.value=` all `,G.value=` list `,Q(!1)):Z()},{immediate:!0}),ke(e=>Z(e),{enabled:()=>!N.value});let wt=se(()=>{N.value?Q(!1,!0):Z(!0)}),Tt=!1;return ce(async()=>{await $e({all:!0}),Tt=!0}),oe(async()=>{Tt&&(await $e({all:!0}),N.value?await Q(!1,!0):await Z(!0))}),Ce(()=>{$(),wt()}),(n,c)=>(m(),C(t,{fluid:``,class:` pa - 4 `},{default:g(()=>[N.value?(m(),s(b,{key:0},[_(` div `,Fe,[l(u,{variant:` text `,"prepend-icon":` mdi - arrow - left `,onClick:c[0]||=e=>v(j).push(` / executions `)},{default:g(()=>[...c[8]||=[f(` 返回列表 `,-1)]]),_:1}),_(` h1 `,Ie,x(et.value),1),H.value?(m(),C(w,{key:0,color:v(o)(H.value.status),size:` small `,variant:` tonal `,label:``},{default:g(()=>[f(x(v(de)(H.value.status)),1)]),_:1},8,[` color `])):d(``,!0),l(me),H.value?.long_task&&P.value===` script `?(m(),C(u,{key:1,size:` small `,variant:` tonal `,loading:U.value,onClick:c[1]||=e=>Q(!0)},{default:g(()=>[...c[9]||=[f(` 拉取日志 `,-1)]]),_:1},8,[` loading `])):d(``,!0),P.value===` script `&&H.value&&(H.value.status===` running `||H.value.status===` partial `)?(m(),C(u,{key:2,size:` small `,variant:` text `,color:` error `,onClick:vt},{default:g(()=>[...c[10]||=[f(` 停止 `,-1)]]),_:1})):d(``,!0),P.value===` script `&&H.value&&(H.value.status===` failed `||H.value.status===` partial `)?(m(),C(u,{key:3,size:` small `,variant:` tonal `,color:` primary `,onClick:yt},{default:g(()=>[...c[11]||=[f(` 重试失败项 `,-1)]]),_:1})):d(``,!0)]),U.value&&!H.value?(m(),C(D,{key:0,elevation:` 0 `,border:``,rounded:` lg `,class:` pa - 8 text - center `},{default:g(()=>[l(pe,{indeterminate:``,color:` primary `})]),_:1})):H.value?(m(),C(D,{key:1,elevation:` 0 `,border:``,rounded:` lg `},{default:g(()=>[l(O,null,{default:g(()=>[_(` div `,Le,x(st(H.value.progress))+` · 操作人 `+x(H.value.operator||` — `),1),P.value===` script `?(m(),s(` pre `,Re,x(H.value.command),1)):(m(),C(w,{key:1,size:` small `,variant:` tonal `,color:` info `,class:` mb - 3 `,label:``},{default:g(()=>[f(x(v(a)(P.value))+` · `+x(H.value.label||H.value.op||` — `),1)]),_:1})),J.value.total?(m(),s(` div `,ze,[l(w,{size:` small `,variant:` tonal `,label:``},{default:g(()=>[f(` 共 `+x(J.value.total)+` 台 `,1)]),_:1}),J.value.success?(m(),C(w,{key:0,color:` success `,size:` small `,variant:` tonal `,label:``},{default:g(()=>[f(` 成功 `+x(J.value.success),1)]),_:1})):d(``,!0),J.value.failed?(m(),C(w,{key:1,color:` error `,size:` small `,variant:` tonal `,label:``},{default:g(()=>[f(` 失败 `+x(J.value.failed),1)]),_:1})):d(``,!0),J.value.pending?(m(),C(w,{key:2,color:` info `,size:` small `,variant:` tonal `,label:``},{default:g(()=>[f(` 进行中 `+x(J.value.pending),1)]),_:1})):d(``,!0)])):d(``,!0),Y.value.length?(m(),C(ee,{key:3,type:` error `,variant:` tonal `,density:` compact `,class:` mb - 3 `,title:` 失败 $ { Y . value . length } 台 `},{default:g(()=>[_(` div `,Be,x(Y.value.join(` 、 `)),1)]),_:1},8,[` title `])):d(``,!0),_(` div `,Ve,[c[20]||=_(` span `,{class:` text - caption text - medium - emphasis `},` 筛选 `,-1),l(xe,{modelValue:W.value,"onUpdate:modelValue":c[2]||=e=>W.value=e,mandatory:``,density:` compact `,color:` primary `,variant:` outlined `,divided:``},{default:g(()=>[l(u,{value:` all `,size:` small `},{default:g(()=>[...c[12]||=[f(` 全部 `,-1)]]),_:1}),l(u,{value:` failed `,size:` small `},{default:g(()=>[...c[13]||=[f(` 仅失败 `,-1)]]),_:1}),l(u,{value:` success `,size:` small `},{default:g(()=>[...c[14]||=[f(` 仅成功 `,-1)]]),_:1})]),_:1},8,[` modelValue `]),J.value.failed>0?(m(),s(b,{key:0},[l(Se,{vertical:``,class:` mx - 1 `}),c[19]||=_(` span `,{class:` text - caption text - medium - emphasis `},` 视图 `,-1),l(xe,{modelValue:G.value,"onUpdate:modelValue":c[3]||=e=>G.value=e,mandatory:``,density:` compact `,color:` primary `,variant:` outlined `,divided:``},{default:g(()=>[l(u,{value:` list `,size:` small `},{default:g(()=>[...c[15]||=[f(` 列表 `,-1)]]),_:1}),l(u,{value:` group `,size:` small `},{default:g(()=>[...c[16]||=[f(` 按错误分组 `,-1)]]),_:1})]),_:1},8,[` modelValue `]),l(u,{size:` small `,variant:` tonal `,"prepend-icon":` mdi - content - copy `,onClick:St},{default:g(()=>[...c[17]||=[f(` 复制失败清单 `,-1)]]),_:1}),G.value=