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.