2 lines
5.2 KiB
JavaScript
2 lines
5.2 KiB
JavaScript
import{d as e,bw as a,b4 as l,a$ as s,b5 as t,r as n,bk as o,bx as r,bt as i,F as c,a7 as u,ad as d,b2 as m,o as v,bd as p,D as g,c as f,l as _,m as y,ag as h,g as w,w as b,ak as x,O as k,t as I,N as T,aj as z,by as $,P as D,am as S,bz as V,Q as j,E as C,aB as B,bA as F,bB as E,e as K,bf as R}from"./index.hhEe1BLx.js";import{E as q}from"./el-card.CFoxjjZH.js";import{_ as A}from"./index._j-4o23O.js";import{a as G,c as L}from"./custom.D9sfwXWP.js";const N={class:"login-container"},O={class:"absolute-lt flex-x-end p-3 w-full"},U={class:"text-center relative"},J={class:"flex-y-center w-full"},M={class:"flex-y-center w-full"},P={key:0,class:"google-code-image-box"},Q=R(e({__name:"index",setup(e){const{copy:R}=a({legacy:!0});l();const Q=s(),W=t(),H=p();n(W.theme===o.DARK);const X=n(!0),Y=n(!1),Z=n(!1),ee=n(r),{height:ae}=i(),le=n(""),se=n({user_name:"",password:"",google_code:""}),te=n("");const ne=c((()=>({})));function oe(){const e="/"+ce.value.active;m.push({path:e})}function re(){ee.value.validate((e=>{if(e){Y.value=!0;const e=function(){let e=se.value;return"customer"===ce.value.active&&(e={...se.value,ms_name:se.value.user_name}),e}(),a={username:e.user_name,password:e.password};te.value="",oe(),Q.login(a).then((e=>{(null==e?void 0:e.qr_code_url)?te.value=null==e?void 0:e.qr_code_url:(te.value="",oe())})).catch((()=>{})).finally((()=>{Y.value=!1}))}}))}function ie(e){e instanceof KeyboardEvent&&(Z.value=e.getModifierState("CapsLock"))}n(""),u((()=>{ae.value<600?X.value=!1:X.value=!0}));const ce=n({active:"",list:[{identity:"admin",name:"管理员平台"},{identity:"customer",name:"客户管理平台"}]});d({visible:!1,type:"user-form",width:400,title:"",leftBtnText:"确 定",rightBtnText:""});let ue=JSON.parse(sessionStorage.getItem("loginInfo")||"{}");ce.value.active=ue.loginType,le.value&&le.value!==ce.value.active&&!["admin","customer"].includes(ce.value.active)&&(localStorage.clear(),m.push({path:"/login",replace:!0})),le.value=ce.value.active;localStorage.getItem(le.value+"accessToken")&&oe();const de=n("account_login"),me=e=>{"account_login"===de.value?(de.value="tg_login",_e()):(de.value="account_login",clearInterval(ye))},ve=F((e=>{R(e).then((()=>{E.success("复制成功")}))}),300),pe=()=>{window.open("https://t.me/bfbf")},ge=n(""),fe=n(""),_e=()=>{G({}).then((e=>{ge.value=e.token,fe.value=e.expires_at,he()})).catch((e=>{}))};let ye=null;const he=()=>{new Date(fe.value).getTime()-Date.now()<=0?clearInterval(ye):(clearInterval(ye),ye=setInterval((()=>{L({token:ge.value}).then((e=>{e.logged_in?(localStorage.setItem("customeraccessToken",e.loginToken),oe(),clearInterval(ye)):e.valid||(E.warning("授权认证过期,请刷新界面重新获取认证"),clearInterval(ye))})).catch((e=>{clearInterval(ye)}))}),3e3))};return v((()=>{ce.value.active})),g((()=>H.path),(e=>{e.startsWith("/login/")&&ce.value.active})),(e,a)=>{const l=x,s=A,t=z,n=$,o=S,i=V,c=r,u=B("Document"),d=C,m=q;return K(),f("div",N,[_("div",O,["customer"==w(ce).active?(K(),y(l,{key:0,size:"small",type:"primary",style:{"margin-right":"20px",width:"100px"},plain:"",round:"",onClick:me},{default:b((()=>[k(I("tg_login"===w(de)?"账号密码登录":"TG注册/登录"),1)])),_:1})):h("",!0)]),w(ce).active?(K(),y(m,{key:0,class:"login-input-container !border-none !bg-transparent !rounded-[4%] w-100 <sm:w-85"},{default:b((()=>{var r;return[_("div",U,[_("h2",null,I(null==(r=w(ce).list.find((e=>e.identity===w(ce).active)))?void 0:r.name),1)]),"account_login"===w(de)?(K(),y(c,{key:0,ref_key:"loginFormRef",ref:ee,model:w(se),rules:w(ne),class:"login-form"},{default:b((()=>[T(n,{prop:"user_name"},{default:b((()=>[_("div",J,[T(s,{"icon-class":"user",class:"mx-2"}),T(t,{ref:"user_name",modelValue:w(se).user_name,"onUpdate:modelValue":a[0]||(a[0]=e=>w(se).user_name=e),placeholder:e.$t("login.username"),name:"user_name",size:"large",class:"h-[48px]"},null,8,["modelValue","placeholder"])])])),_:1}),T(o,{visible:w(Z),content:e.$t("login.capsLock"),placement:"right"},{default:b((()=>[T(n,{prop:"password"},{default:b((()=>[_("div",M,[T(s,{"icon-class":"lock",class:"mx-2"}),T(t,{modelValue:w(se).password,"onUpdate:modelValue":a[1]||(a[1]=e=>w(se).password=e),placeholder:e.$t("login.password"),type:"password",name:"password",onKeyup:[ie,D(re,["enter"])],size:"large",class:"h-[48px] pr-2","show-password":""},null,8,["modelValue","placeholder"])])])),_:1})])),_:1},8,["visible","content"]),w(te)?(K(),f("div",P,[T(i,{class:"google-code-image",src:w(te)},null,8,["src"])])):h("",!0),T(l,{loading:w(Y),type:"primary",size:"large",class:"w-full",onClick:j(re,["prevent"])},{default:b((()=>[k(I(e.$t("login.login")),1)])),_:1},8,["loading"])])),_:1},8,["model","rules"])):(K(),y(c,{key:1,ref_key:"loginFormRef",ref:ee,class:"login-form"},{default:b((()=>[T(l,{type:"primary",plain:"",round:"",size:"large",class:"w-full tg_code",onClick:a[2]||(a[2]=e=>w(ve)(`/login ${w(ge)}`))},{default:b((()=>[_("span",null,I(`/login ${w(ge)}`),1),T(d,{style:{"margin-left":"10px"}},{default:b((()=>[T(u)])),_:1})])),_:1}),T(l,{type:"primary",class:"w-full",style:{"margin-top":"10px","margin-left":"0"},onClick:pe},{default:b((()=>a[3]||(a[3]=[k("跳转TG机器人")]))),_:1,__:[3]})])),_:1},512))]})),_:1})):h("",!0)])}}}),[["__scopeId","data-v-49e2ad9b"]]);export{Q as default};
|