Files
tangzhuan-yu/static/assets/UserManagement-ClhaMsDE.js
T
jinghui d33349ccbc v3.6.9: 账号管理登录有效期提示与失效处理说明
- 后端 /cookies/details 新增 login_info:最近 token 刷新/cookie 续期/连接活动时间戳、
  密码是否已设、cookie_invalid 失效通知是否已绑定启用渠道、账号加入时间
- 账号卡片新增登录状态行:登录有效/最近续期/最近活跃 + 密码与失效通知就绪提示
- need_relogin 红条按是否已设密码分支提示(未设密码引导补填以自动重登)
- 页面顶部新增「关于登录有效期与失效处理」说明块:有效期机制/失效通知/处理步骤/
  提高稳定性四条
2026-11-16 11:22:24 +08:00

2 lines
6.6 KiB
JavaScript
Vendored
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.
import{r as l,j as e,U as h,e as $,S as j,aT as A,L as f,ak as T,bz as L,n as i,v as y,bA as P,bB as R,aY as E,bC as _}from"./index-CkAjw-Zl.js";import{a as I,S as N,E as B}from"./ui-DGhuFsSA.js";import{T as z}from"./trash-2-H_4vB0ks.js";const D=n=>{if(!n)return"-";const c=new Date(n.includes("T")?n:`${n.replace(" ","T")}Z`);return Number.isNaN(c.getTime())?n:c.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})},Y=()=>{const[n,c]=l.useState([]),[u,g]=l.useState(!0),[o,d]=l.useState(null),[w,p]=l.useState(null),[b,m]=l.useState(""),x=async()=>{g(!0);try{c(await L())}catch(t){i(`加载用户列表失败:${t.message}`,"error")}finally{g(!1)}};l.useEffect(()=>{x()},[]);const U=async t=>{if(o!==null)return;const s=t.is_active!==!1;if(!(s&&!await y(`禁用用户「${t.username}」?其所有在线会话将立即下线,且无法再登录。`,{title:"禁用用户",confirmLabel:"禁用",danger:!0}))){d(t.id);try{const a=await P(t.id,!s);i(a.message||"状态已更新","success"),await x()}catch(a){i(`操作失败:${a.message}`,"error")}finally{d(null)}}},C=async t=>{const[s,a]=E(b);if(!s){i(a,"warning");return}if(o===null){d(t.id);try{const r=await _(t.id,b);i(r.message||"密码已重置","success"),p(null),m("")}catch(r){i(`重置失败:${r.message}`,"error")}finally{d(null)}}},k=async t=>{if(o===null&&await y(`删除用户「${t.username}」?其名下的闲鱼账号、卡密、回复规则等数据将一并删除,不可恢复。`,{title:"删除用户",confirmLabel:"删除",danger:!0})){d(t.id);try{const s=await R(t.id);i(s.message||"用户已删除","success"),await x()}catch(s){i(`删除失败:${s.message}`,"error")}finally{d(null)}}};return e.jsxs("div",{className:"page-stack",children:[e.jsx(I,{title:"用户管理",description:"管理注册用户与登录权限。普通用户仅能操作分配给其名下的账号数据。",icon:h,actions:e.jsxs("button",{type:"button",onClick:()=>void x(),className:"ios-btn-secondary flex items-center gap-2 rounded-md px-4 py-2.5 text-sm",children:[e.jsx($,{className:`h-4 w-4 ${u?"animate-spin":""}`}),"刷新"]})}),e.jsxs("section",{className:"section-panel",children:[e.jsx(N,{title:"权限说明",icon:j}),e.jsxs("div",{className:"grid gap-3 p-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface-subtle)] p-3.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-bold text-[var(--text)]",children:[e.jsx(j,{className:"h-4 w-4 text-[#8a6300]"}),"管理员(admin)"]}),e.jsx("p",{className:"mt-1.5 text-xs leading-5 text-[var(--text-muted)]",children:"拥有全部权限:系统设置、通知与系统日志、用户管理,以及所有闲鱼账号和数据。"})]}),e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface-subtle)] p-3.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-bold text-[var(--text)]",children:[e.jsx(A,{className:"h-4 w-4 text-[var(--text-soft)]"}),"普通用户"]}),e.jsx("p",{className:"mt-1.5 text-xs leading-5 text-[var(--text-muted)]",children:"只能看到并操作自己名下的闲鱼账号、商品、订单与消息;侧栏不显示系统设置与用户管理,接口层也会拒绝其访问。"})]})]})]}),e.jsxs("section",{className:"section-panel",children:[e.jsx(N,{title:"用户列表",description:`共 ${n.length} 个用户`,icon:h}),e.jsxs("div",{className:"divide-y divide-[var(--border)]",children:[n.map(t=>{const s=t.username==="admin",a=t.is_active===!1,r=o===t.id,v=w===t.id;return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--brand)] text-sm font-black text-[#2a2416]",children:t.username.slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-sm font-bold text-[var(--text)]",children:t.username}),s&&e.jsx("span",{className:"rounded-full bg-[var(--brand)] px-2 py-0.5 text-[10px] font-bold text-[#2a2416]",children:"内置管理员"}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-bold ${a?"bg-red-50 text-red-600":"bg-emerald-50 text-emerald-600"}`,children:a?"已禁用":"正常"})]}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:t.email}),e.jsxs("p",{className:"mt-1 text-[11px] text-[var(--text-soft)]",children:[t.cookie_count??0," 个闲鱼账号 · ",t.card_count??0," 张卡密 · 注册于 ",D(t.created_at)]})]}),!s&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void U(t),disabled:r,className:a?"rounded-md bg-emerald-50 px-3 py-2 text-xs font-bold text-emerald-700 hover:bg-emerald-100 disabled:opacity-50":"rounded-md bg-amber-50 px-3 py-2 text-xs font-bold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:r?e.jsx(f,{className:"h-4 w-4 animate-spin"}):a?"启用":"禁用"}),e.jsx("button",{type:"button",onClick:()=>{p(v?null:t.id),m("")},disabled:r,title:"重置密码",className:"flex h-9 w-9 items-center justify-center rounded-md bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] disabled:opacity-50",children:e.jsx(T,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>void k(t),disabled:r,title:"删除用户",className:"flex h-9 w-9 items-center justify-center rounded-md bg-red-50 text-red-600 hover:bg-red-100 disabled:opacity-50",children:e.jsx(z,{className:"h-4 w-4"})})]})]}),v&&!s&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 rounded-lg border border-[var(--border)] bg-[var(--surface-subtle)] p-3",children:[e.jsx("input",{type:"password",value:b,onChange:S=>m(S.target.value),placeholder:"新密码:至少 8 位,含字母和数字",autoComplete:"new-password",className:"ios-input h-10 min-w-0 flex-1 rounded-md px-3 text-sm"}),e.jsx("button",{type:"button",onClick:()=>void C(t),disabled:r,className:"ios-btn-primary h-10 rounded-md px-4 text-sm disabled:opacity-50",children:r?e.jsx(f,{className:"h-4 w-4 animate-spin"}):"确认重置"}),e.jsx("button",{type:"button",onClick:()=>{p(null),m("")},className:"ios-btn-secondary h-10 rounded-md px-4 text-sm",children:"取消"})]})]},t.id)}),!u&&n.length===0&&e.jsx(B,{compact:!0,title:"暂无用户",description:"开放注册后,新注册的用户会出现在这里。",icon:h}),u&&e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(f,{className:"h-6 w-6 animate-spin text-[#d6b600]"})})]})]})]})};export{Y as default};