UNPKG

@tencentcloud/roomkit-electron-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,

150 lines (149 loc) 6.18 kB
import { defineComponent, ref, computed, onMounted, onBeforeUnmount, createElementBlock, openBlock, createElementVNode, normalizeClass, createVNode, createBlock, createCommentVNode, toDisplayString, unref, withCtx, createTextVNode } from "vue"; import { storeToRefs } from "pinia"; import { ipcRenderer } from "electron"; import SvgIcon from "../../../common/base/SvgIcon.vue.mjs"; import ScreenSharingIcon from "../../../common/icons/ScreenSharingIcon.vue.mjs"; import TuiButton from "../../../common/base/Button.vue.mjs"; import Dialog from "../../../common/base/Dialog/index.vue.mjs"; import bus from "../../../../hooks/useMitt.mjs"; import { useI18n } from "../../../../locales/index.mjs"; import { useRoomStore } from "../../../../stores/room.mjs"; import { MetricsKey } from "../../../../services/manager/dataReportManager.mjs"; import "../../../../services/main.mjs"; import { roomService } from "../../../../services/roomService.mjs"; import "@tencentcloud/tuiroom-engine-electron"; import "../../../../utils/environment.mjs"; import "mitt"; import "../../../../services/manager/roomActionManager.mjs"; import "@tencentcloud/tui-core"; const _hoisted_1 = { class: "local-screen-info" }; const _hoisted_2 = { class: "text" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", setup(__props) { var _a; const roomStore = useRoomStore(); const { t } = useI18n(); const showStopShareRegion = ref(false); const localScreenContainerRef = ref(); const isMiniRegion = ref(false); const { isAnnotationVisible, isSharingScreen } = storeToRefs(roomStore); const annotationSwitchLabel = computed(() => { return isAnnotationVisible.value ? t("End annotating") : t("Start annotating"); }); function openStopConfirmDialog() { showStopShareRegion.value = true; } function stopScreenSharing() { showStopShareRegion.value = false; bus.emit("ScreenShare:stopScreenShare"); } const resizeObserver = new ResizeObserver(() => { var _a2; isMiniRegion.value = ((_a2 = localScreenContainerRef.value) == null ? void 0 : _a2.offsetHeight) <= 200; }); onMounted(() => { resizeObserver.observe(localScreenContainerRef.value); isAnnotationVisible.value = false; }); onBeforeUnmount(() => { resizeObserver.unobserve(localScreenContainerRef.value); }); function toggleAnnotationWindow() { var _a2, _b; if (isAnnotationVisible.value) { (_a2 = ipcRenderer) == null ? void 0 : _a2.send("annotation:stop-annotating"); isAnnotationVisible.value = false; roomService.dataReportManager.reportCount(MetricsKey.stopAnnotating); } else { (_b = ipcRenderer) == null ? void 0 : _b.send("annotation:start-annotating"); isAnnotationVisible.value = true; roomService.dataReportManager.reportCount(MetricsKey.startAnnotating); } } (_a = ipcRenderer) == null ? void 0 : _a.on("annotation:stop-from-annotation-window", () => { isAnnotationVisible.value = false; roomService.dataReportManager.reportCount(MetricsKey.stopAnnotating); }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: "local-screen-container", ref_key: "localScreenContainerRef", ref: localScreenContainerRef }, [ createElementVNode("div", { class: normalizeClass(["local-screen-control-container", { mini: isMiniRegion.value }]) }, [ createElementVNode("div", _hoisted_1, [ createVNode(SvgIcon, { icon: ScreenSharingIcon }), createElementVNode("span", _hoisted_2, toDisplayString(unref(t)("You are sharing the screen...")), 1) ]), createVNode(TuiButton, { size: "default", class: "stop-button", onClick: openStopConfirmDialog }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(t)("End sharing")), 1) ]), _: 1 }), unref(isSharingScreen) ? (openBlock(), createBlock(TuiButton, { key: 0, size: "default", class: "toggle-annotating-button", onClick: toggleAnnotationWindow }, { default: withCtx(() => [ createTextVNode(toDisplayString(annotationSwitchLabel.value), 1) ]), _: 1 })) : createCommentVNode("", true), createVNode(Dialog, { modelValue: showStopShareRegion.value, "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => showStopShareRegion.value = $event), width: "420px", title: unref(t)("End sharing"), modal: true, "close-on-click-modal": true, "append-to-room-container": true }, { footer: withCtx(() => [ createElementVNode("span", null, [ createVNode(TuiButton, { class: "dialog-button", size: "default", onClick: stopScreenSharing }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(t)("End sharing")), 1) ]), _: 1 }), createVNode(TuiButton, { type: "primary", size: "default", onClick: _cache[0] || (_cache[0] = ($event) => showStopShareRegion.value = false) }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(t)("Cancel")), 1) ]), _: 1 }) ]) ]), default: withCtx(() => [ createElementVNode("span", null, toDisplayString(unref(t)( "Others will no longer see your screen after you stop sharing. Are you sure you want to stop?" )), 1) ]), _: 1 }, 8, ["modelValue", "title"]) ], 2) ], 512); }; } }); export { _sfc_main as default };