fix: update redirect logic for chat user login in dingtalk and wecom QR code components

This commit is contained in:
wxg0103 2025-07-30 16:03:23 +08:00
parent 00a4b09c99
commit 87eb5a879b
2 changed files with 18 additions and 12 deletions

View File

@ -102,26 +102,27 @@ const initActive = async () => {
{
redirect_uri: redirectUri,
client_id: data.appKey,
scope: 'openid',
scope: 'openid corpid',
response_type: 'code',
state: 'fit2cloud-ding-chat-qr',
prompt: 'consent',
corpId: data.corp_id
},
(loginResult) => {
console.log(loginResult)
const authCode = loginResult.authCode
chatUser.dingCallback(authCode, accessToken).then(() => {
router.push({name: 'home'})
router.push({
name: 'chat',
params: {accessToken: accessToken},
query: route.query,
})
})
},
(errorMsg: string) => {
console.log(errorMsg)
MsgError(errorMsg)
}
)
} catch (error) {
console.error(error)
}
}

View File

@ -11,18 +11,19 @@ import {
WWLoginRedirectType,
WWLoginType
} from '@wecom/jssdk'
import { ref, nextTick, defineProps } from 'vue'
import { MsgError } from '@/utils/message'
import {ref, nextTick, defineProps} from 'vue'
import {MsgError} from '@/utils/message'
import useStore from '@/stores'
import { getBrowserLang } from '@/locales'
import {getBrowserLang} from '@/locales'
const router = useRouter()
const route = useRoute()
const {
params: {accessToken},
} = route as any
const wwLogin = ref({})
const obj = ref<any>({ isWeComLogin: false })
const { chatUser } = useStore()
const obj = ref<any>({isWeComLogin: false})
const {chatUser} = useStore()
const props = defineProps<{
config: {
@ -55,10 +56,14 @@ const init = async () => {
panel_size: WWLoginPanelSizeType.small
},
onCheckWeComLogin: obj.value,
async onLoginSuccess({ code }: any) {
async onLoginSuccess({code}: any) {
chatUser.wecomCallback(code, accessToken).then(() => {
setTimeout(() => {
router.push({ name: 'home' })
router.push({
name: 'chat',
params: {accessToken: accessToken},
query: route.query,
})
})
})
},