mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-01-31 00:53:20 +08:00
2 lines
4.2 KiB
JavaScript
2 lines
4.2 KiB
JavaScript
"use strict";(self["webpackChunksanyue_imghub"]=self["webpackChunksanyue_imghub"]||[]).push([[45],{4893:function(e,t,s){s.d(t,{A:function(){return w}});var i=s(6975),n=s(47),a=(s(5331),s(9648),s(9623)),o=(s(6711),s(4632)),l=s(4453),r=s(6768),d=s(4232),u=s(5130);const c={class:"login-container"},h={class:"login-title",tabindex:"0"},p={class:"input-wrapper"};function m(e,t,s,m,f,b){const g=l.A,y=o.A,k=a.WK,w=n.S2,F=i.A;return(0,r.uX)(),(0,r.CE)("div",{class:(0,d.C4)(["login",{"is-focused":f.isFocused}])},[(0,r.bF)(g,{class:"toggle-dark"}),(0,r.bF)(y),(0,r.Lk)("div",c,[(0,r.Lk)("h1",h,(0,d.v_)(s.title),1),((0,r.uX)(!0),(0,r.CE)(r.FK,null,(0,r.pI)(s.fields,(e,s)=>((0,r.uX)(),(0,r.CE)("div",{key:e.key,class:"input-container"},[(0,r.Lk)("label",{class:"input-name",ref_for:!0,ref:`inputLabel${s}`,style:(0,d.Tr)({"--underline-width":f.labelUnderlineWidths[s]+"px"})},(0,d.v_)(e.label),5),(0,r.Lk)("div",p,[(0,r.bF)(k,{modelValue:f.formData[e.key],"onUpdate:modelValue":t=>f.formData[e.key]=t,placeholder:e.placeholder,type:e.type||"text","show-password":e.showPassword,class:"password-input",onKeyup:(0,u.jR)(b.handleSubmit,["enter","native"]),onFocus:b.handleInputFocus,onBlur:b.handleInputBlur},null,8,["modelValue","onUpdate:modelValue","placeholder","type","show-password","onKeyup","onFocus","onBlur"]),t[0]||(t[0]=(0,r.Lk)("div",{class:"input-underline"},null,-1))])]))),128)),(0,r.bF)(w,{class:"submit",type:"primary",onClick:b.handleSubmit},{default:(0,r.k6)(()=>[(0,r.eW)((0,d.v_)(s.submitText),1)]),_:1},8,["onClick"])]),(0,r.bF)(F,{class:"footer"})],2)}s(8111),s(7588);var f=s(8401),b=s(8903),g={name:"BaseLogin",mixins:[b.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}},data(){return{formData:{},labelUnderlineWidths:[],isFocused:!1}},computed:{...(0,f.L8)(["userConfig"])},watch:{fields:{handler(){this.$nextTick(()=>{this.calculateLabelWidths()})},deep:!0}},components:{Footer:i.A,ToggleDark:l.A,Logo:o.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 s=this.$refs[`inputLabel${t}`];if(s&&s[0]){const i=document.createElement("canvas"),n=i.getContext("2d"),a=s[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.$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")}}}},y=s(1241);const k=(0,y.A)(g,[["render",m],["__scopeId","data-v-06e63a14"]]);var w=k},8351:function(e,t,s){s.r(t),s.d(t,{default:function(){return u}});var i=s(4893),n=s(6768);function a(e,t,s,a,o,l){const r=i.A;return(0,n.uX)(),(0,n.Wv)(r,{title:"管理端登录",fields:o.loginFields,"submit-text":"登录","background-key":"adminLoginBkImg","is-admin":!0,onSubmit:l.handleLogin},null,8,["fields","onSubmit"])}s(4114),s(4979);var o=s(9189),l={data(){return{loginFields:[{key:"username",label:"用户名",placeholder:"请输入用户名",type:"text"},{key:"password",label:"密码",placeholder:"请输入密码",type:"password",showPassword:!0}]}},components:{BaseLogin:i.A},methods:{async handleLogin(e){const{username:t,password:s}=e,i=btoa(`${t}:${s}`);try{const e=await o.A.get("/api/manage/check",{headers:{Authorization:`Basic ${i}`},withCredentials:!0});200===e.status&&(this.$store.commit("setCredentials",i),this.$router.push("/dashboard"))}catch(n){n.response&&401===n.response.status?this.$message.error("用户名或密码错误"):this.$message.error("服务器错误")}}}},r=s(1241);const d=(0,r.A)(l,[["render",a]]);var u=d}}]);
|
|
//# sourceMappingURL=45.17f632e5.js.map
|