更新
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { ref, watch } from 'vue';
|
||||
import { CallMediaType, AudioPlayBackDevice } from '@trtc/call-engine-lite-wx';
|
||||
import {
|
||||
TUIStore,
|
||||
StoreName,
|
||||
TUICallKitServer,
|
||||
NAME,
|
||||
} from './TUICallService/index';
|
||||
|
||||
const inviterId = ref<string>('');
|
||||
const mediaType = ref<CallMediaType>(CallMediaType.UNKNOWN);
|
||||
const duration = ref<number>(0);
|
||||
const pusherId = ref<string>(TUIStore.getData(StoreName.CALL, NAME.PUSHER_ID));
|
||||
|
||||
TUIStore?.watch(StoreName.CALL, {
|
||||
[NAME.CALL_MEDIA_TYPE]: _handleCallMediaTypeChange,
|
||||
[NAME.DURATION]: _handleCallDurationChange,
|
||||
[NAME.CALL_INFO]: _handleCallInfoChange,
|
||||
[NAME.PUSHER_ID]: _handlePusherIdChange,
|
||||
});
|
||||
function _handleCallMediaTypeChange(value: CallMediaType) {
|
||||
mediaType.value = value;
|
||||
}
|
||||
function _handleCallDurationChange(value: Number) {
|
||||
duration.value = value;
|
||||
}
|
||||
function _handleCallInfoChange(obj: any) {
|
||||
if (inviterId.value === obj.inviterId) return;
|
||||
inviterId.value = obj.inviterId || '';
|
||||
}
|
||||
function _handlePusherIdChange(value: string) {
|
||||
pusherId.value = value;
|
||||
}
|
||||
|
||||
const calls = async (params: any) => await TUICallKitServer.calls(params);
|
||||
const accept = async () => await TUICallKitServer.accept();
|
||||
const reject = async () => await TUICallKitServer.reject();
|
||||
const hangup = async () => await TUICallKitServer.hangup();
|
||||
|
||||
// // 群通话: "邀请他人", "中途加入"
|
||||
// const inviteUser = async (params) => await TUICallKitServer.inviteUser(params);
|
||||
// const join = async (params) => await TUICallKitServer.join(params);
|
||||
|
||||
const setSelfInfo = async (params) => await TUICallKitServer.setSelfInfo(params);
|
||||
const setSoundMode = async (type) => await TUICallKitServer.setSoundMode(type);
|
||||
|
||||
|
||||
function useCallListState() {
|
||||
return {
|
||||
// state
|
||||
inviterId,
|
||||
mediaType,
|
||||
duration,
|
||||
pusherId,
|
||||
|
||||
// actions
|
||||
calls,
|
||||
accept,
|
||||
reject,
|
||||
hangup,
|
||||
setSoundMode,
|
||||
setSelfInfo,
|
||||
};
|
||||
}
|
||||
|
||||
export { useCallListState };
|
||||
Reference in New Issue
Block a user