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,
108 lines (107 loc) • 4.58 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const TUIRoomEngine = require("@tencentcloud/tuiroom-engine-js");
const index$1 = require("../../../components/common/base/Dialog/index.js");
const room = require("../../../stores/room.js");
const index = require("../../../locales/index.js");
const useRoomEngine = require("../../../hooks/useRoomEngine.js");
const uikitBaseComponentVue3 = require("@tencentcloud/uikit-base-component-vue3");
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
__name: "VideoRequestDialog",
setup(__props) {
const roomEngine = useRoomEngine.default();
const roomStore = room.useRoomStore();
const dialogContent = Vue.ref("");
const { t } = index.useI18n();
const showRequestOpenCameraDialog = Vue.ref(false);
const requestOpenCameraRequestId = Vue.ref("");
async function onRequestReceived(eventInfo) {
const { userId, requestAction, requestId } = eventInfo.request;
if (requestAction === TUIRoomEngine.TUIRequestAction.kRequestToOpenRemoteCamera) {
const userRole = roomStore.getUserRole(userId) === TUIRoomEngine.TUIRole.kRoomOwner ? t("RoomOwner") : t("Admin");
dialogContent.value = t("Sb invites you to turn on the camera", {
role: userRole
});
requestOpenCameraRequestId.value = requestId;
showRequestOpenCameraDialog.value = true;
}
}
async function handleAccept() {
var _a;
await ((_a = roomEngine.instance) == null ? void 0 : _a.responseRemoteRequest({
requestId: requestOpenCameraRequestId.value,
agree: true
}));
requestOpenCameraRequestId.value = "";
showRequestOpenCameraDialog.value = false;
}
async function handleReject() {
var _a;
await ((_a = roomEngine.instance) == null ? void 0 : _a.responseRemoteRequest({
requestId: requestOpenCameraRequestId.value,
agree: false
}));
requestOpenCameraRequestId.value = "";
showRequestOpenCameraDialog.value = false;
}
async function onRequestCancelled(eventInfo) {
const { requestId } = eventInfo;
if (requestOpenCameraRequestId.value === requestId) {
showRequestOpenCameraDialog.value = false;
}
}
TUIRoomEngine.once("ready", () => {
var _a, _b;
(_a = roomEngine.instance) == null ? void 0 : _a.on(TUIRoomEngine.TUIRoomEvents.onRequestReceived, onRequestReceived);
(_b = roomEngine.instance) == null ? void 0 : _b.on(TUIRoomEngine.TUIRoomEvents.onRequestCancelled, onRequestCancelled);
});
Vue.onUnmounted(() => {
var _a, _b;
(_a = roomEngine.instance) == null ? void 0 : _a.off(TUIRoomEngine.TUIRoomEvents.onRequestReceived, onRequestReceived);
(_b = roomEngine.instance) == null ? void 0 : _b.off(
TUIRoomEngine.TUIRoomEvents.onRequestCancelled,
onRequestCancelled
);
});
return (_ctx, _cache) => {
return Vue.openBlock(), Vue.createBlock(Vue.unref(index$1.default), {
modelValue: showRequestOpenCameraDialog.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => showRequestOpenCameraDialog.value = $event),
title: Vue.unref(t)("Tips"),
modal: true,
"show-close": false,
"close-on-click-modal": false,
width: "500px",
"append-to-room-container": true,
"confirm-button": Vue.unref(t)("Turn on the camera"),
"cancel-button": Vue.unref(t)("Keep it closed"),
onConfirm: handleAccept,
onCancel: handleReject
}, {
footer: Vue.withCtx(() => [
Vue.createVNode(Vue.unref(uikitBaseComponentVue3.TUIButton), {
onClick: handleAccept,
type: "primary"
}, {
default: Vue.withCtx(() => [
Vue.createTextVNode(Vue.toDisplayString(Vue.unref(t)("Turn on the camera")), 1)
]),
_: 1
}),
Vue.createVNode(Vue.unref(uikitBaseComponentVue3.TUIButton), { onClick: handleReject }, {
default: Vue.withCtx(() => [
Vue.createTextVNode(Vue.toDisplayString(Vue.unref(t)("Keep it closed")), 1)
]),
_: 1
})
]),
default: Vue.withCtx(() => [
Vue.createElementVNode("span", null, Vue.toDisplayString(dialogContent.value), 1)
]),
_: 1
}, 8, ["modelValue", "title", "confirm-button", "cancel-button"]);
};
}
});
exports.default = _sfc_main;