// 飞书脚本 export function qr_load() { return new Promise((resolve, reject) => { const script = document.createElement("script") script.type = "text/javascript" script.src = "https://sf3-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.2.js" script.onerror = reject script.onload = () => { resolve() } document.head.appendChild(script) }) } export async function qr_login( appId: string, redirect_url: string, state: string ) { const gotoUrl = `https://passport.feishu.cn/suite/passport/oauth/authorize?client_id=${appId}&redirect_uri=${encodeURIComponent( redirect_url )}&response_type=code&state=${encodeURIComponent(state)}` const QRLogin = (window).QRLogin const QRLoginObj = QRLogin({ id: "login_container", goto: gotoUrl, style: `width: 270px;height: 270px;border: 0;border-radius:12px;background-color: #E4F2FF; background-image: radial-gradient(at 47% 33%, hsl(212.37, 72%, 59%) 0, transparent 59%), radial-gradient(at 82% 65%, hsl(198.00, 100%, 50%) 0, transparent 55%);`, }) const handleMessage = function (event: any) { const origin = event.origin if ( QRLoginObj.matchOrigin(origin) && window.location.href.indexOf("login") > -1 ) { const loginTmpCode = event.data window.location.href = `${gotoUrl}&tmp_code=${loginTmpCode}` } } if (typeof window.addEventListener !== "undefined") { window.addEventListener("message", handleMessage, false) } else if (typeof (window).attachEvent !== "undefined") { ;(window).attachEvent("onmessage", handleMessage) } } export const APP_ID = "cli_a9a902d6c3b95ceb" export const APP_SECRECT = "zVbsYlJa3nzK5DwabshHFgcWQdnp4HLu"