import{$n as e,F as t,It as n,Jn as r,L as i,M as a,Mr as o,N as s,P as c,Sr as l,Xn as u,Yn as d,dr as f,er as p,lr as m,nr as h,vr as g}from"./index-9ZGEqHPG.js";import{a as _}from"./VSelectionControl-D6-x3Otj.js";import{t as v}from"./VSpacer-Cu4v-Rar.js";import{t as y}from"./useSnackbar-D7YOfKok.js";import{t as b}from"./VChip-CTgzb9sy.js";import{t as x}from"./VDialog-BBAukoFN.js";import{t as S}from"./VSelect-AIFszPWO.js";import{t as C}from"./VDataTableServer-DJK7mjnE.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=h({__name:`RetriesPage`,setup(h){let k=y(),A=l(!1),j=l([]),M=l(0),N=l(1),P=l(null),F=l(!1),I=l(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 n.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 n.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 n.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 m(()=>z()),(n,l)=>(f(),d(_,{fluid:``,class:`pa-6`},{default:g(()=>[p(a,{elevation:`0`,border:``,rounded:`lg`},{default:g(()=>[p(c,{class:`d-flex align-center text-h6`},{default:g(()=>[l[5]||=e(` 重试队列 `,-1),p(v),p(S,{modelValue:P.value,"onUpdate:modelValue":[l[0]||=e=>P.value=e,l[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}),p(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":l[2]||=e=>{N.value=e,z()}},{"item.status":g(({item:t})=>[p(b,{color:U(t.status),size:`x-small`,variant:`tonal`,label:``,border:`sm`},{default:g(()=>[e(o(W(t.status)),1)]),_:2},1032,[`color`])]),"item.operation":g(({item:e})=>[r(`span`,w,o(G(e)),1)]),"item.server_name":g(({item:e})=>[r(`span`,T,o(e.server_name||`—`),1)]),"item.retry_count":g(({item:e})=>[r(`span`,E,o(e.retry_count||0)+` / `+o(e.max_retries||3),1)]),"item.next_retry_at":g(({item:e})=>[r(`span`,D,o(e.next_retry_at||`—`),1)]),"item.created_at":g(({item:e})=>[r(`span`,O,o(e.created_at),1)]),"item.actions":g(({item:t})=>[t.status===`pending`||t.status===`failed`?(f(),d(i,{key:0,variant:`text`,size:`x-small`,color:`primary`,density:`compact`,onClick:e=>B(t)},{default:g(()=>[...l[6]||=[e(` 重试 `,-1)]]),_:1},8,[`onClick`])):u(``,!0),p(i,{variant:`text`,size:`x-small`,color:`error`,density:`compact`,onClick:e=>V(t)},{default:g(()=>[...l[7]||=[e(` 删除 `,-1)]]),_:1},8,[`onClick`])]),"no-data":g(()=>[...l[8]||=[r(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1}),p(x,{modelValue:F.value,"onUpdate:modelValue":l[4]||=e=>F.value=e,"max-width":`400`},{default:g(()=>[p(a,{border:``},{default:g(()=>[p(c,null,{default:g(()=>[...l[9]||=[e(`确认删除`,-1)]]),_:1}),p(s,null,{default:g(()=>[...l[10]||=[e(`确定要删除此重试任务吗？`,-1)]]),_:1}),p(t,null,{default:g(()=>[p(v),p(i,{variant:`text`,onClick:l[3]||=e=>F.value=!1},{default:g(()=>[...l[11]||=[e(`取消`,-1)]]),_:1}),p(i,{color:`error`,variant:`flat`,onClick:H},{default:g(()=>[...l[12]||=[e(`删除`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{k as default};