tg_web_dist/js/index.5dKuVPAM.js

2 lines
5.9 KiB
JavaScript
Raw Normal View History

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