tg_web_dist/js/index.1752127231660YJFyNS60.js

2 lines
6.0 KiB
JavaScript
Raw Normal View History

2025-07-10 14:01:19 +08:00
import{d as e,bw as a,b4 as l,a$ as t,b5 as s,r as o,bk as n,bt as r,F as c,a7 as i,ad as u,b2 as d,o as g,bx as m,b6 as p,D as v,c as f,l as _,m as y,ag as h,g as w,w as x,ak as b,by as k,aB as I,e as T,O as V,t as z,N as $,bz as j,aj as D,am as S,P as C,bA as E,Q as B,bB as F,E as K,bf as G}from"./index.1752127231660zIbJHk2O.js";import{E as R}from"./el-card.1752127231660B6JdeAnJ.js";import{E as U}from"./el-text.1752127231660DlDlwk5p.js";import{_ as q}from"./index.1752127231660B0tqmD2Z.js";import{a as A,c as L}from"./custom.1752127231660r-ddqOQP.js";const N={class:"login-container"},O={class:"absolute-lt flex-x-end p-3 w-full"},J={class:"text-center relative"},M={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=G(e({__name:"index",setup(e){const{copy:G}=a({legacy:!0});l();const X=t(),Y=s(),Z=p();o(Y.theme===n.DARK);const ee=o(!0),ae=o(!1),le=o(!1),te=o(k),{height:se}=r(),oe=o(""),ne=o({user_name:"",password:"",google_code:""}),re=o("");const ce=c((()=>({})));function ie(){const e="/"+ge.value.active;d.push({path:e})}function ue(){te.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};re.value="",await X.login(a).then((e=>{clearInterval(xe),(null==e?void 0:e.qr_code_url)?re.value=null==e?void 0:e.qr_code_url:(re.value="",ie())})).catch((()=>{})).finally((()=>{ae.value=!1}))}}))}function de(e){e instanceof KeyboardEvent&&(le.value=e.getModifierState("CapsLock"))}o(""),i((()=>{se.value<600?ee.value=!1:ee.value=!0}));const ge=o({active:"",list:[{identity:"admin",name:"管理员平台"},{identity:"customer",name:"客户管理平台"}]});u({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(),d.push({path:"/login",replace:!0})),oe.value=ge.value.active;localStorage.getItem(oe.value+"accessToken")&&ie();const pe=o("account_login"),ve=e=>{"account_login"===pe.value?(pe.value="tg_login",we()):(pe.value="account_login",clearInterval(xe))};g((()=>{"customer"==me.loginType&&(pe.value="tg_login",we())}));const fe=F((e=>{G(e).then((()=>{m.success("复制成功")}))}),300),_e=()=>{window.open("https://t.me/bfbf")},ye=o(""),he=o(""),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||(m.warning("授权认证过期,请刷新界面重新获取认证"),clearInterval(xe))})).catch((e=>{clearInterval(xe)}))}),3e3))};return g((()=>{ge.value.active})),v((()=>Z.path),(e=>{e.startsWith("/login/")&&ge.value.active})),(e,a)=>{const l=b,t=q,s=D,o=j,n=S,r=E,c=k,i=U,u=I("Document"),d=K,g=R;return T(),f("div",N,[_("div",O,["customer"==w(ge).active?(T(),y(l,{key:0,size:"small",type:"primary",style:{"margin-right":"20px",width:"100px"},plain:"",round:"",onClick:ve},{default:x((()=>[V(z("tg_login"===w(pe)?"账号密码登录":"TG注册/登录"),1)])),_:1})):h("",!0)]),w(ge).active?(T(),y(g,{key:0,class:"login-input-container !border-none !bg-transparent !rounded-[4%] w-100 <sm:w-85"},{default:x((()=>{var g;return[_("div",J,[_("h2",null,z(null==(g=w(ge).list.find((e=>e.identity===w(ge).active)))?void 0:g.name),1)]),"account_login"===w(pe)?(T(),y(c,{key:0,ref_key:"loginFormRef",ref:te,model:w(ne),rules:w(ce),class:"login-form"},{default:x((()=>[$(o,{prop:"user_name"},{default:x((()=>[_("div",M,[$(t,{"icon-class":"user",class:"mx-2"}),$(s,{ref:"user_name",modelValue:w(ne).user_name,"onUpdate:modelValue":a[0]||(a[0]=