修复了2个bug
This commit is contained in:
1 parent
ce8372e878
commit
2a64dc7395
64 files changed
+1050
-39
No files matched your search
@@ -0,0 +1 @@
|
||||
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[524],{1360:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(1847).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},4577:(e,t,a)=>{"use strict";a.d(t,{BrowserAuthGuard:()=>c,BrowserAuthProvider:()=>o,ClientRedirect:()=>d,a:()=>u});var r=a(5155),n=a(2115),s=a(63),l=a(6660);let i=(0,n.createContext)(null);function o(e){let{children:t}=e,[a,s]=(0,n.useState)(null),[o,u]=(0,n.useState)("loading"),[c,d]=(0,n.useState)(null),h=(0,n.useCallback)(async e=>{try{let t=await (0,l.uK)(e);s(t),u("ready"),d(null)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;u("error"),d(e instanceof Error?e.message:"无法读取认证状态")}},[]);(0,n.useEffect)(()=>{let e=new AbortController;return h(e.signal),()=>e.abort()},[h]);let f=(0,n.useMemo)(()=>{var e,t;let r=(null==a?void 0:a.user)||null,n=null==(e=null==a?void 0:a.authRequired)||e,s=!n||(null==r?void 0:r.role)==="super_admin",l=s||(null==r?void 0:r.role)==="organization_admin";return{status:o,user:r,authMode:(null==a?void 0:a.authMode)||null,authRequired:n,authConfigured:null!=(t=null==a?void 0:a.authConfigured)&&t,isAdmin:l,isSuperAdmin:s,error:c,refresh:()=>h()}},[c,h,a,o]);return(0,r.jsx)(i.Provider,{value:f,children:t})}function u(){let e=(0,n.useContext)(i);if(!e)throw Error("useBrowserAuth must be used inside BrowserAuthProvider");return e}function c(e){let{children:t,role:a="user"}=e,i=u(),o=(0,s.usePathname)(),c=(0,s.useRouter)(),d="ready"===i.status&&i.authRequired&&!i.user;return((0,n.useEffect)(()=>{if(d){let e=(0,l.M6)(window.location,o||"/create");c.replace("/auth/login?next=".concat(encodeURIComponent(e)))}},[d,o,c]),"loading"===i.status||d)?(0,r.jsx)(h,{message:"正在确认登录状态…"}):"error"===i.status?(0,r.jsx)(h,{message:i.error||"无法读取认证状态",actionLabel:"重试",onAction:()=>void i.refresh()}):("admin"!==a||i.isAdmin)&&("super"!==a||i.isSuperAdmin)?(0,r.jsx)(r.Fragment,{children:t}):(0,r.jsx)(h,{message:"当前账号无权访问此页面。"})}function d(e){let{to:t,forwardNext:a=!1}=e;return(0,n.useEffect)(()=>{let e=a?new URLSearchParams(window.location.search).get("next"):null,r=e?"".concat(t,"?next=").concat(encodeURIComponent(e)):t;window.location.replace(r)},[a,t]),(0,r.jsx)(h,{message:"正在跳转…"})}function h(e){let{message:t,actionLabel:a,onAction:n}=e;return(0,r.jsxs)("section",{className:"panel",children:[(0,r.jsx)("p",{className:"muted",children:t}),a&&n?(0,r.jsx)("button",{className:"button",type:"button",onClick:n,children:a}):null]})}},4934:(e,t,a)=>{"use strict";a.d(t,{LogManager:()=>d});var r=a(5155),n=a(2115),s=a(6651),l=a(5299),i=a(9559),o=a(1360),u=a(7612);let c=[{id:"all",label:"全部"},{id:"error",label:"错误"},{id:"warning",label:"警告"},{id:"info",label:"信息"}];function d(){let[e,t]=(0,n.useState)(null),[a,d]=(0,n.useState)("all"),[f,m]=(0,n.useState)(""),[p,g]=(0,n.useState)(""),[v,x]=(0,n.useState)(!0),[y,j]=(0,n.useState)(!1),[w,b]=(0,n.useState)(null),[N,A]=(0,n.useState)(null),k=(0,n.useRef)(null),E=(0,n.useRef)(null),C=(0,n.useRef)(null);(0,n.useEffect)(()=>{S()},[a,f]),(0,n.useEffect)(()=>(0,u.It)(k,e=>(0,u.xr)(e)),[]),(0,n.useEffect)(()=>{(0,u.c8)(E.current)},[null==e?void 0:e.entries]),(0,n.useEffect)(()=>{(0,u.Js)(C.current)},[w,N]);let M=(0,n.useMemo)(()=>{let t=(null==e?void 0:e.entries)||[];return{total:t.length,error:t.filter(e=>"error"===e.level).length,warning:t.filter(e=>"warning"===e.level).length,info:t.filter(e=>"info"===e.level).length}},[e]);async function S(){x(!0),b(null);try{let e=new URLSearchParams({level:a,limit:"200"});f.trim()&&e.set("q",f.trim());let r=await fetch("/api/logs?".concat(e.toString()),{cache:"no-store"}),n=await r.json();if(!r.ok)throw Error(n.error||"读取日志失败");t(n)}catch(e){b(e instanceof Error?e.message:String(e))}finally{x(!1)}}async function R(){if(window.confirm("确定清空后台日志?")){j(!0),b(null),A(null);try{let e=await fetch("/api/logs",{method:"DELETE"}),t=await e.json();if(!e.ok)throw Error(t.error||"清空日志失败");A("日志已清空。"),await S()}catch(e){b(e instanceof Error?e.message:String(e))}finally{j(!1)}}}return(0,r.jsxs)("div",{className:"log-manager",ref:k,children:[(0,r.jsxs)("div",{className:"workspace-head","data-animate":!0,children:[(0,r.jsx)("div",{children:(0,r.jsx)("h1",{className:"workspace-title",children:"日志管理"})}),(0,r.jsxs)("div",{className:"workspace-meta",children:[(0,r.jsxs)("span",{className:"status",children:[M.total," 条"]}),(0,r.jsxs)("span",{className:"status failed",children:[M.error," 错误"]}),(0,r.jsxs)("span",{className:"status running",children:[M.warning," 警告"]})]})]}),(0,r.jsxs)("section",{className:"panel log-actions","data-animate":!0,children:[Line truncated
|
||||
Reference in new issue
Block a user