2 lines
6.4 KiB
JavaScript
2 lines
6.4 KiB
JavaScript
import{d as e,bl as a,aS as l,bm as s,m as o,w as n,l as t,N as i,c,a6 as r,a5 as u,e as d,g as m,O as g,t as v,bn as p,bo as f,aN as _,aT as h,r as y,b6 as b,bp as w,bi as k,F as x,a7 as T,ad as I,aQ as S,o as V,a$ as j,D as z,ag as C,b8 as D,b9 as E,aY as $,ba as K,aj as N,bq as L,P as R,am as q,br as F,Q as G,ak as A,E as U,bb as B,bs as H,b1 as O}from"./index.Drv-jZX0.js";import{E as Q}from"./el-card.38HNAb5D.js";import{_ as J}from"./index.CXRwJeBa.js";import{E as M,a as P,b as W}from"./el-dropdown-item.CvtQz2ca.js";import{E as Y}from"./el-text.B_soufBJ.js";import{g as Z,c as X}from"./custom.C4Y5SdYO.js";import"./lodash.vESyDP0b.js";const ee=e({__name:"index",props:{size:{type:String,required:!1}},setup(e){const f=[{label:"中文",value:a.ZH_CN},{label:"English",value:a.EN}],_=l(),{locale:h,t:y}=s();function b(e){h.value=e,_.changeLanguage(e),p.success(y("langSelect.message.success"))}return(a,l)=>{const s=J,p=W,h=P,y=M;return d(),o(y,{trigger:"click",onCommand:b},{dropdown:n((()=>[i(h,null,{default:n((()=>[(d(),c(u,null,r(f,(e=>i(p,{key:e.value,disabled:m(_).language===e.value,command:e.value},{default:n((()=>[g(v(e.label),1)])),_:2},1032,["disabled","command"]))),64))])),_:1})])),default:n((()=>[t("div",null,[i(s,{"icon-class":"language",size:e.size},null,8,["size"])])])),_:1})}}}),ae={class:"login-container"},le={class:"absolute-lt flex-x-end p-3 w-full"},se={class:"text-center relative"},oe={class:"flex-y-center w-full"},ne={class:"flex-y-center w-full"},te={key:0,class:"google-code-image-box"},ie=O(e({__name:"index",setup(e){const{copy:a}=f({legacy:!0});l();const s=_(),r=h(),u=j(),O=y(r.theme===b.DARK),M=y(!0),P=y(!1),W=y(!1),ie=y(w),{height:ce}=k(),re=y(""),ue=y({user_name:"",password:"",google_code:""}),de=y("");const me=x((()=>({})));function ge(){const e="/"+_e.value.active;S.push({path:e})}function ve(){ie.value.validate((e=>{if(e){P.value=!0;const e=function(){let e=ue.value;return"customer"===_e.value.active&&(e={...ue.value,ms_name:ue.value.user_name}),e}(),a={username:e.user_name,password:e.password};de.value="",ge(),s.login(a).then((e=>{(null==e?void 0:e.qr_code_url)?de.value=null==e?void 0:e.qr_code_url:(de.value="",ge()),console.log(e,11111)})).catch((()=>{})).finally((()=>{P.value=!1}))}}))}y("");const pe=()=>{const e=r.theme===b.DARK?b.LIGHT:b.DARK;r.changeTheme(e)};function fe(e){e instanceof KeyboardEvent&&(W.value=e.getModifierState("CapsLock"))}T((()=>{ce.value<600?M.value=!1:M.value=!0}));const _e=y({active:"",list:[{identity:"admin",name:"管理员平台"},{identity:"customer",name:"客户管理平台"}]});I({visible:!1,type:"user-form",width:400,title:"",leftBtnText:"确 定",rightBtnText:""});let he=JSON.parse(sessionStorage.getItem("loginInfo")||"{}");_e.value.active=he.loginType,re.value&&re.value!==_e.value.active&&!["admin","customer"].includes(_e.value.active)&&(localStorage.clear(),S.push({path:"/login",replace:!0})),console.log(_e.value.active,111,he.loginType),re.value=_e.value.active;localStorage.getItem(re.value+"accessToken")&&ge();const ye=y("account_login"),be=()=>{"account_login"===ye.value?(ye.value="tg_login",Ie()):ye.value="account_login"},we=H((e=>{a(e).then((()=>{p.success("复制成功")}))}),300),ke=()=>{window.open("https://t.me/bfbf")},xe=y(""),Te=y(""),Ie=()=>{Z({}).then((e=>{xe.value=e.token,Te.value=e.expires_at,Ve()})).catch((e=>{console.log(e)}))};let Se=null;const Ve=()=>{new Date(Te.value).getTime()-Date.now()<=0?clearInterval(Se):(clearInterval(Se),Se=setInterval((()=>{X({token:xe.value}).then((e=>{console.log(e),e.logged_in?(localStorage.setItem("customeraccessToken",e.loginToken),ge(),clearInterval(Se)):e.valid||(console.log("未登录"),p.warning("授权认证过期,请刷新界面重新获取认证"),clearInterval(Se))})).catch((e=>{console.log(e)}))}),3e3))};return V((()=>{console.log(u),_e.value.active})),z((()=>u.path),(e=>{e.startsWith("/login/")&&_e.value.active})),(e,a)=>{const l=Y,s=K,r=ee,u=J,p=N,f=L,_=q,h=F,y=A,b=w,k=B("Document"),x=U,T=Q;return d(),c("div",ae,[t("div",le,["customer"==m(_e).active?(d(),o(l,{key:0,type:"primary",style:{"margin-right":"20px"},onClick:be},{default:n((()=>[g(v("tg_login"===m(ye)?"账号密码登录":"TG登录"),1)])),_:1})):C("",!0),i(s,{modelValue:m(O),"onUpdate:modelValue":a[0]||(a[0]=e=>$(O)?O.value=e:null),"inline-prompt":"","active-icon":m(E),"inactive-icon":m(D),onChange:pe},null,8,["modelValue","active-icon","inactive-icon"]),i(r,{class:"ml-2 cursor-pointer"})]),m(_e).active?(d(),o(T,{key:0,class:"login-input-container !border-none !bg-transparent !rounded-[4%] w-100 <sm:w-85"},{default:n((()=>{var l;return[t("div",se,[t("h2",null,v(null==(l=m(_e).list.find((e=>e.identity===m(_e).active)))?void 0:l.name),1)]),"account_login"===m(ye)?(d(),o(b,{key:0,ref_key:"loginFormRef",ref:ie,model:m(ue),rules:m(me),class:"login-form"},{default:n((()=>[i(f,{prop:"user_name"},{default:n((()=>[t("div",oe,[i(u,{"icon-class":"user",class:"mx-2"}),i(p,{ref:"user_name",modelValue:m(ue).user_name,"onUpdate:modelValue":a[1]||(a[1]=e=>m(ue).user_name=e),placeholder:e.$t("login.username"),name:"user_name",size:"large",class:"h-[48px]"},null,8,["modelValue","placeholder"])])])),_:1}),i(_,{visible:m(W),content:e.$t("login.capsLock"),placement:"right"},{default:n((()=>[i(f,{prop:"password"},{default:n((()=>[t("div",ne,[i(u,{"icon-class":"lock",class:"mx-2"}),i(p,{modelValue:m(ue).password,"onUpdate:modelValue":a[2]||(a[2]=e=>m(ue).password=e),placeholder:e.$t("login.password"),type:"password",name:"password",onKeyup:[fe,R(ve,["enter"])],size:"large",class:"h-[48px] pr-2","show-password":""},null,8,["modelValue","placeholder"])])])),_:1})])),_:1},8,["visible","content"]),m(de)?(d(),c("div",te,[i(h,{class:"google-code-image",src:m(de)},null,8,["src"])])):C("",!0),i(y,{loading:m(P),type:"primary",size:"large",class:"w-full",onClick:G(ve,["prevent"])},{default:n((()=>[g(v(e.$t("login.login")),1)])),_:1},8,["loading"])])),_:1},8,["model","rules"])):(d(),o(b,{key:1,ref_key:"loginFormRef",ref:ie,class:"login-form"},{default:n((()=>[i(y,{type:"primary",plain:"",round:"",size:"large",class:"w-full tg_code",onClick:a[3]||(a[3]=e=>m(we)(`/login ${m(xe)}`))},{default:n((()=>[t("span",null,v(`/login ${m(xe)}`),1),i(x,{style:{"margin-left":"10px"}},{default:n((()=>[i(k)])),_:1})])),_:1}),i(y,{type:"primary",class:"w-full",style:{"margin-top":"10px","margin-left":"0"},onClick:ke},{default:n((()=>a[4]||(a[4]=[g("跳转TG机器人")]))),_:1,__:[4]})])),_:1},512))]})),_:1})):C("",!0)])}}}),[["__scopeId","data-v-84534f55"]]);export{ie as default};
|