tg_web_dist/js/index.ptmLBe_P.js
2025-07-01 15:36:27 +08:00

2 lines
6.4 KiB
JavaScript

import{aw as e,aa as a,ax as l,ay as s,az as o,a5 as n,ab as t,an as i,aA as c,av as r,a8 as u,ai as d,ap as m,aq as g,ar as v,G as p,aB as f,J as _,aC as h,H as y,E as w,aD as x,ak as k}from"./index.D1_OMcDq.js";import{E as b}from"./el-card.D8nwomaJ.js";import{_ as I}from"./index.BxiMFgRM.js";import{E as T,a as j,b as V}from"./el-dropdown-item.C98XWrLy.js";import{v as z,J as C,K as S,B as D,M as E,x as K,aa as $,H as G,y as H,u as R,a2 as q,P as A,r as B,c as L,f as N,V as J,j as M,w as U,G as F,k as O,ab as P,O as W,al as Z}from"./editor-vue.xUJDThhq.js";import{E as Q}from"./el-text.K-o0B5G6.js";import{g as X,c as Y}from"./custom.ClzIN1ao.js";import"./lodash.lGe4XDVY.js";import"./editor.Ppghu3lf.js";const ee=z({__name:"index",props:{size:{type:String,required:!1}},setup(o){const n=[{label:"中文",value:e.ZH_CN},{label:"English",value:e.EN}],t=a(),{locale:i,t:c}=l();function r(e){i.value=e,t.changeLanguage(e),s.success(c("langSelect.message.success"))}return(e,a)=>{const l=I,s=V,i=j,c=T;return H(),C(c,{trigger:"click",onCommand:r},{dropdown:S((()=>[E(i,null,{default:S((()=>[(H(),K(G,null,$(n,(e=>E(s,{key:e.value,disabled:R(t).language===e.value,command:e.value},{default:S((()=>[q(A(e.label),1)])),_:2},1032,["disabled","command"]))),64))])),_:1})])),default:S((()=>[D("div",null,[E(l,{"icon-class":"language",size:o.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=k(z({__name:"index",setup(e){const{copy:l}=o({legacy:!0});a();const k=n(),T=t(),j=d(),V=B(T.theme===i.DARK),z=B(!0),$=B(!1),G=B(!1),ie=B(c),{height:ce}=r(),re=B(""),ue=B({user_name:"",password:"",google_code:""}),de=B("");const me=L((()=>({})));function ge(){const e="/"+_e.value.active;u.push({path:e})}function ve(){ie.value.validate((e=>{if(e){$.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(),k.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((()=>{$.value=!1}))}}))}B("");const pe=()=>{const e=T.theme===i.DARK?i.LIGHT:i.DARK;T.changeTheme(e)};function fe(e){e instanceof KeyboardEvent&&(G.value=e.getModifierState("CapsLock"))}N((()=>{ce.value<600?z.value=!1:z.value=!0}));const _e=B({active:"",list:[{identity:"admin",name:"管理员平台"},{identity:"customer",name:"客户管理平台"}]});J({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(),u.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"),we=()=>{"account_login"===ye.value?(ye.value="tg_login",Te()):ye.value="account_login"},xe=x((e=>{l(e).then((()=>{s.success("复制成功")}))}),300),ke=()=>{window.open("https://t.me/bfbf")},be=B(""),Ie=B(""),Te=()=>{X({}).then((e=>{be.value=e.token,Ie.value=e.expires_at,Ve()})).catch((e=>{console.log(e)}))};let je=null;const Ve=()=>{new Date(Ie.value).getTime()-Date.now()<=0?clearInterval(je):(clearInterval(je),je=setInterval((()=>{Y({token:be.value}).then((e=>{console.log(e),e.logged_in?(localStorage.setItem("customeraccessToken",e.loginToken),ge(),clearInterval(je)):e.valid||(console.log("未登录"),s.warning("授权认证过期,请刷新界面重新获取认证"),clearInterval(je))})).catch((e=>{console.log(e)}))}),3e3))};return M((()=>{console.log(j),_e.value.active})),U((()=>j.path),(e=>{e.startsWith("/login/")&&_e.value.active})),(e,a)=>{const l=Q,s=v,o=ee,n=I,t=p,i=f,r=_,u=h,d=y,x=c,k=Z("Document"),T=w,j=b;return H(),K("div",ae,[D("div",le,["customer"==R(_e).active?(H(),C(l,{key:0,type:"primary",style:{"margin-right":"20px"},onClick:we},{default:S((()=>[q(A("tg_login"===R(ye)?"账号密码登录":"TG登录"),1)])),_:1})):F("",!0),E(s,{modelValue:R(V),"onUpdate:modelValue":a[0]||(a[0]=e=>O(V)?V.value=e:null),"inline-prompt":"","active-icon":R(g),"inactive-icon":R(m),onChange:pe},null,8,["modelValue","active-icon","inactive-icon"]),E(o,{class:"ml-2 cursor-pointer"})]),R(_e).active?(H(),C(j,{key:0,class:"login-input-container !border-none !bg-transparent !rounded-[4%] w-100 <sm:w-85"},{default:S((()=>{var l;return[D("div",se,[D("h2",null,A(null==(l=R(_e).list.find((e=>e.identity===R(_e).active)))?void 0:l.name),1)]),"account_login"===R(ye)?(H(),C(x,{key:0,ref_key:"loginFormRef",ref:ie,model:R(ue),rules:R(me),class:"login-form"},{default:S((()=>[E(i,{prop:"user_name"},{default:S((()=>[D("div",oe,[E(n,{"icon-class":"user",class:"mx-2"}),E(t,{ref:"user_name",modelValue:R(ue).user_name,"onUpdate:modelValue":a[1]||(a[1]=e=>R(ue).user_name=e),placeholder:e.$t("login.username"),name:"user_name",size:"large",class:"h-[48px]"},null,8,["modelValue","placeholder"])])])),_:1}),E(r,{visible:R(G),content:e.$t("login.capsLock"),placement:"right"},{default:S((()=>[E(i,{prop:"password"},{default:S((()=>[D("div",ne,[E(n,{"icon-class":"lock",class:"mx-2"}),E(t,{modelValue:R(ue).password,"onUpdate:modelValue":a[2]||(a[2]=e=>R(ue).password=e),placeholder:e.$t("login.password"),type:"password",name:"password",onKeyup:[fe,P(ve,["enter"])],size:"large",class:"h-[48px] pr-2","show-password":""},null,8,["modelValue","placeholder"])])])),_:1})])),_:1},8,["visible","content"]),R(de)?(H(),K("div",te,[E(u,{class:"google-code-image",src:R(de)},null,8,["src"])])):F("",!0),E(d,{loading:R($),type:"primary",size:"large",class:"w-full",onClick:W(ve,["prevent"])},{default:S((()=>[q(A(e.$t("login.login")),1)])),_:1},8,["loading"])])),_:1},8,["model","rules"])):(H(),C(x,{key:1,ref_key:"loginFormRef",ref:ie,class:"login-form"},{default:S((()=>[E(d,{type:"primary",plain:"",round:"",size:"large",class:"w-full tg_code",onClick:a[3]||(a[3]=e=>R(xe)(`/login ${R(be)}`))},{default:S((()=>[D("span",null,A(`/login ${R(be)}`),1),E(T,{style:{"margin-left":"10px"}},{default:S((()=>[E(k)])),_:1})])),_:1}),E(d,{type:"primary",class:"w-full",style:{"margin-top":"10px","margin-left":"0"},onClick:ke},{default:S((()=>a[4]||(a[4]=[q("跳转TG机器人")]))),_:1,__:[4]})])),_:1},512))]})),_:1})):F("",!0)])}}}),[["__scopeId","data-v-84534f55"]]);export{ie as default};