UnisKB/ui/src/views/chat/user-login/scanCompinents/wecomQrCode.vue

51 lines
1.3 KiB
Vue
Raw Normal View History

2025-06-12 04:03:43 +00:00
<template>
<iframe :src="iframeUrl" width="100%" height="380px" frameborder="0"
style="margin-top: -30px"></iframe>
2025-06-12 04:03:43 +00:00
</template>
<script lang="ts" setup>
import {ref, nextTick, defineProps} from 'vue'
import {getBrowserLang} from '@/locales'
2025-06-12 04:03:43 +00:00
const props = defineProps<{
config: {
app_secret: string
app_key: string
corp_id?: string
agent_id?: string
callback_url: string
2025-06-12 04:03:43 +00:00
}
}>()
const iframeUrl = ref('')
2025-06-12 04:03:43 +00:00
const init = async () => {
await nextTick() // 确保DOM已更新
const data = {
corpId: props.config.corp_id,
agentId: props.config.agent_id,
redirectUri: props.config.callback_url,
2025-06-12 04:03:43 +00:00
}
let lang = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
if (lang === 'en-US') {
lang = 'en'
} else {
lang = 'zh'
2025-06-12 04:03:43 +00:00
}
const redirectUri = encodeURIComponent(data.redirectUri)
console.log('redirectUri', data.redirectUri)
// 手动构建生成二维码的url
iframeUrl.value = `https://login.work.weixin.qq.com/wwlogin/sso/login?login_type=CorpApp&appid=${data.corpId}&agentid=${data.agentId}&redirect_uri=${redirectUri}&state=fit2cloud-wecom-qr&lang=${lang}&lang=${lang}&panel_size=small`
2025-06-12 04:03:43 +00:00
}
init()
</script>
<style scoped lang="scss">
#wecom-qr {
2025-06-12 04:03:43 +00:00
margin-top: -20px;
height: 331px;
justify-content: center;
2025-06-12 04:03:43 +00:00
}
</style>