(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[626],{99650:function(e,t,r){Promise.resolve().then(r.bind(r,33905))},35901:function(e,t,r){"use strict";r.d(t,{H:function(){return i},a:function(){return s}});var a=r(57437),o=r(2265),n=r(99376);let l=(0,o.createContext)(void 0);function i(e){let{children:t}=e,[r,i]=(0,o.useState)(!1),s=(0,n.useRouter)();(0,o.useEffect)(()=>{let e=localStorage.getItem("auth");e?u(e).then(e=>{i(e),e||localStorage.removeItem("auth")}):c().then(e=>{e||i(!0)})},[]);let c=async()=>{try{let e=localStorage.getItem("auth"),t=await fetch("/api/basic",{headers:{Authorization:"Basic ".concat(e)}});return 401===t.status}catch(e){return!0}},u=async e=>{try{return(await fetch("/api/basic",{headers:{Authorization:"Basic ".concat(e)}})).ok}catch(e){return!1}},h=async(e,t)=>{try{let r=btoa("".concat(e,":").concat(t));if(await u(r))return localStorage.setItem("auth",r),i(!0),!0;return!1}catch(e){return!1}};return(0,a.jsx)(l.Provider,{value:{isAuthenticated:r,login:h,logout:()=>{localStorage.removeItem("auth"),i(!1),c().then(e=>{e?s.push("/login"):s.push("/")})}},children:t})}function s(){let e=(0,o.useContext)(l);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},33905:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var a=r(57437),o=r(76301),n=r(2265),l=r(87565);let i=(0,l.A)(function(e){return n.createElement("svg",Object.assign({viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",focusable:!1,"aria-hidden":!0},e),n.createElement("path",{d:"M12 16c1.98 0 3.75-1.66 4.71-4.14.6-.25 1.18-1 1.44-1.97.34-1.27.27-2.4-.65-2.76C17.4 2.71 15.66 1 12 1S6.6 2.71 6.5 7.13c-.93.35-1 1.49-.65 2.76.26.98.83 1.72 1.44 1.97C8.26 14.34 10.02 16 12 16Z",fill:"currentColor"}),n.createElement("path",{d:"M19.6 22c1.24 0 2.12-1.15 1.27-2.05C19.2 18.2 15.85 17 12 17c-3.85 0-7.2 1.2-8.87 2.95-.85.9.03 2.05 1.27 2.05h15.2Z",fill:"currentColor"}))},"user"),s=(0,l.A)(function(e){return n.createElement("svg",Object.assign({viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",focusable:!1,"aria-hidden":!0},e),n.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2a6.5 6.5 0 0 0-6.5 6.5V10H5a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-.5V8.5A6.5 6.5 0 0 0 12 2Zm3.5 8V8.5a3.5 3.5 0 1 0-7 0V10h7Z",fill:"currentColor"}))},"lock");var c=r(35901),u=r(99376);function h(){let{login:e}=(0,c.a)(),t=(0,u.useRouter)(),[r,l]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=localStorage.getItem("auth");fetch("/api/basic",{headers:{Authorization:"Basic ".concat(e)}}).then(e=>{401!==e.status&&t.push("/")}).catch(()=>{})},[t]);let h=async r=>{l(!0);try{await e(r.username,r.password)?(o.FN.success("登录成功"),t.push("/")):o.FN.error("用户名或密码错误")}catch(e){o.FN.error("登录失败")}finally{l(!1)}};return(0,a.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",backgroundSize:"cover","--semi-color-text-0":"rgba(0, 0, 0, 1)","--semi-color-text-1":"rgba(0, 0, 0, 0.3)","--semi-color-text-2":"rgba(0, 0, 0, 0.3)"},children:(0,a.jsxs)(o.Card,{shadows:"always",style:{width:400,borderRadius:16,padding:24,backdropFilter:"blur(10px)",backgroundColor:"rgba(255, 255, 255, 0.85)",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.1)",border:"1px solid rgba(255, 255, 255, 0.18)"},children:[(0,a.jsx)("div",{style:{textAlign:"center",marginBottom:30},children:(0,a.jsx)(o.Typography.Title,{heading:2,style:{color:"#333"},children:"Biliup 登录"})}),(0,a.jsx)(o.Form,{onSubmit:h,children:e=>{let{formState:t,values:n,formApi:l}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Form.Input,{field:"username",label:"用户名",prefix:(0,a.jsx)(i,{style:{color:"#667eea"}}),placeholder:"请输入用户名",rules:[{required:!0,message:"请输入用户名"}],style:{marginBottom:20}}),(0,a.jsx)(o.Form.Input,{field:"password",label:"密码",mode:"password",prefix:(0,a.jsx)(s,{style:{color:"#667eea"}}),placeholder:"请输入密码",rules:[{required:!0,message:"请输入密码"}],style:{marginBottom:30}}),(0,a.jsx)(o.zx,{loading:r,type:"primary",htmlType:"submit",block:!0,style:{backgroundColor:"#667eea",borderColor:"#667eea",borderRadius:8,padding:"12px 0",fontSize:16,fontWeight:500,color:"white"},children:"登录"})]})}})]})})}}},function(e){e.O(0,[916,737,877,623,290,852,191,147,429,326,301,971,117,744],function(){return e(e.s=99650)}),_N_E=e.O()}]);