import{_ as m}from"./logo_dingtalk-CyDPr22R.js";import{ay as f,az as h,aA as _,cc as y,aB as k,aQ as w,aV as C,aE as v,aW as q,aI as a,aJ as R,aX as B,c1 as Q}from"./admin-DgPvPHD7.js";const S={class:"flex-center mb-16"},E=f({__name:"dingtalkQrCode",props:{config:{}},setup(c){const o=c,d=h(),{chatUser:p}=_(),{load:l}=y("https://g.alicdn.com/dingding/h5-dingtalk-login/0.21.0/ddlogin.js"),i=k(!1),n=w(),{params:{accessToken:r}}=n,u=async()=>{try{if(await l(!0),!i.value)return;const e={appKey:o.config.app_key,appSecret:o.config.app_secret,corp_id:o.config.corp_id},t=encodeURIComponent(window.location.origin);window.DTFrameLogin({id:"ding-talk-qr",width:280,height:280},{redirect_uri:t,client_id:e.appKey,scope:"openid corpid",response_type:"code",state:"fit2cloud-ding-chat-qr",prompt:"consent",corpId:e.corp_id},s=>{const g=s.authCode;p.dingCallback(g,r).then(()=>{d.push({name:"chat",params:{accessToken:r},query:n.query})})},s=>{Q(s)})}catch{}};return C(()=>o.config,e=>{e.app_key&&e.corp_id&&(i.value=!0,u())},{immediate:!0}),(e,t)=>(v(),q(B,null,[a("div",S,[t[0]||(t[0]=a("img",{src:m,alt:"",width:"24px",class:"mr-4"},null,-1)),a("h2",null,R(e.$t("views.system.authentication.scanTheQRCode.dingtalkQrCode")),1)]),t[1]||(t[1]=a("div",{class:"ding-talk-qrName"},[a("div",{id:"ding-talk-qr"})],-1))],64))}});export{E as default};