Files
jiang13-forum/embed_static/static/spa/assets/ProfilePage-CGuBSp7z.js
freefire 1d273066b0 升级帖子编辑与 Feed 体验:TipTap 富文本、修订历史、排序与编辑时限。
将 Markdown 编辑器替换为 TipTap WYSIWYG,新增帖子修订记录与 diff 展示;首页支持最新/回复排序与本地缓存;后台可配置编辑时限与锁定帖子;侧边栏整合板块导航并优化 Feed 布局。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 03:05:45 +08:00

2 lines
5.1 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.
import{e as G,r as t,j as s}from"./react-vendor-CFzzFOsg.js";import{u as _,a as F,F as L,c as l,d,e as m,b as j,f as p,o as P,s as u}from"./form-xbbJUieP.js";import{u as M,S as R,B as o,a as f,n as i}from"./index-L-Mx2Hle.js";import{I as x}from"./input-CIPYpxcv.js";import{B as U}from"./badge-e5OBoJ6g.js";import{A as W,t as D,k as J}from"./ui-vendor-DGgNN2YO.js";const V=P({nickname:u().min(1,"请输入昵称").max(64)}),q=P({old_password:u().min(1,"请输入当前密码"),new_password:u().min(6,"新密码至少 6 位"),confirm_password:u().min(1,"请确认新密码")}).refine(r=>r.new_password===r.confirm_password,{message:"两次输入的新密码不一致",path:["confirm_password"]});function Y(){const r=G(),{user:a,loading:g,refresh:v}=M(),[B,y]=t.useState(!1),[C,N]=t.useState(!1),[A,k]=t.useState(!1),h=t.useRef(null),w=_({resolver:F(V),values:{nickname:(a==null?void 0:a.nickname)??""}}),c=_({resolver:F(q),defaultValues:{old_password:"",new_password:"",confirm_password:""}});if(t.useEffect(()=>{!g&&!a&&r("/login")},[g,a,r]),g)return s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(R,{size:"lg"})});if(!a)return null;const E=async e=>{y(!0);try{await f.updateNickname(e.nickname),await v(),i.success("昵称已更新")}catch(n){i.error(n instanceof Error?n.message:"更新失败")}finally{y(!1)}},z=async e=>{N(!0);try{await f.updatePassword(e.old_password,e.new_password),i.success("密码已修改,请重新登录"),c.reset(),await f.logout(),r("/login")}catch(n){i.error(n instanceof Error?n.message:"修改失败")}finally{N(!1)}},I=async e=>{var b;const n=(b=e.target.files)==null?void 0:b[0];if(n){if(n.size>2*1024*1024){i.error("头像不能超过 2MB");return}k(!0);try{await f.uploadAvatar(n),await v(),i.success("头像已更新")}catch(S){i.error(S instanceof Error?S.message:"上传失败")}finally{k(!1),h.current&&(h.current.value="")}}};return s.jsx("div",{className:"page-wrap",children:s.jsxs("div",{className:"page-inner-wide",style:{maxWidth:640},children:[s.jsxs(o,{variant:"ghost",className:"mb-3",onClick:()=>r(-1),children:[s.jsx(W,{}),"返回"]}),s.jsxs("div",{className:"profile-header",children:[s.jsx("div",{className:"profile-avatar-lg",children:a.avatar?s.jsx("img",{src:a.avatar,alt:""}):a.nickname[0]}),s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",style:{marginBottom:4},children:a.nickname}),s.jsxs("div",{style:{fontSize:13,color:"var(--color-text-3)"},children:["@",a.username]}),a.role==="admin"&&s.jsx(U,{variant:"green",className:"mt-1.5",children:"管理员"})]})]}),a.role==="admin"&&s.jsxs("div",{className:"section-card admin-entry-card",children:[s.jsx("div",{className:"section-card-title",children:"管理员入口"}),s.jsx("p",{style:{fontSize:13,color:"var(--color-text-3)",margin:"0 0 12px"},children:"管理板块、用户、帖子及系统设置"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(o,{variant:"outline",onClick:()=>r("/admin/boards"),children:[s.jsx(D,{}),"管理板块"]}),s.jsxs(o,{onClick:()=>r("/admin/dashboard"),children:[s.jsx(J,{}),"进入系统后台"]})]})]}),s.jsxs("div",{className:"section-card",children:[s.jsx("div",{className:"section-card-title",children:"基本资料"}),s.jsx(L,{...w,children:s.jsxs("form",{onSubmit:w.handleSubmit(E),className:"space-y-4",children:[s.jsxs(l,{children:[s.jsx(d,{children:"用户名"}),s.jsx(m,{children:s.jsx(x,{value:a.username,disabled:!0})})]}),s.jsx(j,{control:w.control,name:"nickname",render:({field:e})=>s.jsxs(l,{children:[s.jsx(d,{children:"昵称"}),s.jsx(m,{children:s.jsx(x,{maxLength:64,placeholder:"显示名称",...e})}),s.jsx(p,{})]})}),s.jsx(o,{type:"submit",loading:B,children:"保存昵称"})]})})]}),s.jsxs("div",{className:"section-card",children:[s.jsx("div",{className:"section-card-title",children:"头像"}),s.jsx("p",{style:{fontSize:13,color:"var(--color-text-3)",margin:"0 0 12px"},children:"支持 JPG、PNG、GIF、WebP不超过 2MB"}),s.jsx("input",{ref:h,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",style:{display:"none"},onChange:I}),s.jsx(o,{variant:"outline",loading:A,onClick:()=>{var e;return(e=h.current)==null?void 0:e.click()},children:"选择图片上传"})]}),s.jsxs("div",{className:"section-card",children:[s.jsx("div",{className:"section-card-title",children:"修改密码"}),s.jsx(L,{...c,children:s.jsxs("form",{onSubmit:c.handleSubmit(z),className:"space-y-4",children:[s.jsx(j,{control:c.control,name:"old_password",render:({field:e})=>s.jsxs(l,{children:[s.jsx(d,{children:"当前密码"}),s.jsx(m,{children:s.jsx(x,{type:"password",placeholder:"输入当前密码",...e})}),s.jsx(p,{})]})}),s.jsx(j,{control:c.control,name:"new_password",render:({field:e})=>s.jsxs(l,{children:[s.jsx(d,{children:"新密码"}),s.jsx(m,{children:s.jsx(x,{type:"password",placeholder:"至少 6 位",...e})}),s.jsx(p,{})]})}),s.jsx(j,{control:c.control,name:"confirm_password",render:({field:e})=>s.jsxs(l,{children:[s.jsx(d,{children:"确认新密码"}),s.jsx(m,{children:s.jsx(x,{type:"password",placeholder:"再次输入新密码",...e})}),s.jsx(p,{})]})}),s.jsx(o,{type:"submit",variant:"destructive",loading:C,children:"修改密码"})]})})]})]})})}export{Y as default};