Files
jiang13-forum/embed_static/static/spa/assets/BoardsManagePage-DQXzBsE1.js
freefire b451703642 完善论坛配置与发帖体验:TipTap 富文本、图片上传、修订历史、Feed 排序与后台参数管理。
同步更新 README 与 ROADMAP,反映最新功能与开发状态。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 04:11:38 +08:00

2 lines
7.7 KiB
JavaScript

import{r as n,j as e,e as K}from"./react-vendor-CFzzFOsg.js";import{_ as Q,Z as U,u as W,a as Y,F as $,b as g,c as y,d as N,e as b,f as w,o as ee,s as R}from"./form-OSLy-cSS.js";import{c as l,e as se,S as F,B as h,a as j,n as c}from"./index-5C0q-ZMs.js";import{I as A}from"./input-CE0PJTgJ.js";import{T as ae}from"./textarea-VyK9_GFn.js";import{B as te}from"./badge-DB-zL5ml.js";import{a4 as re,a5 as ne,a6 as S,a7 as le,X as oe,a8 as _,a9 as B,aa as E,m as ie}from"./ui-vendor-BtpOfToU.js";import{A as de,a as ce,b as me,c as xe,d as he,e as pe,f as je,g as fe,h as ue}from"./alert-dialog-BoQ7HSUR.js";function ge(s){return Q(U,s)}const k=n.forwardRef(({className:s,...t},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:l("w-full caption-bottom text-sm",s),...t})}));k.displayName="Table";const z=n.forwardRef(({className:s,...t},r)=>e.jsx("thead",{ref:r,className:l("[&_tr]:border-b",s),...t}));z.displayName="TableHeader";const H=n.forwardRef(({className:s,...t},r)=>e.jsx("tbody",{ref:r,className:l("[&_tr:last-child]:border-0",s),...t}));H.displayName="TableBody";const v=n.forwardRef(({className:s,...t},r)=>e.jsx("tr",{ref:r,className:l("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...t}));v.displayName="TableRow";const i=n.forwardRef(({className:s,...t},r)=>e.jsx("th",{ref:r,className:l("h-10 px-3 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t}));i.displayName="TableHead";const d=n.forwardRef(({className:s,...t},r)=>e.jsx("td",{ref:r,className:l("p-3 align-middle [&:has([role=checkbox])]:pr-0",s),...t}));d.displayName="TableCell";const ye=re,Ne=ne,I=n.forwardRef(({className:s,...t},r)=>e.jsx(B,{ref:r,className:l("fixed inset-0 z-[110] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...t}));I.displayName=B.displayName;const O=n.forwardRef(({className:s,children:t,...r},f)=>e.jsxs(Ne,{children:[e.jsx(I,{}),e.jsxs(S,{ref:f,className:l("fixed left-[50%] top-[50%] z-[110] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...r,children:[t,e.jsxs(le,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"关闭"})]})]})]}));O.displayName=S.displayName;const L=({className:s,...t})=>e.jsx("div",{className:l("flex flex-col space-y-1.5 text-center sm:text-left",s),...t});L.displayName="DialogHeader";const P=({className:s,...t})=>e.jsx("div",{className:l("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...t});P.displayName="DialogFooter";const M=n.forwardRef(({className:s,...t},r)=>e.jsx(_,{ref:r,className:l("text-lg font-semibold leading-none tracking-tight",s),...t}));M.displayName=_.displayName;const be=n.forwardRef(({className:s,...t},r)=>e.jsx(E,{ref:r,className:l("text-sm text-muted-foreground",s),...t}));be.displayName=E.displayName;const we=ee({name:R().min(1,"请输入名称").max(64),description:R().max(500).optional(),sort_order:ge().min(0)});function _e(){K();const{ready:s}=se(),[t,r]=n.useState([]),[f,D]=n.useState(!0),[Z,m]=n.useState(!1),[p,T]=n.useState(null),[G,C]=n.useState(!1),o=W({resolver:Y(we),defaultValues:{name:"",description:"",sort_order:1}}),u=()=>{D(!0),j.boards().then(a=>r(a.boards??[])).catch(a=>c.error(a.message)).finally(()=>D(!1))};n.useEffect(()=>{s&&u()},[s]);const V=()=>{T(null),o.reset({name:"",description:"",sort_order:t.length+1}),m(!0)},X=a=>{T(a),o.reset({name:a.name,description:a.description??"",sort_order:a.sort_order}),m(!0)},q=async a=>{C(!0);try{p?(await j.updateBoard(p.id,a),c.success("板块已更新")):(await j.createBoard(a),c.success("板块已创建")),m(!1),u(),window.dispatchEvent(new Event("boards-refresh"))}catch(x){c.error(x instanceof Error?x.message:"操作失败")}finally{C(!1)}},J=async a=>{try{await j.deleteBoard(a),c.success("板块已删除"),u(),window.dispatchEvent(new Event("boards-refresh"))}catch(x){c.error(x instanceof Error?x.message:"删除失败")}};return s?e.jsxs("div",{className:"admin-page",children:[e.jsx("div",{className:"admin-page-head",children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h1",{children:"板块管理"}),e.jsx("p",{children:"创建、编辑或删除论坛板块,用户发帖前需先有板块"})]}),e.jsxs(h,{onClick:V,children:[e.jsx(ie,{}),"新建板块"]})]})}),e.jsx("div",{className:"admin-card",children:f?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs(k,{children:[e.jsx(z,{children:e.jsxs(v,{children:[e.jsx(i,{className:"w-[60px]",children:"ID"}),e.jsx(i,{children:"名称"}),e.jsx(i,{children:"简介"}),e.jsx(i,{className:"w-[70px]",children:"排序"}),e.jsx(i,{className:"w-[80px]",children:"帖子数"}),e.jsx(i,{className:"w-[160px]",children:"操作"})]})}),e.jsx(H,{children:t.map(a=>e.jsxs(v,{children:[e.jsx(d,{children:a.id}),e.jsx(d,{children:e.jsx("strong",{children:a.name})}),e.jsx(d,{className:"max-w-[200px] truncate",children:a.description}),e.jsx(d,{children:a.sort_order}),e.jsx(d,{children:e.jsx(te,{variant:"secondary",children:a.post_count??0})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>X(a),children:"编辑"}),e.jsxs(de,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",children:"删除"})}),e.jsxs(me,{children:[e.jsxs(xe,{children:[e.jsx(he,{children:"确定删除该板块?"}),e.jsx(pe,{children:"删除后该板块下的帖子将无法通过板块筛选,此操作不可撤销。"})]}),e.jsxs(je,{children:[e.jsx(fe,{children:"取消"}),e.jsx(ue,{onClick:()=>J(a.id),children:"删除"})]})]})]})]})})]},a.id))})]}),t.length===0&&e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"还没有板块,点击右上角创建第一个"})})]})}),e.jsx(ye,{open:Z,onOpenChange:m,children:e.jsxs(O,{children:[e.jsx(L,{children:e.jsx(M,{children:p?"编辑板块":"新建板块"})}),e.jsx($,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(q),className:"space-y-4",children:[e.jsx(g,{control:o.control,name:"name",render:({field:a})=>e.jsxs(y,{children:[e.jsx(N,{children:"板块名称"}),e.jsx(b,{children:e.jsx(A,{maxLength:64,placeholder:"如:技术交流",...a})}),e.jsx(w,{})]})}),e.jsx(g,{control:o.control,name:"description",render:({field:a})=>e.jsxs(y,{children:[e.jsx(N,{children:"简介"}),e.jsx(b,{children:e.jsx(ae,{rows:3,maxLength:500,placeholder:"板块说明(可选)",...a})}),e.jsx(w,{})]})}),e.jsx(g,{control:o.control,name:"sort_order",render:({field:a})=>e.jsxs(y,{children:[e.jsx(N,{children:"排序"}),e.jsx(b,{children:e.jsx(A,{type:"number",min:0,...a})}),e.jsx(w,{})]})}),e.jsxs(P,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>m(!1),children:"取消"}),e.jsx(h,{type:"submit",loading:G,children:p?"保存":"创建"})]})]})})]})})]}):e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(F,{size:"lg"})})}export{_e as default};