@tencentcloud/roomkit-web-vue3
Version:
<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,
122 lines (121 loc) • 4.65 kB
JavaScript
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Vue = require("vue");
const TUIRoomEngine = require("@tencentcloud/tuiroom-engine-js");
const room = require("../../../../stores/room.js");
const useAudioAction = require("./useAudioAction.js");
const useChatAction = require("./useChatAction.js");
const useVideoAction = require("./useVideoAction.js");
const useTransferOwnerAction = require("./useTransferOwnerAction.js");
const index$1 = require("./useChangeNameCardAction/index.js");
const useKickUserAction = require("./useKickUserAction.js");
const useSeatAction = require("./useSeatAction.js");
const useAdminAction = require("./useAdminAction.js");
const pinia = require("pinia");
const index = require("../index.js");
function useUserActions(option) {
const { userInfo, actionList } = option;
const roomStore = room.useRoomStore();
const { isFreeSpeakMode, isSpeakAfterTakingSeatMode, localUser } = pinia.storeToRefs(roomStore);
const { seatApplicationRequestList } = index.default();
const isTargetUserMySelf = Vue.computed(
() => roomStore.localUser.userId === userInfo.userId
);
const isTargetUserRoomOwner = Vue.computed(
() => userInfo.userRole === TUIRoomEngine.TUIRole.kRoomOwner
);
const isTargetUserGeneral = Vue.computed(
() => userInfo.userRole === TUIRoomEngine.TUIRole.kGeneralUser
);
const isTargetUserAnchor = Vue.computed(() => (userInfo == null ? void 0 : userInfo.isOnSeat) === true);
const isTargetUserAudience = Vue.computed(() => (userInfo == null ? void 0 : userInfo.isOnSeat) !== true);
const { isMaster, isAdmin } = pinia.storeToRefs(roomStore);
const isCanOperateCurrentUser = Vue.computed(
() => isMaster.value && !isTargetUserRoomOwner.value || isAdmin.value && isTargetUserGeneral.value || isTargetUserMySelf.value
);
const audioAction = useAudioAction.default(userInfo);
const videoAction = useVideoAction.default(userInfo);
const chatAction = useChatAction.default(userInfo);
const transferOwnerAction = useTransferOwnerAction.default(userInfo);
const adminAction = useAdminAction.default(userInfo);
const nameCardAction = index$1.default(userInfo);
const kickUserAction = useKickUserAction.default(userInfo);
const { inviteUserOnSeat, agreeUserOnSeat, denyUserOnSeat, kickUserOffSeat } = useSeatAction.default(userInfo);
const isUserApplyingToAnchor = Vue.computed(() => {
return seatApplicationRequestList.value.find(
(request) => request.userId === userInfo.userId
);
});
const agreeOrDenyStageList = isUserApplyingToAnchor.value ? [agreeUserOnSeat, denyUserOnSeat] : [];
const inviteStageList = isTargetUserAudience.value && !isUserApplyingToAnchor.value ? [inviteUserOnSeat] : [];
const onStageControlList = isTargetUserAnchor.value ? [audioAction, videoAction, kickUserOffSeat] : [];
const controlListObj = {
freeSpeak: {
[TUIRoomEngine.TUIRole.kRoomOwner]: [
audioAction,
videoAction,
chatAction,
adminAction,
transferOwnerAction,
kickUserAction,
nameCardAction
],
[TUIRoomEngine.TUIRole.kAdministrator]: [
audioAction,
videoAction,
chatAction,
nameCardAction
]
},
speakAfterTakeSeat: {
[TUIRoomEngine.TUIRole.kRoomOwner]: [
...inviteStageList,
...onStageControlList,
...agreeOrDenyStageList,
adminAction,
transferOwnerAction,
chatAction,
kickUserAction,
nameCardAction
],
[TUIRoomEngine.TUIRole.kAdministrator]: [
...inviteStageList,
...onStageControlList,
...agreeOrDenyStageList,
chatAction,
nameCardAction
]
}
};
const controlList = Vue.computed(() => {
if (!userInfo || !userInfo.isInRoom) {
return [];
}
if (!isCanOperateCurrentUser.value) {
return [];
}
if (isTargetUserMySelf.value) {
return [nameCardAction];
}
if (isFreeSpeakMode.value) {
return controlListObj.freeSpeak[localUser.value.userRole] || [];
}
if (isSpeakAfterTakingSeatMode.value) {
return controlListObj.speakAfterTakeSeat[localUser.value.userRole] || [];
}
return [];
});
if (actionList && actionList.length > 0) {
return actionList == null ? void 0 : actionList.reduce((result, action) => {
const actionItem = controlList.value.find(
(item) => item.key === action
);
if (actionItem) {
result.push(actionItem);
}
return result;
}, []);
}
return controlList.value;
}
exports.useUserActions = useUserActions;