wecomQrCode-ValuvP2Z.js 1.4 KB

12345
  1. import{cV as m,h2 as g,h1 as _,h4 as w,fy as y,fC as k,cx as h,fj as b,dr as x,af as q}from"./admin-KIlVrsVZ.js";const C={id:"wecom-qr",class:"wecom-qr flex"},T=m({__name:"wecomQrCode",props:{config:{}},setup(s){const o=s,i=g(),a=_(),{chatUser:l}=w(),{params:{accessToken:c}}=a;let e=null;function u(r){const t=document.querySelector(r);if(!t)return null;const n=document.createElement("iframe");return n.style.cssText=`
  2. display: block;
  3. border: none;
  4. background: transparent;
  5. `,n.referrerPolicy="origin",n.setAttribute("frameborder","0"),n.setAttribute("allowtransparency","true"),n.setAttribute("allow","local-network-access"),t.appendChild(n),n}function d(){return(localStorage.getItem("MaxKB-locale")||x())==="en-US"?"en":"zh"}function p(){e?.remove(),e=null}const f=async()=>{if(await b(),e=u("#wecom-qr"),!e)return;const r=encodeURIComponent(o.config.callback_url);e.src=`${o.config.qr_url}?login_type=CorpApp&appid=${o.config.corp_id}&agentid=${o.config.agent_id}&redirect_uri=${r}&state=${c}&lang=${d()}&panel_size=small&redirect_type=self`,e.addEventListener("load",t=>{e?.contentWindow&&e.contentWindow.postMessage("getToken","*")}),window.addEventListener("message",t=>{t.data.type==="token"&&(l.setToken(t.data.value),i.push({name:"chat",params:{accessToken:c},query:a.query}))})};return y(p),f(),(r,t)=>(k(),h("div",C))}}),v=q(T,[["__scopeId","data-v-bf59c5a9"]]);export{v as default};