import{Dr as e,F as t,L as n,Lr as r,Lt as i,M as a,N as o,P as s,Xn as c,Yn as l,Zn as u,br as d,er as f,fr as p,rr as m,tr as h,ur as g}from"./index-DlQ7NONs.js";import{a as _}from"./VSelectionControl-DzIMhLnk.js";import{t as v}from"./VSpacer-CKw4fJfQ.js";import{t as y}from"./useSnackbar-D7YOfKok.js";import{t as b}from"./VChip-CqKVMdU4.js";import{t as x}from"./VDialog-BIzmuKKQ.js";import{t as S}from"./VSelect-CA1qJw1j.js";import{t as C}from"./VDataTableServer-BdF5Y6fh.js";var w={class:`font-weight-medium text-truncate d-inline-block`,style:{"max-width":`240px`}},T={class:`text-medium-emphasis`},E={class:`text-medium-emphasis`},D={class:`text-caption text-medium-emphasis`},O={class:`text-caption text-medium-emphasis`},k=m({__name:`RetriesPage`,setup(m){let k=y(),A=e(!1),j=e([]),M=e(0),N=e(1),P=e(null),F=e(!1),I=e(null),L=[{label:`待重试`,value:`pending`},{label:`重试中`,value:`retrying`},{label:`成功`,value:`success`},{label:`失败`,value:`failed`}],R=[{title:`状态`,key:`status`,width:100},{title:`任务`,key:`operation`},{title:`服务器`,key:`server_name`},{title:`次数`,key:`retry_count`,width:100},{title:`下次重试`,key:`next_retry_at`,width:140},{title:`创建时间`,key:`created_at`,width:160},{title:``,key:`actions`,width:120,align:`end`,sortable:!1}];async function z(){A.value=!0;try{let e=(await i.getList(`/retries/`,{limit:200})).items||[];P.value&&(e=e.filter(e=>e.status===P.value)),M.value=e.length;let t=(N.value-1)*20;j.value=e.slice(t,t+20)}catch(e){j.value=[],M.value=0,k(e instanceof Error?e.message:`加载重试队列失败`,`error`)}finally{A.value=!1}}async function B(e){try{await i.post(`/retries/${e.id}/retry`),z(),k(`重试已触发`)}catch(e){k(e.message||`操作失败`,`error`)}}function V(e){I.value=e.id,F.value=!0}async function H(){if(I.value)try{await i.delete(`/retries/${I.value}`),F.value=!1,z(),k(`已删除`)}catch(e){k(e.message||`删除失败`,`error`)}}function U(e){return e===`success`?`success`:e===`failed`?`error`:e===`retrying`?`warning`:`info`}function W(e){return e===`pending`?`待重试`:e===`retrying`?`重试中`:e===`success`?`成功`:e===`failed`?`失败`:e}function G(e){return e.source_path&&e.target_path?`${e.source_path} → ${e.target_path}`:e.source_path||e.target_path||`文件推送`}return g(()=>z()),(e,i)=>(p(),c(_,{fluid:``,class:`pa-6`},{default:d(()=>[h(a,{elevation:`0`,border:``,rounded:`lg`},{default:d(()=>[h(s,{class:`d-flex align-center text-h6`},{default:d(()=>[i[5]||=f(` 重试队列 `,-1),h(v),h(S,{modelValue:P.value,"onUpdate:modelValue":[i[0]||=e=>P.value=e,i[1]||=e=>{N.value=1,z()}],items:L,"item-title":`label`,"item-value":`value`,label:`状态筛选`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`160px`},clearable:``},null,8,[`modelValue`])]),_:1}),h(C,{items:j.value,headers:R,"items-length":M.value,loading:A.value,page:N.value,"items-per-page":20,hover:``,density:`comfortable`,"onUpdate:page":i[2]||=e=>{N.value=e,z()}},{"item.status":d(({item:e})=>[h(b,{color:U(e.status),size:`x-small`,variant:`tonal`,label:``,border:`sm`},{default:d(()=>[f(r(W(e.status)),1)]),_:2},1032,[`color`])]),"item.operation":d(({item:e})=>[l(`span`,w,r(G(e)),1)]),"item.server_name":d(({item:e})=>[l(`span`,T,r(e.server_name||`—`),1)]),"item.retry_count":d(({item:e})=>[l(`span`,E,r(e.retry_count||0)+` / `+r(e.max_retries||3),1)]),"item.next_retry_at":d(({item:e})=>[l(`span`,D,r(e.next_retry_at||`—`),1)]),"item.created_at":d(({item:e})=>[l(`span`,O,r(e.created_at),1)]),"item.actions":d(({item:e})=>[e.status===`pending`||e.status===`failed`?(p(),c(n,{key:0,variant:`text`,size:`x-small`,color:`primary`,density:`compact`,onClick:t=>B(e)},{default:d(()=>[...i[6]||=[f(` 重试 `,-1)]]),_:1},8,[`onClick`])):u(``,!0),h(n,{variant:`text`,size:`x-small`,color:`error`,density:`compact`,onClick:t=>V(e)},{default:d(()=>[...i[7]||=[f(` 删除 `,-1)]]),_:1},8,[`onClick`])]),"no-data":d(()=>[...i[8]||=[l(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1}),h(x,{modelValue:F.value,"onUpdate:modelValue":i[4]||=e=>F.value=e,"max-width":`400`},{default:d(()=>[h(a,{border:``},{default:d(()=>[h(s,null,{default:d(()=>[...i[9]||=[f(`确认删除`,-1)]]),_:1}),h(o,null,{default:d(()=>[...i[10]||=[f(`确定要删除此重试任务吗？`,-1)]]),_:1}),h(t,null,{default:d(()=>[h(v),h(n,{variant:`text`,onClick:i[3]||=e=>F.value=!1},{default:d(()=>[...i[11]||=[f(`取消`,-1)]]),_:1}),h(n,{color:`error`,variant:`flat`,onClick:H},{default:d(()=>[...i[12]||=[f(`删除`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{k as default};