mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-25 17:22:55 +00:00
feat: streamline WeCom QR code login success handling with direct callback integration (#4526)
This commit is contained in:
parent
5ddd1db32d
commit
8d360b1c5f
|
|
@ -43,7 +43,7 @@ function createTransparentIFrame(el: string) {
|
|||
iframeEl.referrerPolicy = 'origin'
|
||||
iframeEl.setAttribute('frameborder', '0')
|
||||
iframeEl.setAttribute('allowtransparency', 'true')
|
||||
|
||||
iframeEl.setAttribute('allow', 'local-network-access')
|
||||
container.appendChild(iframeEl)
|
||||
return iframeEl
|
||||
}
|
||||
|
|
@ -77,21 +77,18 @@ const init = async () => {
|
|||
`&panel_size=small` +
|
||||
`&redirect_type=self`
|
||||
iframe.addEventListener('load', (e) => {
|
||||
console.log('load', iframe)
|
||||
if (iframe?.contentWindow) {
|
||||
iframe.contentWindow.stop()
|
||||
const searchParams = new URLSearchParams(iframe.contentWindow.location.search)
|
||||
const code = searchParams.get('code')
|
||||
if (code) {
|
||||
chatUser.wecomCallback(code, accessToken).then((ok) => {
|
||||
iframe.contentWindow.postMessage('getToken', '*')
|
||||
}
|
||||
})
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data.type === 'token') {
|
||||
chatUser.setToken(event.data.value)
|
||||
router.push({
|
||||
name: 'chat',
|
||||
params: { accessToken },
|
||||
query: route.query,
|
||||
})
|
||||
cleanup()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue