Commit b6b1b1cb by pangchong

feat: 视频通话

parent 87d28029
......@@ -19,33 +19,38 @@ import useUserStore from '@/store/user'
import { wsShouldOpen } from 'AnyR/states/coreState'
import { storeToRefs } from 'pinia'
import { userStates } from 'AnyR/states/wsStates'
import {CallState} from "AnyR/constants/chatChannelRelated";
import {chatChannelState} from "AnyR/states/chatChannelStates";
import useContactsStore from "@/store/contacts";
import {useAnyR} from "AnyR/index";
import { CallState } from 'AnyR/constants/chatChannelRelated'
import { chatChannelState } from 'AnyR/states/chatChannelStates'
import useContactsStore from '@/store/contacts'
import { useAnyR } from 'AnyR/index'
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) {
contactsStore.changeWait(false)
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)
} else {
if (AnyR.agora) {
contactsStore.changeWait(false);
router.push({
name: "VideoCall"
}).then(function () {
contactsStore.changeWait(false)
router
.push({
name: 'VideoCall'
})
.then(function () {
return AnyR.agora.joinChatRoom()
})
}
}
})
}
)
const { showLoading, loadText } = storeToRefs(useAppStore())
......@@ -87,8 +92,17 @@ router.beforeEach(async (to, from, next) => {
if (to.name == 'Login') {
next({ path: './' })
} else {
//视频通话页面
if (to.name == 'VideoCall') {
if (AnyR.agora && chatChannelState.value.currentState == CallState.calling) {
next()
} else {
next({ path: './' })
}
} else {
next()
}
}
} else {
//未登录
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