PageSourceSearch

https://nickz.ai/assets/js/index-C2Ymdy8t.js

js nickz.ai collected 2026-10-05 14:20:26 UTC 14,918 bytes, 1 lines download raw bytes

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:"![",suffix:"](url)",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=`![image](${t.data.data.url})`;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.