import{_ as q,i as M,j as N,k as U,r as d,l as b,m as D,c as _,f as m,d as a,w as u,e as p,a as R,u as B,o as h,n as z,p as E,E as K}from"./index-DikBC4WP.js";import{C as L}from"./index-Ba59pKR3.js";const A={class:"loginView"},J={class:"wrapper-content"},P={class:"login-form"},$={key:0},j={key:1},F={__name:"login",setup(G){const w=M(),r=R(),y=B(),{proxy:S}=N(),C=U(),l=d(void 0);d(!0),b(()=>y,o=>{l.value=o.query&&o.query.redirect},{immediate:!0});const t=d({username:"",password:""}),V={username:[{required:!0,trigger:"blur",message:"请输入用户名"}],password:[{required:!0,trigger:"blur",message:"请输入密码"}]},i=d(!1);function v(){S.$refs.loginRef.validate(o=>{if(o){if(i.value=!0,!(localStorage!=null&&localStorage.getItem("UDID"))){K({message:"服务错误，请刷新页面",type:"warning"});return}const e=(t.value.username+(localStorage==null?void 0:localStorage.getItem("UDID"))).toLowerCase().replaceAll("-",""),s=`Gx${I(6)}${t.value.password}`,f=L.Blowfish.encrypt(s,e).toString();w.login({password:f,username:t.value.username}).then(async c=>{JSON.parse(sessionStorage.getItem("userData")),await x()}).catch(c=>{console.log("登录失败",c),i.value=!1})}}),k()}async function x(){try{if(l.value&&l.value!=="/login")try{r.resolve(l.value).matched.length>0?await r.push(l.value):(console.warn("重定向路径无效，跳转到默认页面"),await r.push("/coordinate"))}catch(o){console.warn("重定向跳转失败，跳转到默认页面:",o),await r.push("/coordinate")}else await r.push("/coordinate")}catch(o){console.error("登录跳转异常:",o),await r.push("/coordinate")}finally{i.value=!1}}function I(o){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let n="";for(let s=0;s<o;s++)n+=e.charAt(Math.floor(Math.random()*e.length));return n}function k(){"Notification"in window?Notification.requestPermission().then(()=>{}):console.log("浏览器不支持通知")}return D(async()=>{C.initUdid()}),(o,e)=>{const n=p("el-input"),s=p("el-form-item"),f=p("el-button"),c=p("el-form");return h(),_("div",A,[m("div",J,[m("div",P,[e[3]||(e[3]=m("div",{class:"selected-rectangle"},null,-1)),a(c,{ref:"loginRef",class:"form-info",model:t.value,rules:V},{default:u(()=>[e[2]||(e[2]=m("h3",{class:"title"},"欢迎登录",-1)),a(s,{prop:"username"},{default:u(()=>[a(n,{modelValue:t.value.username,"onUpdate:modelValue":e[0]||(e[0]=g=>t.value.username=g),"auto-complete":"off",placeholder:"请输入您的账号",size:"large",type:"text"},null,8,["modelValue"])]),_:1}),a(s,{prop:"password"},{default:u(()=>[a(n,{modelValue:t.value.password,"onUpdate:modelValue":e[1]||(e[1]=g=>t.value.password=g),"auto-complete":"off",placeholder:"请输入密码",size:"large",type:"password",onKeyup:z(v,["enter"])},null,8,["modelValue"])]),_:1}),a(s,null,{default:u(()=>[a(f,{loading:i.value,size:"large",class:"button-login",type:"primary",onClick:E(v,["prevent"])},{default:u(()=>[i.value?(h(),_("span",j,"登录中...")):(h(),_("span",$,"登 录"))]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])])])}}},Q=q(F,[["__scopeId","data-v-aec6e781"]]);export{Q as default};
