import{i as e,t}from"./react-B8IZ02wI.js";import{t as n}from"./button-DqbiydrF.js";import{t as r}from"./typography-Chzsf8_A.js";import{O as i,P as a,d as o,i as s,n as c}from"./authStore-BvQBJ9ky.js";import{A as l,An as u,D as d,E as f,F as p,M as m,On as h,R as g,Sn as _,ct as v,j as y,n as b,pt as x,t as S,ut as C}from"./index-Bg7bo8aA.js";var w=e(t(),1),T=b(),E=!1,D=!1;function O(){let[e,t]=(0,w.useState)(!1),[b,O]=(0,w.useState)(null),[k]=x.useForm(),A=h(),[j]=u(),M=c(e=>e.setAuth),N=s(e=>e.load),P=!!j.get(`reason`);(0,w.useEffect)(()=>{i.getPublicLicense().then(e=>O(e.data)).catch(()=>{})},[]);let F=(e,t)=>{k.setFieldsValue({username:e,password:t})},I=async e=>{t(!0);try{let{token:t,user:n}=(await o.login(e.username,e.password)).data;M(t,n),await N();let r=g(n.roles);if(v.success(`登录成功 · ${r}`),typeof window<`u`&&d()){A(`/m`);return}A(f(n.roles)?`/dashboard`:`/my/assets`)}catch(e){v.error(a(e,`登录失败`))}finally{t(!1)}},L=!!b?.trial,R=typeof b?.daysLeft==`number`?Number(b.daysLeft):null,z=b?.status===`expired`;return(0,T.jsxs)(`div`,{className:`login-page-proto`,children:[(0,T.jsxs)(`div`,{className:`login-brand-hero`,children:[(0,T.jsx)(S,{size:56,variant:`sidebar`,style:{margin:`0 auto 16px`,boxShadow:`0 8px 24px rgba(13,148,136,0.35)`}}),(0,T.jsx)(r.Title,{level:2,className:`login-brand-title`,children:y}),(0,T.jsx)(r.Text,{className:`login-brand-tagline`,children:p})]}),(0,T.jsxs)(`div`,{className:`login-card-proto`,children:[(0,T.jsxs)(r.Text,{type:`secondary`,className:`login-card-hint`,children:[m,` · `,l]}),D,!!b?.showDefaultAdmin&&(0,T.jsx)(_,{type:`info`,showIcon:!0,style:{marginBottom:12},title:`默认管理员账号`,description:(0,T.jsxs)(`div`,{style:{fontSize:13,lineHeight:1.7},children:[`用户名 `,(0,T.jsx)(r.Text,{code:!0,children:String(b?.defaultUsername||`admin`)}),` / 密码 `,(0,T.jsx)(r.Text,{code:!0,children:String(b?.defaultPassword||`admin123`)}),(0,T.jsx)(`div`,{style:{marginTop:6},children:`登录后请立即修改密码；未修改前每次登录都会提示。`}),(0,T.jsx)(n,{type:`link`,size:`small`,style:{padding:0,height:`auto`,marginTop:4},onClick:()=>F(String(b?.defaultUsername||`admin`),String(b?.defaultPassword||`admin123`)),children:`填入账号`})]})}),P&&(0,T.jsx)(_,{type:`warning`,showIcon:!0,style:{marginBottom:12},title:`登录已过期`,description:`会话已失效，请重新登录后继续操作。`}),L&&!z&&R!==null&&(0,T.jsx)(_,{type:R<=2?`warning`:`info`,showIcon:!0,style:{marginBottom:12},title:`试用版剩余 ${R} 天`,description:`到期后需粘贴 DFAM1 激活码完成正式授权。`}),z&&(0,T.jsx)(_,{type:`error`,showIcon:!0,style:{marginBottom:12},title:L?`试用已结束`:String(b?.statusLabel||`授权已失效`),description:`可登录管理员账号，在「系统设置 → 软件授权」完成激活。`}),(0,T.jsxs)(x,{form:k,layout:`vertical`,onFinish:I,children:[(0,T.jsx)(x.Item,{name:`username`,label:`用户名`,rules:[{required:!0,message:`请输入用户名`}],children:(0,T.jsx)(C,{placeholder:`输入用户名`,autoComplete:`username`})}),(0,T.jsx)(x.Item,{name:`password`,label:`密码`,rules:[{required:!0,message:`请输入密码`}],children:(0,T.jsx)(C.Password,{placeholder:`输入密码`,autoComplete:`current-password`})}),(0,T.jsx)(n,{type:`primary`,htmlType:`submit`,block:!0,loading:e,size:`large`,style:{marginTop:8},children:`登 录`})]}),E]})]})}export{O as default};