7 lines
5.6 KiB
JavaScript
7 lines
5.6 KiB
JavaScript
import{c as U,u as C,d as E,r as p,f as F,g as S,j as e,B as f,l as q,a9 as B,F as z,H as k,S as M,I as Q,aa as _,ab as K,ac as v,ad as L}from"./index-CSVqyJB0.js";/**
|
|
* @license lucide-react v0.475.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const T=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],D=U("Upload",T),r={name:"",gender:"",birth:"",nation:"",native:"",political:"",school:"",college:"",major:"",className:"",studentId:"",degree:"",phone:"",email:"",homepage:"",photoUrl:"",selfIntro:""},N=[{title:"基本信息",fields:[{key:"name",label:"姓名"},{key:"gender",label:"性别",options:["","男","女"]},{key:"birth",label:"出生日期",type:"date"},{key:"nation",label:"民族"},{key:"native",label:"籍贯"},{key:"political",label:"政治面貌"}]},{title:"学校信息",fields:[{key:"school",label:"学校"},{key:"college",label:"学院"},{key:"major",label:"专业"},{key:"className",label:"班级"},{key:"studentId",label:"学号"},{key:"degree",label:"学历层次",options:["","专科","本科","硕士研究生","博士研究生"]}]},{title:"联系方式",fields:[{key:"phone",label:"手机"},{key:"email",label:"邮箱"},{key:"homepage",label:"个人主页 / 博客"}]}];function H(){var g,j;const m=C(),o=E(),[w,n]=p.useState(!1),[i,d]=p.useState(r),[h,u]=p.useState(!1),b=F({queryKey:["profile"],queryFn:L}),a=((j=(g=b.data)==null?void 0:g.content)==null?void 0:j.info)??{},c=t=>d(s=>({...r,...s,...t})),I=()=>{d({...r,...a}),n(!0)},y=S({mutationFn:()=>v({info:i}),onSuccess:()=>{o("success","个人信息已保存"),n(!1),m.invalidateQueries({queryKey:["profile"]})},onError:t=>o("error",t.message)}),P=async t=>{if(t){u(!0);try{const s=await K(t),l={...r,...i,photoUrl:s};d(l),await v({info:l}),m.invalidateQueries({queryKey:["profile"]}),o("success","证件照已上传")}catch(s){o("error",s.message)}u(!1)}},x=a.photoUrl;return e.jsxs("div",{className:"mx-auto max-w-[880px] px-3 py-4 sm:px-6 sm:py-5",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-ink-1",children:"个人信息"}),e.jsxs(f,{variant:"primary",onClick:I,children:[e.jsx(q,{size:13})," 编辑"]})]}),b.isLoading?e.jsx("div",{className:"py-16 text-center text-[13px] text-ink-3",children:"加载中…"}):e.jsxs("div",{className:"rounded-lg border border-line bg-surface shadow-card",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b border-line p-4 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"flex size-20 shrink-0 items-center justify-center overflow-hidden rounded-full border border-line bg-surface-2",children:x?e.jsx("img",{src:x,alt:"证件照",className:"h-full w-full object-cover"}):e.jsx(B,{size:32,className:"text-ink-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[17px] font-semibold text-ink-1",children:a.name||"未填写姓名"}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-3",children:[a.school,a.college,a.major].filter(Boolean).join(" · ")||"完善学校信息后,简历将自动填充"})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 text-[12px] text-ink-2 transition-colors hover:border-line-strong",children:[e.jsx(D,{size:13}),h?"上传中…":x?"更换证件照":"上传证件照",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:h,onChange:t=>{var s;P((s=t.target.files)==null?void 0:s[0]),t.target.value=""}})]})]}),N.map(t=>e.jsxs("div",{className:"border-b border-line px-4 py-3 last:border-b-0",children:[e.jsx("div",{className:"mb-2 text-[12px] font-semibold text-ink-2",children:t.title}),e.jsx("dl",{className:"grid grid-cols-1 gap-x-6 gap-y-1.5 sm:grid-cols-2",children:t.fields.map(s=>{const l=a[s.key]||"";return e.jsxs("div",{className:"grid min-w-0 grid-cols-[84px_1fr] gap-x-2.5 py-0.5",children:[e.jsx("dt",{className:"shrink-0 text-right text-[12px] text-ink-3",children:s.label}),e.jsx("dd",{className:"min-w-0 truncate text-[12.5px] "+(l?"text-ink-1":"text-ink-3/60"),title:l,children:l||"未填写"})]},s.key)})})]},t.title))]}),!a.selfIntro&&e.jsx("div",{className:"mt-3 rounded-md border border-dashed border-line px-4 py-2.5 text-[12px] text-ink-3",children:"提示:编辑里填写「自我评价」后,可一键用于简历生成。"}),e.jsx(z,{open:w,onClose:()=>n(!1),width:720,title:"编辑个人信息",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-auto text-[12px] text-ink-3",children:"填写一次,填表与简历自动复用"}),e.jsx(f,{variant:"primary",onClick:()=>y.mutate(),disabled:y.isPending,children:"保存"})]}),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[N.map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[12px] font-semibold text-ink-2",children:t.title}),e.jsx("div",{className:"grid grid-cols-1 gap-x-3 gap-y-3 sm:grid-cols-2",children:t.fields.map(s=>e.jsx(k,{label:s.label,children:s.options?e.jsx(M,{value:i[s.key]||"",onChange:l=>c({[s.key]:l.target.value}),options:s.options.map(l=>({value:l,label:l||"未选择"}))}):e.jsx(Q,{type:s.type||"text",value:i[s.key]||"",onChange:l=>c({[s.key]:l.target.value})})},s.key))})]},t.title)),e.jsx("div",{className:"border-t border-line pt-3",children:e.jsx(k,{label:"自我评价",hint:"简历「自我评价」板块使用",children:e.jsx(_,{rows:4,value:i.selfIntro,onChange:t=>c({selfIntro:t.target.value}),placeholder:"简述性格、能力、方向…"})})})]})})]})}export{H as ProfilePage};
|