2 lines
6.4 KiB
JavaScript
2 lines
6.4 KiB
JavaScript
import{d as e,bm as a,aS as l,bn as s,m as n,w as o,l as t,O as c,c as i,a7 as r,a6 as u,bo as d,e as m,g,P as v,t as p,bp as f,aN as _,aT as h,aU as y,r as b,b6 as w,bq as k,bj as x,F as T,a8 as I,ae as S,aQ as V,o as z,D as C,bb as D,ah as E,b8 as j,b9 as R,a_ as $,ba as K,ak as L,br as q,Q as N,an as U,bs as A,R as F,al as G,E as B,bt as H,b1 as J}from"./index.Dp_uSW6y.js";import{E as O}from"./el-card.Zsvnolk4.js";import{_ as Q}from"./index.CftLazBh.js";import{E as M,a as P,b as W}from"./el-dropdown-item.DBtzPq_3.js";import{E as Z}from"./el-text.DTndLzKF.js";import{g as X,c as Y}from"./custom.CvOULV1b.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),d.success(y("langSelect.message.success"))}return(a,l)=>{const s=Q,d=W,h=P,y=M;return m(),n(y,{trigger:"click",onCommand:b},{dropdown:o((()=>[c(h,null,{default:o((()=>[(m(),i(u,null,r(f,(e=>c(d,{key:e.value,disabled:g(_).language===e.value,command:e.value},{default:o((()=>[v(p(e.label),1)])),_:2},1032,["disabled","command"]))),64))])),_:1})])),default:o((()=>[t("div",null,[c(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"},ne={class:"flex-y-center w-full"},oe={class:"flex-y-center w-full"},te={key:0,class:"google-code-image-box"},ce=J(e({__name:"index",setup(e){const{copy:a}=f({legacy:!0});l();const s=_(),r=h(),u=y(),J=b(r.theme===w.DARK),M=b(!0),P=b(!1),W=b(!1),ce=b(k),{height:ie}=x(),re=b(""),ue=b({user_name:"",password:"",google_code:""}),de=b("");const me=T((()=>({})));function ge(){const e="/"+_e.value.active;V.push({path:e})}function ve(){ce.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}))}}))}b("");const pe=()=>{const e=r.theme===w.DARK?w.LIGHT:w.DARK;r.changeTheme(e)};function fe(e){e instanceof KeyboardEvent&&(W.value=e.getModifierState("CapsLock"))}I((()=>{ie.value<600?M.value=!1:M.value=!0}));const _e=b({active:"",list:[{identity:"admin",name:"管理员平台"},{identity:"customer",name:"客户管理平台"}]});S({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(),V.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=b("account_login"),be=()=>{"account_login"===ye.value?(ye.value="tg_login",Ie()):ye.value="account_login"},we=H((e=>{a(e).then((()=>{d.success("复制成功")}))}),300),ke=()=>{window.open("https://t.me/bfbf")},xe=b(""),Te=b(""),Ie=()=>{X({}).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((()=>{Y({token:xe.value}).then((e=>{console.log(e),e.logged_in?(localStorage.setItem("customeraccessToken",e.loginToken),ge(),clearInterval(Se)):e.valid||(console.log("未登录"),d.warning("授权认证过期,请刷新界面重新获取认证"),clearInterval(Se))})).catch((e=>{console.log(e)}))}),3e3))};return z((()=>{console.log(u),_e.value.active})),C((()=>u.path),(e=>{e.startsWith("/login/")&&_e.value.active})),(e,a)=>{const l=Z,s=K,r=ee,u=Q,d=L,f=q,_=U,h=A,y=G,b=k,w=D("Document"),x=B,T=O;return m(),i("div",ae,[t("div",le,["customer"==g(_e).active?(m(),n(l,{key:0,type:"primary",style:{"margin-right":"20px"},onClick:be},{default:o((()=>[v(p("tg_login"===g(ye)?"账号密码登录":"TG登录"),1)])),_:1})):E("",!0),c(s,{modelValue:g(J),"onUpdate:modelValue":a[0]||(a[0]=e=>$(J)?J.value=e:null),"inline-prompt":"","active-icon":g(R),"inactive-icon":g(j),onChange:pe},null,8,["modelValue","active-icon","inactive-icon"]),c(r,{class:"ml-2 cursor-pointer"})]),g(_e).active?(m(),n(T,{key:0,class:"login-input-container !border-none !bg-transparent !rounded-[4%] w-100 <sm:w-85"},{default:o((()=>{var l;return[t("div",se,[t("h2",null,p(null==(l=g(_e).list.find((e=>e.identity===g(_e).active)))?void 0:l.name),1)]),"account_login"===g(ye)?(m(),n(b,{key:0,ref_key:"loginFormRef",ref:ce,model:g(ue),rules:g(me),class:"login-form"},{default:o((()=>[c(f,{prop:"user_name"},{default:o((()=>[t("div",ne,[c(u,{"icon-class":"user",class:"mx-2"}),c(d,{ref:"user_name",modelValue:g(ue).user_name,"onUpdate:modelValue":a[1]||(a[1]=e=>g(ue).user_name=e),placeholder:e.$t("login.username"),name:"user_name",size:"large",class:"h-[48px]"},null,8,["modelValue","placeholder"])])])),_:1}),c(_,{visible:g(W),content:e.$t("login.capsLock"),placement:"right"},{default:o((()=>[c(f,{prop:"password"},{default:o((()=>[t("div",oe,[c(u,{"icon-class":"lock",class:"mx-2"}),c(d,{modelValue:g(ue).password,"onUpdate:modelValue":a[2]||(a[2]=e=>g(ue).password=e),placeholder:e.$t("login.password"),type:"password",name:"password",onKeyup:[fe,N(ve,["enter"])],size:"large",class:"h-[48px] pr-2","show-password":""},null,8,["modelValue","placeholder"])])])),_:1})])),_:1},8,["visible","content"]),g(de)?(m(),i("div",te,[c(h,{class:"google-code-image",src:g(de)},null,8,["src"])])):E("",!0),c(y,{loading:g(P),type:"primary",size:"large",class:"w-full",onClick:F(ve,["prevent"])},{default:o((()=>[v(p(e.$t("login.login")),1)])),_:1},8,["loading"])])),_:1},8,["model","rules"])):(m(),n(b,{key:1,ref_key:"loginFormRef",ref:ce,class:"login-form"},{default:o((()=>[c(y,{type:"primary",plain:"",round:"",size:"large",class:"w-full tg_code",onClick:a[3]||(a[3]=e=>g(we)(`/login ${g(xe)}`))},{default:o((()=>[t("span",null,p(`/login ${g(xe)}`),1),c(x,{style:{"margin-left":"10px"}},{default:o((()=>[c(w)])),_:1})])),_:1}),c(y,{type:"primary",class:"w-full",style:{"margin-top":"10px","margin-left":"0"},onClick:ke},{default:o((()=>a[4]||(a[4]=[v("跳转TG机器人")]))),_:1,__:[4]})])),_:1},512))]})),_:1})):E("",!0)])}}}),[["__scopeId","data-v-84534f55"]]);export{ce as default};
|