import{m as _,E as I,v as V,x as v,y as n,w as p,o as E,z as w,B as U,C as B,D as b}from"./index-6f5315ad.js";import"./base-60afcd29.js";import{E as F,a as A}from"./el-form-item-579310f7.js";import{E as R}from"./el-button-c8e39703.js";import{E as j}from"./el-checkbox-de97dc63.js";import{E as D}from"./el-input-bf9b01ad.js";import{a as S}from"./axios-4a70c6fc.js";import{_ as z}from"./_plugin-vue_export-helper-c27b6911.js";import{E as g}from"./index-dd51f9d6.js";import"./config-provider-338f87a0.js";/*! js-cookie v3.0.5 | MIT */function h(o){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var f in i)o[f]=i[f]}return o}var M={read:function(o){return o[0]==='"'&&(o=o.slice(1,-1)),o.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(o){return encodeURIComponent(o).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function x(o,l){function i(t,u,e){if(!(typeof document>"u")){e=h({},l,e),typeof e.expires=="number"&&(e.expires=new Date(Date.now()+e.expires*864e5)),e.expires&&(e.expires=e.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var r in e)e[r]&&(c+="; "+r,e[r]!==!0&&(c+="="+e[r].split(";")[0]));return document.cookie=t+"="+o.write(u,t)+c}}function f(t){if(!(typeof document>"u"||arguments.length&&!t)){for(var u=document.cookie?document.cookie.split("; "):[],e={},c=0;c<u.length;c++){var r=u[c].split("="),a=r.slice(1).join("=");try{var d=decodeURIComponent(r[0]);if(e[d]=o.read(a,d),t===d)break}catch{}}return t?e[t]:e}}return Object.create({set:i,get:f,remove:function(t,u){i(t,"",h({},u,{expires:-1}))},withAttributes:function(t){return x(this.converter,h({},this.attributes,t))},withConverter:function(t){return x(h({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(l)},converter:{value:Object.freeze(o)}})}var T=x(M,{path:"/"});const O=o=>(U("data-v-5c2539af"),o=o(),B(),o),q={class:"login-page"},$={class:"login-box"},H=O(()=>v("div",{class:"login-logo"},"電商後台",-1)),K={class:"card"},P={class:"card-body login-card-body"},G=["src","onclick"],J={__name:"index",setup(o){const l=_(null),i=_(null);I(()=>{l.value.focus()});const f=_(null),t=_("index.php?act=captcha&"+Math.random()),u=()=>{e.value.captcha=e.value.captcha.toUpperCase()},e=_({username:"",password:"",captcha:"",remember:!1}),c=async r=>{r&&await r.validate(async(a,d)=>{if(a){let s=await S.post("privilege.php?act=signin",e.value);if(s.data.code!="200"){switch(t.value="index.php?act=captcha&"+Math.random(),g("登入失敗"),s.data.code){case"501":e.value.captcha="";break;default:e.value.username="",e.value.password="",e.value.captcha="",l.value.focus()}return}g("登入成功"),T.set("Authorization","Bearer "+s.data.token),window.location.href="index.php"}else return g("登入失敗"),!1})};return(r,a)=>{const d=D,s=A,C=j,k=R,y=F;return E(),V("div",q,[v("div",$,[H,v("div",K,[v("div",P,[n(y,{ref_key:"ruleFormRef",ref:i,model:e.value,"status-icon":"",rules:r.rules,class:"demo-ruleForm"},{default:p(()=>[n(s,{prop:"username",rules:[{required:!0,message:"帳號必填",trigger:"blur"}]},{default:p(()=>[n(d,{modelValue:e.value.username,"onUpdate:modelValue":a[0]||(a[0]=m=>e.value.username=m),autocomplete:"off",placeholder:"請輸入帳號",ref_key:"ifocus",ref:l},null,8,["modelValue"])]),_:1}),n(s,{prop:"password",rules:[{required:!0,message:"密碼必填",trigger:"blur"}]},{default:p(()=>[n(d,{modelValue:e.value.password,"onUpdate:modelValue":a[1]||(a[1]=m=>e.value.password=m),type:"password",autocomplete:"off",placeholder:"請輸入密碼"},null,8,["modelValue"])]),_:1}),n(s,null,{default:p(()=>[n(d,{modelValue:e.value.captcha,"onUpdate:modelValue":a[2]||(a[2]=m=>e.value.captcha=m),placeholder:"請輸入驗證碼",onKeyup:u},{append:p(()=>[v("img",{src:t.value,alt:"CAPTCHA",style:{cursor:"pointer"},title:"點擊換一張",ref_key:"captchaImg",ref:f,onclick:`this.src='index.php?act=captcha&${Math.random()}'`},null,8,G)]),_:1},8,["modelValue"])]),_:1}),n(s,null,{default:p(()=>[n(C,{modelValue:e.value.remember,"onUpdate:modelValue":a[3]||(a[3]=m=>e.value.remember=m)},{default:p(()=>[w("記住登入")]),_:1},8,["modelValue"])]),_:1}),n(s,null,{default:p(()=>[n(k,{type:"primary",block:"",onClick:a[4]||(a[4]=m=>c(i.value))},{default:p(()=>[w("登入")]),_:1})]),_:1})]),_:1},8,["model","rules"])])])])])}}},L=z(J,[["__scopeId","data-v-5c2539af"]]);b(L).mount("#app");
