UNPKG

@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,

194 lines (193 loc) 8.21 kB
import { defineComponent, computed, ref, watch, createElementBlock, openBlock, createBlock, createCommentVNode, unref, withCtx, createTextVNode, toDisplayString, createVNode, withDirectives, normalizeClass, createElementVNode, Fragment, renderList, normalizeStyle, vShow, nextTick } from "vue"; import { TUIButton, IconArrowUp, TUIIcon } from "@tencentcloud/uikit-base-component-vue3"; import { useRoomStore } from "../../../../stores/room.mjs"; import { useI18n } from "../../../../locales/index.mjs"; import "../../../../components/common/base/IconButton.vue2.mjs"; /* empty css */ import "pinia"; import "../../../../utils/environment.mjs"; /* empty css */ import "../../../../hooks/useZIndex.mjs"; import "../../../../services/main.mjs"; import "../../../../services/roomService.mjs"; import "@tencentcloud/tuiroom-engine-js"; import "mitt"; import "../../../../services/manager/roomActionManager.mjs"; import "@tencentcloud/tui-core"; /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ import "../../../hooks/useAudioDeviceState/index.mjs"; /* empty css */ /* empty css */ /* empty css */ import "../../../../stores/basic.mjs"; /* empty css */ /* empty css */ /* empty css */ import "../../../../hooks/useRoomEngine.mjs"; import "../../../hooks/useVideoDeviceState/index.mjs"; /* empty css */ /* empty css */ import useUserState from "../../../hooks/useUserState/index.mjs"; /* empty css */ import "../../../hooks/useFreeBeautyState/index.mjs"; /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ import "../../../hooks/useUserState/useUserActions/useMemberInviteAction.mjs"; /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ const _hoisted_1 = { class: "member-control-container" }; const _hoisted_2 = ["onClick"]; const _hoisted_3 = { class: "operate-text" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "indexPC", props: { userInfo: {} }, setup(__props) { const props = __props; const { t } = useI18n(); const roomStore = useRoomStore(); const isMe = computed( () => props.userInfo.userId === roomStore.localUser.userId ); const { useUserActions } = useUserState(); const userActions = useUserActions({ userInfo: props.userInfo }); const singleControl = computed(() => { return isMe.value ? null : userActions == null ? void 0 : userActions[0]; }); const moreControlList = computed(() => { return isMe.value ? userActions : userActions.slice(1); }); const dropdownClass = ref("down"); const moreBtnRef = ref(); const operateListRef = ref(); const showMoreControl = ref(false); watch( () => moreControlList.value.length, (moreControlListLength) => { if (moreControlListLength === 0) { showMoreControl.value = false; } } ); async function toggleClickMoreBtn() { if (showMoreControl.value) { showMoreControl.value = false; } else { await handleDropDownPosition(); showMoreControl.value = true; } } async function handleDropDownPosition() { var _a, _b, _c; const { top, bottom } = (_a = moreBtnRef.value) == null ? void 0 : _a.getBoundingClientRect(); const { top: containerTop, bottom: containerBottom } = (_b = document.getElementById("memberListContainer")) == null ? void 0 : _b.getBoundingClientRect(); if (!containerBottom || !containerTop) { return; } const bottomSize = containerBottom - bottom; const topSize = top - containerTop; let dropDownContainerHeight = 0; if (!showMoreControl.value) { operateListRef.value.style = "display:block;position:absolute;z-index:-1000"; await nextTick(); dropDownContainerHeight = operateListRef.value.offsetHeight; operateListRef.value.style = ""; } else { dropDownContainerHeight = (_c = operateListRef.value) == null ? void 0 : _c.offsetHeight; } if (topSize < dropDownContainerHeight) { return; } if (bottomSize < dropDownContainerHeight) { dropdownClass.value = "up"; } } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ singleControl.value ? (openBlock(), createBlock(unref(TUIButton), { key: 0, type: "primary", onClick: _cache[0] || (_cache[0] = () => { var _a; return (_a = singleControl.value) == null ? void 0 : _a.handler(_ctx.userInfo); }) }, { default: withCtx(() => { var _a; return [ createTextVNode(toDisplayString((_a = singleControl.value) == null ? void 0 : _a.title), 1) ]; }), _: 1 })) : createCommentVNode("", true), moreControlList.value.length > 0 ? (openBlock(), createElementBlock("div", { key: 1, ref_key: "moreBtnRef", ref: moreBtnRef, class: "more-container" }, [ createVNode(unref(TUIButton), { onClick: toggleClickMoreBtn }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(t)("More")) + " ", 1), createVNode(unref(IconArrowUp), { size: "12", class: normalizeClass(["more-arrow", showMoreControl.value ? "up" : "down"]) }, null, 8, ["class"]) ]), _: 1 }), withDirectives(createElementVNode("div", { id: "operate-list", ref_key: "operateListRef", ref: operateListRef, class: normalizeClass(["user-operate-list", dropdownClass.value]) }, [ (openBlock(true), createElementBlock(Fragment, null, renderList(moreControlList.value, (item) => { return openBlock(), createElementBlock("div", { key: item.key, class: "user-operate-item", style: normalizeStyle(item.style || {}), onClick: () => item.handler(_ctx.userInfo) }, [ item.icon ? (openBlock(), createBlock(unref(TUIIcon), { key: 0, icon: item.icon }, null, 8, ["icon"])) : createCommentVNode("", true), createElementVNode("span", _hoisted_3, toDisplayString(item.label), 1) ], 12, _hoisted_2); }), 128)) ], 2), [ [vShow, showMoreControl.value] ]) ], 512)) : createCommentVNode("", true) ]); }; } }); export { _sfc_main as default };