Commit b6b1b1cb by pangchong

feat: 视频通话

parent 87d28029
...@@ -19,33 +19,38 @@ import useUserStore from '@/store/user' ...@@ -19,33 +19,38 @@ import useUserStore from '@/store/user'
import { wsShouldOpen } from 'AnyR/states/coreState' import { wsShouldOpen } from 'AnyR/states/coreState'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { userStates } from 'AnyR/states/wsStates' import { userStates } from 'AnyR/states/wsStates'
import {CallState} from "AnyR/constants/chatChannelRelated"; import { CallState } from 'AnyR/constants/chatChannelRelated'
import {chatChannelState} from "AnyR/states/chatChannelStates"; import { chatChannelState } from 'AnyR/states/chatChannelStates'
import useContactsStore from "@/store/contacts"; import useContactsStore from '@/store/contacts'
import {useAnyR} from "AnyR/index"; import { useAnyR } from 'AnyR/index'
const contactsStore = useContactsStore() const contactsStore = useContactsStore()
const AnyR = useAnyR(); const AnyR = useAnyR()
watch(() => chatChannelState.value.currentState, function (value: any) { watch(
if (value === CallState.idle) { () => chatChannelState.value.currentState,
contactsStore.changeWait(false) function (value: any) {
router.replace({ if (value === CallState.idle) {
name: "Contacts" contactsStore.changeWait(false)
}) router.replace({
} else if(value === CallState.callIn || value === CallState.callOut) { name: 'Contacts'
contactsStore.changeWait(true) })
} else { } else if (value === CallState.callIn || value === CallState.callOut) {
if (AnyR.agora) { contactsStore.changeWait(true)
contactsStore.changeWait(false); } else {
router.push({ if (AnyR.agora) {
name: "VideoCall" contactsStore.changeWait(false)
}).then(function () { router
return AnyR.agora.joinChatRoom() .push({
}) name: 'VideoCall'
} })
.then(function () {
return AnyR.agora.joinChatRoom()
})
}
}
} }
}) )
const { showLoading, loadText } = storeToRefs(useAppStore()) const { showLoading, loadText } = storeToRefs(useAppStore())
...@@ -87,7 +92,16 @@ router.beforeEach(async (to, from, next) => { ...@@ -87,7 +92,16 @@ router.beforeEach(async (to, from, next) => {
if (to.name == 'Login') { if (to.name == 'Login') {
next({ path: './' }) next({ path: './' })
} else { } else {
next() //视频通话页面
if (to.name == 'VideoCall') {
if (AnyR.agora && chatChannelState.value.currentState == CallState.calling) {
next()
} else {
next({ path: './' })
}
} else {
next()
}
} }
} else { } else {
//未登录 //未登录
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment