"use strict";(self["webpackChunksanyue_imghub"]=self["webpackChunksanyue_imghub"]||[]).push([[100],{1823:function(e,t,i){i.d(t,{A:function(){return F}});var s=i(6975),n=i(47),a=(i(5331),i(9648),i(9623)),o=(i(6711),i(813)),l=(i(4896),i(732)),r=i(4453),d=i(6768),u=i(4232),c=i(5130);const h={class:"login-container"},p={class:"login-title",tabindex:"0"},g={class:"input-wrapper"},m={key:0,class:"loading-ring"},f={key:1};function b(e,t,i,b,y,k){const w=r.A,L=l.A,v=o.tk,F=a.WK,C=n.S2,A=s.A;return(0,d.uX)(),(0,d.CE)("div",{class:(0,u.C4)(["login",{"is-focused":y.isFocused}])},[(0,d.bF)(w,{class:"toggle-dark"}),(0,d.bF)(L),(0,d.Lk)("div",h,[(0,d.Lk)("h1",p,(0,u.v_)(i.title),1),((0,d.uX)(!0),(0,d.CE)(d.FK,null,(0,d.pI)(i.fields,(e,t)=>((0,d.uX)(),(0,d.CE)("div",{key:e.key,class:"input-container"},[(0,d.Lk)("label",{class:"input-name",ref_for:!0,ref:`inputLabel${t}`,style:(0,u.Tr)({"--underline-width":y.labelUnderlineWidths[t]+"px"})},(0,u.v_)(e.label),5),(0,d.Lk)("div",g,[(0,d.bF)(F,{modelValue:y.formData[e.key],"onUpdate:modelValue":t=>y.formData[e.key]=t,placeholder:e.placeholder,type:e.type||"text","show-password":e.showPassword,class:"password-input",onKeyup:(0,c.jR)(k.handleSubmit,["enter","native"]),onFocus:k.handleInputFocus,onBlur:k.handleInputBlur},(0,d.eX)({_:2},[e.icon?{name:"prefix",fn:(0,d.k6)(()=>[(0,d.bF)(v,{class:"el-input__icon"},{default:(0,d.k6)(()=>[((0,d.uX)(),(0,d.Wv)((0,d.$y)(e.icon)))]),_:2},1024)]),key:"0"}:void 0]),1032,["modelValue","onUpdate:modelValue","placeholder","type","show-password","onKeyup","onFocus","onBlur"])])]))),128)),(0,d.bF)(C,{class:(0,u.C4)(["submit",{"is-loading":i.loading}]),type:"primary",onClick:k.handleSubmit,disabled:i.loading},{default:(0,d.k6)(()=>[i.loading?((0,d.uX)(),(0,d.CE)("div",m)):((0,d.uX)(),(0,d.CE)("span",f,(0,u.v_)(i.submitText),1))]),_:1},8,["class","onClick","disabled"])]),(0,d.bF)(A,{class:"footer"})],2)}i(8111),i(7588);var y=i(8401),k=i(8903),w={name:"BaseLogin",mixins:[k.A],props:{title:{type:String,required:!0},fields:{type:Array,required:!0},submitText:{type:String,default:"登录"},backgroundKey:{type:String,required:!0},isAdmin:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},data(){return{formData:{},labelUnderlineWidths:[],isFocused:!1}},computed:{...(0,y.L8)(["userConfig"])},watch:{fields:{handler(){this.$nextTick(()=>{this.calculateLabelWidths()})},deep:!0}},components:{Footer:s.A,ToggleDark:r.A,Logo:l.A},mounted(){this.initFormData(),this.initializeBackground(this.backgroundKey,".login",!this.isAdmin,!0),this.$nextTick(()=>{this.calculateLabelWidths()})},methods:{initFormData(){const e={};this.fields.forEach(t=>{e[t.key]=""}),this.formData=e,this.labelUnderlineWidths=new Array(this.fields.length).fill(0)},calculateLabelWidths(){this.$nextTick(()=>{this.fields.forEach((e,t)=>{const i=this.$refs[`inputLabel${t}`];if(i&&i[0]){const s=document.createElement("canvas"),n=s.getContext("2d"),a=i[0],o=window.getComputedStyle(a);n.font=`${o.fontWeight} ${o.fontSize} ${o.fontFamily}`;const l=n.measureText(e.label).width;this.labelUnderlineWidths[t]=Math.ceil(l)+3}})})},handleSubmit(){this.loading||this.$emit("submit",{...this.formData})},handleInputFocus(e){this.isFocused=!0;const t=e.target.closest(".input-container");if(t){const e=t.querySelector(".input-wrapper");e&&e.classList.add("focused")}},handleInputBlur(e){this.isFocused=!1;const t=e.target.closest(".input-container");if(t){const e=t.querySelector(".input-wrapper");e&&e.classList.remove("focused")}}}},L=i(1241);const v=(0,L.A)(w,[["render",b],["__scopeId","data-v-c6b76020"]]);var F=v},2560:function(e,t,i){i.r(t),i.d(t,{default:function(){return p}});var s=i(1823),n=i(6768);function a(e,t,i,a,o,l){const r=s.A;return(0,n.uX)(),(0,n.Wv)(r,{title:l.loginTitle,fields:o.loginFields,"submit-text":"登录","background-key":"loginBkImg","is-admin":!1,loading:o.isLoading,onSubmit:l.handleLogin},null,8,["title","fields","loading","onSubmit"])}i(4114);var o=i(4570),l=i.n(o),r=i(457),d=i(8401),u={data(){return{isLoading:!1,loginFields:[{key:"password",label:"密码",placeholder:"请输入认证码",type:"password",showPassword:!0,icon:"Lock"}]}},computed:{...(0,d.L8)(["userConfig"]),ownerName(){return this.userConfig?.ownerName||"Sanyue"},loginTitle(){return`登录到 ${this.ownerName} 图床`}},components:{BaseLogin:s.A},methods:{async handleLogin(e){const{password:t}=e,i=""===t?"unset":t;this.isLoading=!0;const s=new Promise(e=>setTimeout(e,500)),n=r.A.post("/api/login",{authCode:t}).then(e=>({res:e})).catch(e=>({err:e}));try{const[e]=await Promise.all([n,s]);e.res&&200===e.res.status?(l().set("authCode",i,"14d"),this.$router.push("/"),this.$message.success("登录成功")):(this.isLoading=!1,this.$message.error("登录失败，请检查密码是否正确"))}catch(a){this.isLoading=!1,this.$message.error("系统错误")}}}},c=i(1241);const h=(0,c.A)(u,[["render",a]]);var p=h}}]);
//# sourceMappingURL=100.d7a2e066.js.map