Files
YelayMaths/yelaymaths_admin/.next/static/chunks/app/(admin)/page-446928f870021874.js
T
2026-09-29 19:34:24 +08:00

1 line
7.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[971],{1910:(e,t,n)=>{"use strict";n.d(t,{L:()=>l,M3:()=>o,WG:()=>s,gf:()=>a});let r="yelay_admin_token";function a(){var e;return null!=(e=window.localStorage.getItem(r))?e:""}function s(e){window.localStorage.setItem(r,e)}function l(){window.localStorage.removeItem(r)}function o(){return""!==a()}},2787:(e,t,n)=>{"use strict";n.d(t,{$T:()=>c,$n:()=>a,Sv:()=>u,TM:()=>l,Zp:()=>d,aF:()=>i,l6:()=>o,pd:()=>s});var r=n(1333);function a(e){let{children:t,onClick:n,variant:a="primary",disabled:s,type:l="button"}=e;return(0,r.jsx)("button",{type:l,onClick:n,disabled:s,className:"rounded-md px-3 py-1.5 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-50 ".concat({primary:"bg-blue-600 text-white hover:bg-blue-700",ghost:"bg-white text-gray-700 border border-gray-300 hover:bg-gray-50",danger:"bg-red-600 text-white hover:bg-red-700"}[a]),children:t})}function s(e){let{value:t,onChange:n,placeholder:a,type:s="text"}=e;return(0,r.jsx)("input",{type:s,value:t,placeholder:a,onChange:e=>n(e.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm outline-none focus:border-blue-500"})}function l(e){let{value:t,onChange:n}=e;return(0,r.jsx)("textarea",{value:t,rows:6,onChange:e=>n(e.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-1.5 font-mono text-xs outline-none focus:border-blue-500"})}function o(e){let{value:t,onChange:n,options:a}=e;return(0,r.jsx)("select",{value:t,onChange:e=>n(e.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm outline-none focus:border-blue-500",children:a.map(e=>(0,r.jsx)("option",{value:String(e.value),children:e.label},e.value))})}function d(e){let{title:t,children:n,action:a}=e;return(0,r.jsxs)("section",{className:"rounded-lg border border-gray-200 bg-white p-5 shadow-sm",children:[(t||a)&&(0,r.jsxs)("header",{className:"mb-4 flex items-center justify-between",children:[t&&(0,r.jsx)("h2",{className:"text-base font-semibold text-gray-900",children:t}),a]}),n]})}function i(e){let{open:t,title:n,onClose:a,children:s,footer:l}=e;return t?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:(0,r.jsxs)("div",{className:"max-h-[85vh] w-full max-w-2xl overflow-auto rounded-lg bg-white shadow-xl",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between border-b border-gray-200 px-5 py-3",children:[(0,r.jsx)("h3",{className:"text-base font-semibold",children:n}),(0,r.jsx)("button",{onClick:a,className:"text-gray-400 hover:text-gray-600","aria-label":"关闭",children:"✕"})]}),(0,r.jsx)("div",{className:"px-5 py-4",children:s}),l&&(0,r.jsx)("footer",{className:"flex justify-end gap-2 border-t border-gray-200 px-5 py-3",children:l})]})}):null}function c(e){let{message:t,kind:n="error"}=e;return t?(0,r.jsx)("div",{className:"mb-3 rounded-md border px-3 py-2 text-sm ".concat("error"===n?"bg-red-50 text-red-700 border-red-200":"bg-green-50 text-green-700 border-green-200"),children:t}):null}function u(e){let{text:t="暂无数据"}=e;return(0,r.jsx)("div",{className:"py-10 text-center text-sm text-gray-400",children:t})}},4978:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(1333),a=n(4705),s=n(8312),l=n(2787);function o(){let[e,t]=(0,a.useState)(null),[n,o]=(0,a.useState)("");return(0,a.useEffect)(()=>{s.F.stats().then(t).catch(e=>o(e.message))},[]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-gray-900",children:"数据看板"}),(0,r.jsx)(l.$T,{message:n}),e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[(0,r.jsx)(d,{label:"用户总数",value:String(e.users)}),(0,r.jsx)(d,{label:"在售课程",value:String(e.courses)}),(0,r.jsx)(d,{label:"累计订单",value:String(e.orders)}),(0,r.jsx)(d,{label:"已开通",value:String(e.delivered)}),(0,r.jsx)(d,{label:"已退款",value:String(e.refunded)}),(0,r.jsx)(d,{label:"成交金额(元)",value:(e.revenueFen/100).toFixed(2)}),(0,r.jsx)(d,{label:"支付能力",value:e.payEnabled?1===e.payEnv?"已配置 \xb7 沙箱":"已配置 \xb7 现网":"未配置"})]}),!e.payEnabled&&(0,r.jsx)(l.Zp,{title:"支付尚未启用",children:(0,r.jsx)("p",{className:"text-sm text-gray-600",children:"服务端未配置虚拟支付参数(WX_OFFER_ID / WX_PAY_APPKEY),用户暂时无法购买课程。 请在微信小程序后台开通虚拟支付后,将 OfferID 与现网 AppKey 写入服务端环境变量。"})}),e.payEnabled&&1===e.payEnv&&(0,r.jsx)(l.Zp,{title:"当前处于沙箱环境",children:(0,r.jsx)("p",{className:"text-sm text-gray-600",children:"支付走的是沙箱密钥,不会产生真实扣款,用户也不会真正获得课程。 正式收款前请把服务端的 WX_PAY_ENV 改回 0 并重启。"})})]}):(0,r.jsx)("div",{className:"text-sm text-gray-400",children:"加载中…"})]})}function d(e){let{label:t,value:n}=e;return(0,r.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-white px-4 py-3 shadow-sm",children:[(0,r.jsx)("div",{className:"text-xs text-gray-500",children:t}),(0,r.jsx)("div",{className:"mt-1 text-2xl font-semibold text-gray-900",children:n})]})}},8312:(e,t,n)=>{"use strict";n.d(t,{F:()=>o});var r=n(1910);let a="http://127.0.0.1:3000".replace(/\/+$/,"");async function s(e){var t,n,s,l,o;let d,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=(0,r.gf)(),u={"content-type":"application/json",...null!=(t=i.headers)?t:{}};c&&(u.Authorization="Bearer ".concat(c));try{d=await fetch("".concat(a).concat(e),{...i,headers:u})}catch(e){throw{code:-1,message:"无法连接服务端,请检查网络或接口地址"}}let m=null;try{m=await d.json()}catch(e){throw{code:-1,message:"服务端返回异常(HTTP ".concat(d.status,")")}}if(401===d.status)throw(0,r.L)(),window.location.pathname.startsWith("/login")||(window.location.href="/login"),{code:null!=(n=null==m?void 0:m.code)?n:2e3,message:null!=(s=null==m?void 0:m.message)?s:"登录已失效,请重新登录"};if(!m||0!==m.code)throw{code:null!=(l=null==m?void 0:m.code)?l:-1,message:null!=(o=null==m?void 0:m.message)?o:"请求失败"};return m.data}let l=e=>{let t=Object.entries(e).filter(e=>{let[,t]=e;return void 0!==t&&""!==t}).map(e=>{let[t,n]=e;return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(String(n)))});return t.length?"?".concat(t.join("&")):""},o={base:a,request:s,login:(e,t)=>s("/admin/v1/auth/login",{method:"POST",body:JSON.stringify({username:e,password:t})}),bootstrap:(e,t)=>s("/admin/v1/auth/bootstrap",{method:"POST",body:JSON.stringify({username:e,password:t})}),stats:()=>s("/admin/v1/stats"),listUsers:(e,t,n)=>s("/admin/v1/users".concat(l({page:e,pageSize:t,keyword:n}))),updateUser:(e,t)=>s("/admin/v1/users/".concat(e),{method:"PATCH",body:JSON.stringify(t)}),listResource:(e,t)=>s("/admin/v1/data/".concat(e).concat(l(t))),createResource:(e,t)=>s("/admin/v1/data/".concat(e),{method:"POST",body:JSON.stringify(t)}),updateResource:(e,t,n)=>s("/admin/v1/data/".concat(e,"/").concat(t),{method:"PATCH",body:JSON.stringify(n)}),deleteResource:(e,t)=>s("/admin/v1/data/".concat(e,"/").concat(t),{method:"DELETE"}),listSettings:()=>s("/admin/v1/settings"),upsertSetting:(e,t,n)=>s("/admin/v1/settings",{method:"PUT",body:JSON.stringify({key:e,value:t,remark:n})}),listOrders:(e,t,n)=>s("/admin/v1/orders".concat(l({page:e,pageSize:t,status:n}))),refundOrder:(e,t)=>s("/admin/v1/orders/".concat(e,"/refund"),{method:"POST",body:JSON.stringify({reason:t})}),listEntitlements:e=>s("/admin/v1/entitlements".concat(l({userId:e}))),grantEntitlement:(e,t,n)=>s("/admin/v1/entitlements",{method:"POST",body:JSON.stringify({userId:e,courseId:t,note:n})}),revokeEntitlement:(e,t)=>s("/admin/v1/entitlements".concat(l({userId:e,courseId:t})),{method:"DELETE"})}},9631:(e,t,n)=>{Promise.resolve().then(n.bind(n,4978))}},e=>{e.O(0,[964,857,358],()=>e(e.s=9631)),_N_E=e.O()}]);