Commit 98db7c48 by wxl

fix

parent 459e719d
......@@ -21,9 +21,8 @@ export function useSocket<S = any>() {
} else {
ws = new WebSocket(url) as unknown as CustomeSocket<S>
}
ws.addEventListener('message', event => setMsg(event.data));
ws.addEventListener('message', event => setMsg(event.data));
ws.addEventListener('open', () => {
console.log('ws链接成功')
setStatus('opening');
brokenTime.value = 0;
socketSettings.heartData && startHeartConnect();
......@@ -44,13 +43,12 @@ export function useSocket<S = any>() {
const limit = socketSettings.retryLimit || 100;
const reconnect = () => {
if(!initUrl) return;
console.log('开始重连')
brokenTime.value ++;
if(brokenTime.value > limit) {
ws.close();
} else {
setStatus('reconnect');
setTimeout( () => connect(initUrl), brokenTime.value*1000 );
setTimeout( () => connect(initUrl), 3000 );
}
}
......@@ -63,7 +61,7 @@ export function useSocket<S = any>() {
send: ws.send,
close: () => {
setStatus('closed');
ws.close();
ws.close();
},
onOpen: (cb: any) => ws.addEventListener('open', cb)
}
......
......@@ -122,14 +122,14 @@ export function useCallCenter() {
break;
case 'Busying':
case 'Hangup':
target.value.state = 'idle';
setCallState(!isInChannel.value ? 'idle' : 'calling');
target.value.state = 'idle';
setCallState(!isInChannel.value ? 'idle' : 'calling');
break;
}
})
/** 呼叫挂断功能 */
const hangup = (type?: 'leave' | 'cancel') => {
const hangup = (type?: 'leave' | 'cancel') => {
let flag: AnyRemoteMainFlag, toID: string;
switch(myCallState.value) {
default:
......
......@@ -11,7 +11,6 @@ interface ChannelData {
export function useChannelStore() {
const [currentChannel, setChannel] = useState<ChannelData>(null);
const [isInChannel, setInChannel] = useState(false);
const [channelMembers, setMembers] = useState<string[]>([]);
const [channelInfo, request] = useRequest<ChannelData>('/getAgoraToken', {auto: false});
const { currentMsg } = useInjector(useNetSocketStore);
......@@ -37,7 +36,6 @@ export function useChannelStore() {
const clearChannel = () => {
setChannel(null);
setInChannel(false);
setMembers([]);
}
watch(channelInfo, val => {
......@@ -57,8 +55,7 @@ export function useChannelStore() {
return {
currentChannel,
channelMembers,
currentChannel,
isEmpty,
isInChannel,
getTokenByChannel,
......
import { navigateTo, redirectTo, setKeepScreenOn, showToast } from "@tarojs/taro";
import { getCurrentInstance, navigateTo, redirectTo, setKeepScreenOn, showToast } from "@tarojs/taro";
import { useCallCenter } from "any-hooks/communication/useCallCenter";
import { onMounted, watch } from "vue";
import { useInjector } from "vue-vulcan";
......@@ -40,6 +40,7 @@ export function useCallerListener() {
}
})
const ins = getCurrentInstance()
// 根据用户的呼叫状态变化,执行相应的页面跳转逻辑
watch(myCallState, (state, prev) => {
switch(state) {
......@@ -55,8 +56,10 @@ export function useCallerListener() {
r ? navigateTo({url: '/pages/calling/index'}) : answerCaller('NoDevice')
})
break;
case 'calling':
redirectTo({url: '/pages/meeting/index'});
case 'calling':
const path = ins.router.path;
// console.log('path', path)
path !== '/pages/meeting/index' && redirectTo({url: '/pages/meeting/index'});
break;
}
})
......
......@@ -36,7 +36,7 @@ import { useCallCenter } from "any-hooks/communication/useCallCenter";
<view class="role-name pd-2" :class="{hide: hideConfig[index]}" @tap="toggleHideByIndex(index)">{{key}}</view>
<view class="white-box" :style="{display: hideConfig[index] ? 'none' : 'block'}">
<view v-for="(item, i) in group" :key="i" >
<view class="contact-item" v-if="![authData.id, caller?.id, target?.id ].includes(item?.id)">
<view class="contact-item" v-if="![authData.id].includes(item?.id)">
<image class="avatar" :src="item.avatar" />
<view class="info">
<view>{{item.nickname}}</view>
......
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