tg_web_dist/js/index.1752219713621DHZipo4N.js

2 lines
6.1 KiB
JavaScript
Raw Normal View History

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