import D from"./DanyeTable-Depqh7vg.js";import{D as h,g as x,a as B,t as w,c as T,d as C}from"./DanyeFormDialog-CDhkv0nx.js";import{d as E,r as o,o as V,g as z,c as I,k as O,e as d,w as m,b as f,E as n,D as y,_ as b}from"./index-CUnFTKV2.js";const k={class:"page-container"},M=E({__name:"list",setup(L){const t=o(!1),r=o([]),c=o(!1),u=o(null),l=async()=>{t.value=!0;try{const a=await x();r.value=a.data}finally{t.value=!1}},g=async a=>{try{t.value=!0;const e=await B(a.id);u.value=e.data,c.value=!0}catch{n.error("获取单页详情失败")}finally{t.value=!1}},p=async(a,e)=>{try{await w(a.id,{isImageOptimizer:e}),n.success("状态更新成功");const s=r.value.find(i=>i.id===a.id);s&&(s.isImageOptimizer=e)}catch{n.error("状态更新失败"),l()}},v=async a=>{try{await y.confirm(`确定要清空「${a.title}」的内容吗？清空后可重新编辑。`,"清空确认",{confirmButtonText:"确定清空",cancelButtonText:"取消",type:"warning"}),t.value=!0,await T(a.id),n.success("内容已清空"),l()}catch(e){e!=="cancel"&&n.error("清空失败")}finally{t.value=!1}},_=async a=>{try{await y.confirm(`确定要删除「${a.title}」吗？删除后无法恢复。`,"删除确认",{confirmButtonText:"确定删除",cancelButtonText:"取消",type:"error"}),t.value=!0,await C(a.id),n.success("删除成功"),l()}catch(e){e!=="cancel"&&n.error((e==null?void 0:e.message)||"删除失败")}finally{t.value=!1}};return V(()=>{l()}),(a,e)=>{const s=z("el-card");return O(),I("div",k,[d(s,null,{header:m(()=>[...e[1]||(e[1]=[f("div",{class:"card-header"},[f("span",null,"单页管理")],-1)])]),default:m(()=>[d(D,{data:r.value,loading:t.value,onEdit:g,onToggleOptimizer:p,onClear:v,onDelete:_},null,8,["data","loading"])]),_:1}),d(h,{modelValue:c.value,"onUpdate:modelValue":e[0]||(e[0]=i=>c.value=i),danye:u.value,onSuccess:l},null,8,["modelValue","danye"])])}}}),S=b(M,[["__scopeId","data-v-ef29c3a7"]]);export{S as default};
