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(
() => chatChannelState.value.currentState,
function (value: any) {
if (value === CallState.idle) { if (value === CallState.idle) {
contactsStore.changeWait(false) contactsStore.changeWait(false)
router.replace({ router.replace({
name: "Contacts" name: 'Contacts'
}) })
} else if(value === CallState.callIn || value === CallState.callOut) { } else if (value === CallState.callIn || value === CallState.callOut) {
contactsStore.changeWait(true) contactsStore.changeWait(true)
} else { } else {
if (AnyR.agora) { if (AnyR.agora) {
contactsStore.changeWait(false); contactsStore.changeWait(false)
router.push({ router
name: "VideoCall" .push({
}).then(function () { name: 'VideoCall'
})
.then(function () {
return AnyR.agora.joinChatRoom() return AnyR.agora.joinChatRoom()
}) })
} }
} }
}) }
)
const { showLoading, loadText } = storeToRefs(useAppStore()) const { showLoading, loadText } = storeToRefs(useAppStore())
...@@ -87,8 +92,17 @@ router.beforeEach(async (to, from, next) => { ...@@ -87,8 +92,17 @@ router.beforeEach(async (to, from, next) => {
if (to.name == 'Login') { if (to.name == 'Login') {
next({ path: './' }) next({ path: './' })
} else { } else {
//视频通话页面
if (to.name == 'VideoCall') {
if (AnyR.agora && chatChannelState.value.currentState == CallState.calling) {
next()
} else {
next({ path: './' })
}
} else {
next() next()
} }
}
} else { } else {
//未登录 //未登录
if (to.name == 'Login') { if (to.name == 'Login') {
......
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