1import{r as e,j as t}from"./vendor-react-DejgYtBM.js";import{u as s,A as r,s as a,w as i,v as n,Y as l,ac as o}from"./index-BeIIFw6E.js";import{W as d,l as c,o as p,f as u,T as x,a as h,z as g,B as f,i as m,j as y,m as b,y as j,E as k,J as w,K as v,M as S,D as z}from"./vendor-semi-D8d7bTtM.js";import{m as C}from"./marked.esm-B28mcIGu.js";import{p as N}from"./purify.es-Bm-lHtoJ.js";import{H as I}from"./vendor-highlight-CaHTjBxz.js";import{br as _,E as T,be as D,bf as P,aT as L,bg as $,bh as A,bi as R,bj as M,al as O,bk as E,bl as q,b as B,bm as F,aa as K,aL as H,bn as J,bo as V,bp as W,bq as G,e as X,aj as Y,I as Z,k as Q,X as U}from"./vendor-icons-EJvJ5X-w.js";import"./vendor-motion-Chfy_MiU.js";C.setOptions({gfm:!0,breaks:!0,smartypants:!1,highlight:function(e,t){if(t&&I.getLanguage(t))try{return I.highlight(e,{language:t}).value}catch{}try{return I.highlightAuto(e).value}catch{}return e}});const ee={ADD_TAGS:["iframe","video","audio","source","details","summary","mark","kbd","abbr","sup","sub","dl","dt","dd","ins","ruby","rt","rp"],ADD_ATTR:["target","allowfullscreen","frameborder","scrolling","controls","autoplay","loop","muted","poster","preload","open","title","start","type","media"]},{Text:te}=u,se=e=>[{icon:D,title:e("ç²ä½"),prefix:"**",suffix:"**",placeholder:e("ç²ä½ææ¬")},{icon:P,title:e("æä½"),prefix:"*",suffix:"*",placeholder:e("æä½ææ¬")},{icon:L,title:e("å é¤çº¿"),prefix:"~~",suffix:"~~",placeholder:e("å é¤çº¿ææ¬")},{icon:$,title:e("é«äº®"),prefix:"<mark>",suffix:"</mark>",placeholder:e("é«äº®ææ¬")},{type:"divider"},{icon:A,title:e("ä¸çº§æ é¢"),prefix:"# ",suffix:"",placeholder:e("æ é¢"),isLine:!0},{icon:R,title:e("äºçº§æ é¢"),prefix:"## ",suffix:"",placeholder:e("æ é¢"),isLine:!0},{icon:M,title:e("ä¸çº§æ é¢"),prefix:"### ",suffix:"",placeholder:e("æ é¢"),isLine:!0},{type:"divider"}
1,{icon:O,title:e("æ åºå表"),prefix:"- ",suffix:"",placeholder:e("å表项"),isLine:!0},{icon:E,title:e("æåºå表"),prefix:"1. ",suffix:"",placeholder:e("å表项"),isLine:!0},{icon:q,title:e("å¼ç¨"),prefix:"> ",suffix:"",placeholder:e("å¼ç¨ææ¬"),isLine:!0},{icon:B,title:e("代ç å"),prefix:"```\n",suffix:"\n```",placeholder:e("代ç "),isBlock:!0},{type:"divider"},{icon:F,title:e("龿¥"),prefix:"[",suffix:"](url)",placeholder:e("龿¥ææ¬")},{icon:K,title:e("å¾ç"),prefix:"",placeholder:e("å¾çæè¿°")},{icon:H,title:e("åå²çº¿"),prefix:"\n---\n",suffix:"",placeholder:"",isInsert:!0},{icon:J,title:e("è¡¨æ ¼"),prefix:"\n| å1 | å2 | å3 |\n| --- | --- | --- |\n| ",suffix:" | å
容 | å
容 |\n",placeholder:e("å
容"),isInsert:!0},{type:"divider"},{icon:V,title:e("䏿 "),prefix:"<sup>",suffix:"</sup>",placeholder:e("䏿 ")},{icon:W,title:e("䏿 "),prefix:"<sub>",suffix:"</sub>",placeholder:e("䏿 ")},{icon:G,title:e("é®çé®"),prefix:"<kbd>",suffix:"</kbd>",placeholder:"Ctrl"},{icon:X,title:e("æå åºå"),prefix:"<details>\n<summary>ç¹å»å±å¼</summary>\n\n",suffix:"\n\n</details>",placeholder:e("æå å
容")},{type:"divider"},{icon:Y,title:e("è¦åæç¤º"),prefix:"\n> â ï¸ **è¦åï¼** ",suffix:"",placeholder:e("è¦åå
容"),isLine:!0},{icon:Z,title:e("ä¿¡æ¯æç¤º"),prefix:"\n> â¹ï¸ **æç¤ºï¼** ",suffix:"",placeholder:e("æç¤ºå
容"),isLine:!0},{icon:Q,title:e("æåæç¤º"),prefix:"\n> â
**æåï¼** ",suffix:"",placeholder:e("æåå
容"),isLine:!0}],re=({visible:n,onCancel:l,refresh:o,editingArticle:u})=>{const{t:m}=s(),[y,b]=e.useState(!1),[j,k]=e.useState(!1),[w,v]=e.useState(""),[S,z]=e.useState("edit"),I=e.useRef(),D=e.useRef(),P=null!=u;e.useEffect(()=>{n&&(P?(I.current?.setValues(u),v(u.content||"")):(I.current?.setValues({}),v("")),z("edit"))},[n,P,u]);const L=e.useCallback(e=>{const t=D.current;if(!t)return;const s=t.selectionStart,r=t.selectionEnd;v(a=>{const i=a.substring(s,r);let n,l;if(e.isInsert)n=a.substring(0,s)+e.prefix+e.suffix+a.substring(r),l=s+e.prefix.length+e.suffix.length;else{if(!i)return n=a.substring(0,s)+e.prefix+e.placeholder+e.suffix+a.substring(r),setTimeout(()=>{t.focus(),t.setSelectionRange(s+e.prefix.length,s+e.prefix.length+e.placeholder.length)},0),n;n=a.substring(0,s)+e.prefix+i+e.suffix+a.substring(r),l=s+e.prefix.length+i.length+e.suffix.length}return setTimeout(()=>{t.focus(),t.setSelectionRange(l,l)},0),n})},[]),$=e.useCallback(e=>{if("Tab"===e.key){e.preventDefault();const t=D.current,s=t.selectionStart,r=t.selectionEnd;v(e=>e.substring(0,s)+" "+e.substring(r)),setTimeout(()=>{t.setSelectionRange(s+2,s+2)},0)}},[]),A=e.useCallback(async e=>{const t=e.clipboardData?.items;if(!t)return;let s=null;for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/")){s=t[r].getAsFile();break}if(!s)return;e.preventDefault();const i=D.current;if(!i)return;const n=i.selectionStart,l=i.selectionEnd,o=`![uploading-${Date.now()}-${Math.random().toString(36).slice(2,8)}]()`;v(e=>e.substring(0,n)+o+e.substring(l)),k(!0);try{const e=new FormData;e.append("file",s);const t=await r.post("/api/admin/upload-file",e,{headers:{"Content-Type":"multipart/form-data"}});if(t.data.success&&t.data.data?.url){const e=``;v(t=>t.replace(o,e))}else a(t.data.message||m("å¾çä¸ä¼ 失败")),v(e=>e.replace(o,""))}catch(d){a(m("å¾çä¸ä¼ 失败")+": "+d.message),v(e=>e.replace(o,""))}finally{k(!1)}},[m]);return t.jsx(d,{title:m(P?"ç¼è¾æç« ":"æ°å»ºæç« "),visible:n,onCancel:l,width:900,footer:t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end"},children:[t.jsx(f,{style:{marginRight:8},onClick:l,children:m("åæ¶")}),t.jsx(f,{theme:"solid",onClick:()=>I.current?.submitForm(),loading:y,children:m("æäº¤")})]}),children:t.jsx(c,{spinning:y,children:t.jsxs(p,{getFormApi:e=>I.current=e,onSubmit:async e=>{b(!0);try{const t={...e,content:w,status:0};let s;s=P?await r.put(`/api/article/${u.id}`,t):await r.post("/api/article/",t);const{success:n,message:d}=s.data;n?(i(m(P?"æç« æ´æ°æå":"æç« å建æå")),o(),l()):a(d||m(P?"æ´æ°å¤±è´¥":"å建失败"))}catch(t){a(t.message)}finally{b(!1)}},labelPosition:"top",children:[t.jsx(p.Input,{field:"title",label:m("æ é¢"),rules:[{required:!0,message:m("请è¾å
¥æ é¢")}],placeholder:m("请è¾å
¥æç« æ é¢")}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsxs(te,{strong:!0,style:{display:"block",marginBottom:8},children:[m("å
容")," ",t.jsxs(te,{type:"tertiary",size:"small",children:["ï¼",m("æ¯æ Markdown æ ¼å¼"),"ï¼"]})]}),t.jsxs(x,{activeKey:S,onChange:z,size:"small",style:{marginBottom:0},children:[t.jsxs(h,{tab:t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(_,{size:14})," ",m("ç¼è¾")]}),itemKey:"edit",children:[t.jsx("div",{className:"flex items-center gap-0.5 p-1.5 bg-gray-50 dark:bg-gray-800 border border-b-0 border-gray-200 dark:border-gray-600 rounded-t-lg flex-wrap",children:se(m).map((e,s)=>{if("divider"===e.type)return t.jsx("div",{className:"w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1"},s);const r=e.icon;return t.jsx(g,{content:e.title,position:"top",children:t.jsx("button",{type:"button",onClick:()=>L(e),className:"p-1.5 rounded hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors",children:t.jsx(r,{size:16})})},s)})}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("textarea",{ref:D,value:w,onChange:e=>v(e.target.value),onKeyDown:$,onPaste:A,placeholder:m("请è¾å
¥ Markdown æ ¼å¼çæç« å
容...\n\n# æ é¢\n\næ£æå
容...\n\n## äºçº§æ é¢\n\n- å表项1\n- å表项2"),className:"w-full border border-gray-200 dark:border-gray-600 rounded-b-lg p-4 font-mono text-sm leading-relaxed resize-none bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",style:{height:420,minHeight:300}}),j&&t.jsx("div",{style:{position:"absolute",bottom:8,right:12,background:"var(--semi-color-primary)",color:"#fff",padding:"2px 10px",borderRadius:4,fontSize:12},children:m("å¾çä¸ä¼ ä¸...")})]})]}),t.jsx(h,{tab:t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(T,{size:14})," ",m("é¢è§")]}),itemKey:"preview",children:t.jsx("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-6 bg-white dark:bg-gray-900 overflow-auto",style:{height:460,minHeight:300},children:(()=>
1{if(!w)return t.jsx("div",{className:"text-center text-gray-400 py-20",children:m("ææ å
容ï¼è¯·å¨ç¼è¾å¨ä¸è¾å
¥ Markdown ææ¬")});try{const e=N.sanitize(C.parse(w),ee);return t.jsx("div",{className:"article-markdown-body prose prose-slate dark:prose-invert max-w-none\n prose-headings:font-semibold\n prose-h1:text-2xl prose-h2:text-xl prose-h3:text-lg\n prose-p:text-base prose-p:leading-7\n prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline\n prose-img:rounded-lg prose-img:shadow-md\n prose-code:bg-gray-100 dark:prose-code:bg-gray-800 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded\n prose-pre:bg-gray-900 prose-pre:text-gray-100\n prose-blockquote:border-l-blue-500 prose-blockquote:bg-blue-50 dark:prose-blockquote:bg-blue-900/20 prose-blockquote:py-1\n prose-table:border-collapse\n prose-th:border prose-th:border-gray-300 prose-th:px-3 prose-th:py-2 prose-th:bg-gray-50\n prose-td:border prose-td:border-gray-300 prose-td:px-3 prose-td:py-2",dangerouslySetInnerHTML:{__html:e}})}catch{return t.jsx("div",{className:"text-red-500",children:m("Markdown è§£æé误")})}})()})})]})]})]})})})},{Title:ae,Text:ie}=u,ne=()=>{const{t:d}=s(),[c,u]=e.useState([]),[x,h]=e.useState(!1),[g,C]=e.useState(!1),[N,I]=e.useState(null),[_,T]=e.useState({currentPage:1,pageSize:10,total:0}),[D,P]=e.useState({keyword:"",status:""}),L=e.useRef(),$=async(e=1,t=10,s={})=>{h(!0);try{let a=`/api/article/?p=${e}&size=${t}`;s.keyword&&(a+=`&keyword=${s.keyword}`),""!==s.status&&void 0!==s.status&&(a+=`&status=${s.status}`);const i=await r.get(a),{data:n,total:l}=i.data;u(n||[]),T({currentPage:e,pageSize:t,total:l})}catch(i){a(i.message)}finally{h(!1)}};e.useEffect(()=>{$(_.currentPage,_.pageSize,D)},[]);const A=[{title:"ID",dataIndex:"id",width:80},{title:d("æ é¢"),dataIndex:"title"},{title:d("ç¨æ·å"),dataIndex:"author_username",width:150},{title:d("ç¨æ·è§è²"),dataIndex:"author_role",width:150,render:e=>o(e,d)},{title:d("ä¸çº§ä»£ç"),dataIndex:"author_parent_username",width:150,render:(e,s)=>{if(!(e||s.author_parent_id&&0!==s.author_parent_id))return d("æ ");const r=e||d("æªç¥");return t.jsxs(ie,{style:{cursor:"pointer"},onClick:()=>{n(e),i(d("å·²å¤å¶"))},children:[r," ",s.author_parent_id?`(ID: ${s.author_parent_id})`:""]})}},{title:d("ç¶æ"),dataIndex:"status",width:100,render:e=>{switch(e){case 0:return t.jsx(m,{color:"grey",children:d("å¾
åå¸")});case 1:return t.jsx(m,{color:"green",children:d("å·²åå¸")});case 2:return t.jsx(m,{color:"orange",children:d("已䏿¶")});default:return t.jsx(m,{children:d("æªç¥")})}}},{title:d("æµè§é"),dataIndex:"views",width:100},{title:d("å建æ¶é´"),dataIndex:"created_at",width:180,render:e=>l(e)},{title:d("æä½"),key:"action",fixed:"right",width:200,render:(e,s)=>{const n=JSON.parse(localStorage.getItem("user")),l=n?n.role:0;return l<10||l>=10&&s.author_role>=10?t.jsxs(y,{children:[1!==s.status&&t.jsx(f,{theme:"borderless",type:"primary",onClick:()=>(e=>{1!==e.status?(I(e),C(!0)):a(d("å·²åå¸çæç« ä¸è½ç´æ¥ç¼è¾ï¼è¯·å
䏿¶"))})(s),children:d("ç¼è¾")}),1!==s.status&&t.jsx(f,{theme:"borderless",type:"primary",onClick:()=>(async e=>{try{const t=await r.put(`/api/article/${e.id}`,{...e,status:1}),{success:s,message:n}=t.data;s?(i(d("å叿å")),$(_.currentPage,_.pageSize,D)):a(n||d("åå¸å¤±è´¥"))}catch(t){a(t.message)}})(s),children:d("åå¸")}),1===s.status&&t.jsx(f,{theme:"borderless",type:"warning",onClick:()=>(async e=>{S.confirm({title:d("ç¡®è®¤ä¸æ¶"),content:d("ç¡®å®è¦ä¸æ¶è¿ç¯æç« åï¼ä¸æ¶åå¯ä»¥éæ°ç¼è¾ã"),onOk:async()=>{try{const t=await r.put(`/api/article/${e.id}`,{...e,status:2}),{success:s,message:n}=t.data;s?(i(d("䏿¶æå")),$(_.currentPage,_.pageSize,D)):a(n||d("䏿¶å¤±è´¥"))}catch(t){a(t.message)}}})})(s),children:d("䏿¶")}),1!==s.status&&t.jsx(f,{theme:"borderless",type:"danger",onClick:()=>(async e=>{1!==e.status?S.confirm({title:d("确认å é¤"),content:d("ç¡®å®è¦å é¤è¿ç¯æç« å
1ï¼æ¤æä½ä¸å¯æ¢å¤ã"),onOk:async()=>{try{const t=await r.delete(`/api/article/${e.id}`),{success:s,message:n}=t.data;s?(i(d("å 餿å")),$(_.currentPage,_.pageSize,D)):a(n||d("å é¤å¤±è´¥"))}catch(t){a(t.message)}}}):a(d("å·²åå¸çæç« ä¸è½å é¤"))})(s),children:d("å é¤")})]}):t.jsx("span",{style:{color:"gray"},children:d("æ æé")})}}];return t.jsxs(t.Fragment,{children:[t.jsx(b,{className:"!rounded-2xl",title:t.jsxs("div",{className:"flex flex-col w-full",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx(ae,{heading:3,children:d("æç« 管ç")}),t.jsx(f,{theme:"solid",type:"primary",onClick:()=>{I(null),C(!0)},children:d("æ°å¢æç« ")})]}),t.jsx(z,{margin:"12px"}),t.jsx("div",{className:"mb-4",children:t.jsx(p,{ref:L,layout:"horizontal",labelPosition:"left",onSubmit:e=>{const t={keyword:e.keyword||"",status:e.status};P(t),$(1,_.pageSize,t)},className:"w-full",children:t.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-3 w-full",children:[t.jsx("div",{className:"w-full md:w-48",children:t.jsx(p.Input,{field:"keyword",placeholder:d("æç´¢æç« æ é¢"),showClear:!0,pure:!0,prefix:t.jsx(U,{size:16})})}),t.jsx("div",{className:"w-full md:w-48",children:t.jsxs(p.Select,{field:"status",placeholder:d("éæ©ç¶æ"),style:{width:"100%"},pure:!0,children:[t.jsx(p.Select.Option,{value:"",children:d("å
¨é¨ç¶æ")}),t.jsx(p.Select.Option,{value:"0",children:d("å¾
åå¸")}),t.jsx(p.Select.Option,{value:"1",children:d("å·²åå¸")}),t.jsx(p.Select.Option,{value:"2",children:d("已䏿¶")})]})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(f,{type:"primary",htmlType:"submit",children:d("æç´¢")}),t.jsx(f,{type:"tertiary",onClick:()=>{L.current.formApi.reset(),P({keyword:"",status:""}),$(1,_.pageSize,{keyword:"",status:""})},children:d("éç½®")})]})]})})})]}),shadows:"always",bordered:!1,children:t.jsx(j,{columns:A,dataSource:c,scroll:{x:"max-content"},pagination:{currentPage:_.currentPage,pageSize:_.pageSize,total:_.total,onPageChange:e=>{$(e,_.pageSize,D)}},loading:x,empty:t.jsx(k,{image:t.jsx(v,{style:{width:150,height:150}}),darkModeImage:t.jsx(w,{style:{width:150,height:150}}),description:d("ææ æç« "),style:{padding:30}})})}),t.jsx(re,{visible:g,onCancel:()=>C(!1),refresh:()=>$(_.currentPage,_.pageSize,D),editingArticle:N})]})},le=()=>t.jsx("div",{className:"px-2",children:t.jsx(ne,{})});export{le as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.