UnisKB/static/chat/assets/larkQrCode-D9UasRuW.js

2 lines
1.3 KiB
JavaScript

import{_ as m}from"./logo_lark-DULIW3z6.js";import{ay as u,cc as g,br as f,aE as h,bf as w,aI as e,aJ as k,bg as _}from"./chat-u6cKkSMp.js";const b={class:"flex-center mb-16"},C=u({__name:"larkQrCode",props:{config:{}},setup(n){const{load:c}=g("https://lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"),a=n,d=async()=>{if(!await c(!0)){console.error("飞书二维码 SDK 加载失败");return}const t={agentId:a.config.app_key,appSecret:a.config.app_secret},p=encodeURIComponent(`${window.location.origin}${window.MaxKB.prefix}/api/lark`),s=`https://passport.feishu.cn/suite/passport/oauth/authorize?client_id=${t.agentId}&redirect_uri=${p}&response_type=code&state=fit2cloud-lark-qr`,i=window.QRLogin({id:"lark-qr",goto:s,width:"266",height:"266",style:"width:280px;height:280px;border:1px solid #e8e8e8;margin:0 auto;border-radius:8px;"});window.addEventListener("message",async o=>{if(i.matchOrigin(o.origin)&&i.matchData(o.data)){const l=o.data.tmp_code;window.location.href=`${s}&tmp_code=${l}`}})};return f(()=>{d()}),(r,t)=>(h(),w(_,null,[e("div",b,[t[0]||(t[0]=e("img",{src:m,alt:"",width:"24px",class:"mr-4"},null,-1)),e("h2",null,k(r.$t("views.system.authentication.scanTheQRCode.larkQrCode")),1)]),t[1]||(t[1]=e("div",{id:"lark-qr",class:"lark-qrName"},null,-1))],64))}});export{C as default};