PageSourceSearch

https://www.daohang.info/assets/Profile-o0NkNeYL.js

js daohang.info collected 2026-10-02 01:57:03 UTC 10,972 bytes, 6 lines download raw bytes

1import{c as E,h as L,u as M,r,j as e,B as u,I as c,G as Q,i as q,T as A,U,t as h}from"./main-C79EErcN.js";import{S as z}from"./Select-B3rCKERi.js";import{S as n,T}from"./Switch-B37A862P.js";import{I as D}from"./ImageUpload-COvn1ZPW.js";import{L as R}from"./LetterAvatar-c24BKTJg.js";import{C as f}from"./circle-check-C573Tr91.js";import{M as B}from"./mail-CDOgDkti.js";import{M as G,P as H,a as j}from"./phone-BfPbhyRX.js";import{S as F}from"./send-DQ86CC-4.js";import{P as O}from"./PageLayout-CdIn63Zq.js";import{P as V}from"./PageHeader-9AEgnBf5.js";import{S as _}from"./SettingsCard-CkS9Bg5F.js";import"./vendor-B--z-fyW.js";import"./utils-BJmlP30g.js";import"./chevron-down-DR5a0cMA.js";/**
2 * @license lucide-react v0.562.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const W=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],$=E("circle-user",W),J={sendEmailChangeCode:async a=>L.post("/user/email/send-code",{email:a})},me=()=>{var C;const{user:a,updateProfile:S,fetchProfile:y}=M(),[b,v]=r.useState(!1),[s,p]=r.useState({account:"",nickname:"",email:"",email_verification_code:"",is_email_public:0,phone:"",is_phone_public:0,wechat:"",is_wechat_public:0,qq:"",is_qq_public:0,avatar:"",gender:0,birthday:"",is_birthday_public:0,location:"",is_location_public:0,website:"",is_website_public:0,bio:""}),[d,N]=r.useState(0),[w,k]=r.useState(!1);r.useEffect(()=>{let i;return d>0&&(i=setInterval(()=>{N(t=>t-1)},1e3)),()=>clearInterval(i)},[d]),r.useEffect(()=>{y()},[y]),r.useEffect(()=>{a&&p({account:a.account||"",nickname:a.nickname||"",email:a.email||"",is_email_public:a.is_email_public??0,phone:a.phone||"",is_phone_public:a.is_phone_public??0,wechat:a.wechat||"",is_wechat_public:a.is_wechat_public??0,qq:a.qq||"",is_qq_public:a.is_qq_public??0,avatar:a.avatar||"",gender:a.gender||0,birthday:a.birthday||"",is_birthday_public:a.is_birthday_public??0,location:a.location||"",is_location_public:a.is_location_public??0,website:a.website||"",is_website_public:a.is_website_public??0,bio:a.bio||"",email_verification_code:""})},[a]);const l=i=>{const{name:t,value:o,type:m}=i.target;if(m==="checkbox"){const x=i.target.checked;p(g=>({...g,[t]:x?1:0}))}else{const x=t==="gender"?parseInt(o,10):o;p(g=>({...g,[t]:x}))}},I=async()=>{const i=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;if(!s.email||!i.test(s.email)){h.error("请先输入有效的电子邮箱地址");return}if(s.email===(a==null?void 0:a.email)){h.error("新邮箱不能与当前邮箱相同");return}k(!0);try{await J.sendEmailChangeCode(s.email),N(60),h.success("验证码已发送至新邮箱")}catch(t){console.error("Send code failed",t)}finally{k(!1)}},P=async i=>{var t,o;i.preventDefault(),v(!0);try{await S(s),h.success("个人资料已更新")}catch(m){console.error("Update failed",m);const x=((o=(t=m.response)==null?void 0:t.data)==null?void 0:o.message)||m.message||"更新失败,请重试";h.error(x)}finally{v(!1)}};return e.jsxs(O,{children:[e.jsx(V,{title:"个人资料管理",description:"完善您的个人信息,展示您的个性",action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{variant:"secondary",onClick:()=>window.location.reload(),disabled:b,children:"取消"}),e.jsx(u,{type:"submit",form:"profile-form",isLoading:b,children:"保存更改"})]})}),e.jsxs("form",{id:"profile-form",onSubmit:P,className:"space-y-6",children:[e.jsx(_,{title:"基本信息",icon:e.jsx($,{className:"w-5 h-5"}),children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-8 items-start",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"头像"}),e.jsx(D,{value:s.avatar,onChange:i=>p(t=>({...t,avatar:i})),placeholder:"上传头像",aspectRatio:"square",className:"w-32 h-32",uploadOptions:{maxWidth:200,maxHeight:200},type:"avatars",renderPreview:i=>e.jsx("div",{className:"w-32 h-32 rounded-full overflow-hidden border-4 border-white dark:border-gray-700 shadow-sm transition-transform hover:scale-105 bg-gray-100 dark:bg-gray-700 flex items-center justify-center",children:i?e.jsx("img",{src:i,alt:"Avatar",className:"w-full h-full object-cover"}):e.jsx(R,{name:s.nickname||(a==null?void 0:a.account)||"?",rounded:"full",className:"w-full h-full text-4xl"})})})]}),e.jsxs("div",{className:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-4 w-full",children:[e.jsx(c,{label:"账号",name:"account",value:s.account,onChange:l,disabled:!0,className:"bg-gray-50 dark:bg-gray-700 cursor-not-allowed"}),e.jsx(c,{label:"昵称",name:"nickname",placeholder:"起个好听的名字",value:s.nickname,onChange:l}
6),e.jsx(z,{label:"性别",name:"gender",value:s.gender,onChange:l,options:[{label:"保密",value:0},{label:"男",value:1},{label:"女",value:2}]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(c,{label:"生日",name:"birthday",type:"date",value:s.birthday,onChange:l}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{label:"公开生日",name:"is_birthday_public",checked:!!s.is_birthday_public,onChange:l})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(c,{label:"所在地",name:"location",placeholder:"如:北京 · 朝阳",value:s.location,onChange:l,leftIcon:e.jsx(G,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{label:"公开所在地",name:"is_location_public",checked:!!s.is_location_public,onChange:l})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(c,{label:"个人主页",name:"website",placeholder:"https://yourpage.com",value:s.website,onChange:l,leftIcon:e.jsx(Q,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{label:"公开个人主页",name:"is_website_public",checked:!!s.is_website_public,onChange:l})})]})]})]})}),e.jsx(_,{title:"联系方式与隐私",icon:e.jsx(j,{className:"w-5 h-5"}),children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-3 p-4 rounded-lg bg-gray-50 dark:bg-gray-900/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center text-gray-700 dark:text-gray-300",children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"text-sm font-medium",children:"电子邮箱"})]}),a!=null&&a.email_verified_at?e.jsxs("span",{className:"flex items-center text-xs text-green-600 bg-green-50 dark:bg-green-900/20 dark:text-green-400 px-2 py-0.5 rounded-full font-medium",children:[e.jsx(f,{className:"w-3 h-3 mr-1"})," 已验证"]}):e.jsxs("span",{className:"flex items-center text-xs text-amber-600 bg-amber-50 dark:bg-amber-900/20 dark:text-amber-400 px-2 py-0.5 rounded-full font-medium",children:[e.jsx(q,{className:"w-3 h-3 mr-1"})," 未验证"]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-1",children:e.jsx(c,{name:"email",type:"email",value:s.email,onChange:l,placeholder:"新系统邮箱"})}),e.jsx("div",{className:"flex justify-end pt-1.5",children:e.jsx(n,{label:"公开展示",name:"is_email_public",checked:!!s.is_email_public,onChange:l})})]}),(a==null?void 0:a.email)!==s.email&&e.jsxs("div",{className:"flex gap-3 animate-in fade-in slide-in-from-top-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(c,{name:"email_verification_code",value:s.email_verification_code,onChange:l,placeholder:"6位验证码",maxLength:6})}),((C=s.email_verification_code)==null?void 0:C.length)===6?e.jsx(u,{type:"submit",isLoading:b,className:"h-10 px-4 whitespace-nowrap",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(f,{size:14}),"确认保存"]})}):e.jsx(u,{type:"button",variant:"outline",onClick:I,disabled:d>0||w||!s.email,className:"h-10 px-4 whitespace-nowrap",children:w?e.jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):d>0?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(A,{size:14}),d,"s"]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(F,{size:14}),"获取验证码"]})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"修改邮箱需要向新邮箱发送验证码并完成校验。"})]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg bg-gray-50 dark:bg-gray-900/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center text-gray-700 dark:text-gray-300",children:[e.jsx(H,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"text-sm font-medium",children:"手机号码"})]}),a!=null&&a.phone_verified_at?e.jsxs("span",{className:"flex items-center text-xs text-green-600 bg-green-50 dark:bg-green-900/20 dark:text-green-400 px-2 py-0.5 rounded-full font-medium",children:[e.jsx(f,{className:"w-3 h-3 mr-1"})," 已验证"]}):e.jsxs("span",{className:"flex items-center text-xs text-gray-500 bg-gray-50 dark:bg-gray-800 dark:text-gray-400 px-2 py-0.5 rounded-full font-medium",children:[e.jsx(q,{className:"w-3 h-3 mr-1"})," 未验证"]})]}),e.jsx(c,{name:"phone",placeholder:"输入手机号",value:s.phone,onChange:l}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{label:"公开展示手机号",name:"is_phone_public",checked:!!s.is_phone_public,onChange:l})})]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg bg-gray-50 dark:bg-gray-900/50",children:[e.jsxs("div",{className:"flex items-center text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx(j,{className:"w-4 h-4 mr-2 text-green-500"}),e.jsx("span",{className:"text-sm font-medium",children:"微信"})]}),e.jsx(c,{name:"wechat",placeholder:"微信号",value:s.wechat,onChange:l}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{label:"公开展示微信",name:"is_wechat_public",checked:!!s.is_wechat_public,onChange:l})})]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg bg-gray-50 dark:bg-gray-900/50",children:[e.jsxs("div",{className:"flex items-center text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx(j,{className:"w-4 h-4 mr-2 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"QQ"})]}),e.jsx(c,{name:"qq",placeholder:"QQ号码",value:s.qq,onChange:l}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{label:"公开展示QQ",name:"is_qq_public",checked:!!s.is_qq_public,onChange:l})})]})]})}),e.jsxs(_,{title:"个人主页介绍",icon:e.jsx(U,{className:"w-5 h-5"}),children:[e.jsx(T,{label:"个人简介",name:"bio",placeholder:"简单介绍一下自己,或者您的导航站...",rows:5,value:s.bio,onChange:l,className:"resize-none"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"支持换行。此简介将展示在您的公开主页上,让访客更了解您。"})]})]})]})};export{me 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.