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,

306 lines (305 loc) 13.4 kB
import { defineComponent, ref, onMounted, onUnmounted, watch, nextTick, createElementBlock, openBlock, createVNode, unref, withCtx, createElementVNode, createCommentVNode, toDisplayString, Fragment, renderList, normalizeClass, withDirectives, vShow, pushScopeId, popScopeId } from "vue"; import { storeToRefs } from "pinia"; import { IconBasicBeauty, TUIDialog } from "@tencentcloud/uikit-base-component-vue3"; import IconButton from "../../../components/common/base/IconButton.vue.mjs"; import ResetIcon from "../../../components/common/icons/ResetIcon.vue.mjs"; import Slider from "../../../components/common/base/Slider.vue.mjs"; import { useI18n } from "../../../locales/index.mjs"; import { generateBeautyPanel } from "./GenerateBeautyConfig.mjs"; import { AdvancedBeautyType } from "../../type/AdvancedBeauty.mjs"; import Beauty from "./BeautyPanel/Beauty.vue.mjs"; import MultiBeauty from "./BeautyPanel/MultiBeauty.vue.mjs"; import VirtualBackground from "./BeautyPanel/VirtualBackground.vue.mjs"; import useGetRoomEngine from "../../../hooks/useRoomEngine.mjs"; import logger from "../../../utils/common/logger/index.mjs"; import useAdvancedBeautyState from "../../hooks/useAdvancedBeautyState/index.mjs"; import { useBasicStore } from "../../../stores/basic.mjs"; const _withScopeId = (n) => (pushScopeId("data-v-5169a5d1"), n = n(), popScopeId(), n); const _hoisted_1 = { class: "advanced-beauty" }; const _hoisted_2 = { class: "advanced-beauty-container" }; const _hoisted_3 = { class: "video-container" }; const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { id: "test-preview", class: "test-preview" }, null, -1)); const _hoisted_5 = { class: "text" }; const _hoisted_6 = { key: 0, class: "degree" }; const _hoisted_7 = { class: "text" }; const _hoisted_8 = { class: "text-value" }; const _hoisted_9 = { key: 1, class: "mask" }; const _hoisted_10 = { key: 2, class: "spinner" }; const _hoisted_11 = { class: "beauty-tabs" }; const _hoisted_12 = { class: "beauty-tabs-header" }; const _hoisted_13 = ["onClick"]; const _hoisted_14 = { class: "beauty-tabs-panels" }; const _hoisted_15 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", null, null, -1)); const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", setup(__props) { const { t } = useI18n(); const basicStore = useBasicStore(); const { lang } = storeToRefs(basicStore); const { setAdvancedBeauty, clearBeautySetting, beautyConfigs, beautyLicenseInfo } = useAdvancedBeautyState(); const roomEngine = useGetRoomEngine(); const isBeautyDialogVisible = ref(false); const isLoading = ref(false); const isShowDegree = ref(false); const sliderMinValue = ref(0); const sliderMaxValue = ref(100); const sliderValue = ref(0); const activePanel = ref(AdvancedBeautyType.basicBeauty); const activeBeautyItem = ref({ key: "", item: { key: "", icon: "", name: "", nameEn: "", effectName: "", resourcePath: "", backgroundPath: "" } }); let beautyPanels = /* @__PURE__ */ new Map(); onMounted(async () => { beautyPanels = generateBeautyPanel(beautyLicenseInfo.panelLevel); }); onUnmounted(async () => { await handleResetBeautyClick(); }); watch(activeBeautyItem, (value) => { console.log("activeBeautyItem, ", activeBeautyItem.value); if (value) { if (value.item.minValue !== void 0 && value.item.maxValue !== void 0) { sliderMaxValue.value = value.item.maxValue; sliderMinValue.value = value.item.minValue; isShowDegree.value = true; getCachedBeautySettingValue(); } else { sliderValue.value = 0; isShowDegree.value = false; } setBeautyItem(); } }); watch(sliderValue, async () => { setBeautyItem(); }); async function openBeautySettingPanel() { isBeautyDialogVisible.value = true; isLoading.value = true; await nextTick(); await startCameraTest(); isLoading.value = false; } async function closeBeautySettingPanel() { await stopCameraTest(); isBeautyDialogVisible.value = false; isShowDegree.value = false; } async function startCameraTest() { var _a; try { await ((_a = roomEngine.instance) == null ? void 0 : _a.startCameraDeviceTest({ view: "test-preview" })); } catch (error) { logger.log("startCameraDeviceTest error:", error); } } async function stopCameraTest() { var _a; try { await ((_a = roomEngine.instance) == null ? void 0 : _a.stopCameraDeviceTest()); } catch (error) { logger.log("startCameraDeviceTest error:", error); } } function handleBeautyPropertyClick(panelType, beautyKey, beautyItem) { if (panelType !== activePanel.value) { return; } activeBeautyItem.value = { key: beautyKey, item: beautyItem }; } function handleBeautyPanelClick(key) { activePanel.value = key; } async function handleResetBeautyClick() { sliderValue.value = 0; await nextTick(); clearBeautySetting(); } function setBeautyItem() { const beautyType = activePanel.value; const beautyConfig = { beautyType, beautyPanelKey: activeBeautyItem.value.key, resourcePath: activeBeautyItem.value.item.resourcePath, backgroundPath: activeBeautyItem.value.item.backgroundPath, effectKey: activeBeautyItem.value.item.effectName, effectValue: sliderValue.value }; setAdvancedBeauty(beautyType, beautyConfig); } function getCachedBeautySettingValue() { var _a; const beautyItems = (_a = beautyConfigs.get(activePanel.value)) == null ? void 0 : _a.get(activeBeautyItem.value.key); if (!beautyItems) { sliderValue.value = 0; return; } const beautyConfig = beautyItems.find((item) => { const key = `${activeBeautyItem.value.key}_${item.effectKey}_${item.resourcePath}`; return key === activeBeautyItem.value.item.key; }); if (!beautyConfig) { sliderValue.value = 0; return; } sliderValue.value = beautyConfig.effectValue; } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(IconButton, { title: unref(t)("Beauty"), onClickIcon: openBeautySettingPanel }, { default: withCtx(() => [ createVNode(unref(IconBasicBeauty), { size: "24" }) ]), _: 1 }, 8, ["title"]), createVNode(unref(TUIDialog), { customClasses: ["advanced-beauty-dialog"], visible: isBeautyDialogVisible.value, title: unref(t)("Beauty"), center: true, onClose: closeBeautySettingPanel }, { footer: withCtx(() => [ _hoisted_15 ]), default: withCtx(() => [ createElementVNode("div", _hoisted_2, [ createElementVNode("div", _hoisted_3, [ _hoisted_4, createElementVNode("div", { class: "reset", onClick: handleResetBeautyClick }, [ createVNode(ResetIcon), createElementVNode("span", _hoisted_5, toDisplayString(unref(t)("Reset")), 1) ]), isShowDegree.value ? (openBlock(), createElementBlock("div", _hoisted_6, [ createElementVNode("span", _hoisted_7, toDisplayString(unref(t)("Degree")), 1), createVNode(Slider, { modelValue: sliderValue.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => sliderValue.value = $event), class: "slider", min: sliderMinValue.value, max: sliderMaxValue.value }, null, 8, ["modelValue", "min", "max"]), createElementVNode("span", _hoisted_8, toDisplayString(sliderValue.value), 1) ])) : createCommentVNode("", true), isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_9)) : createCommentVNode("", true), isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_10)) : createCommentVNode("", true) ]), createElementVNode("div", _hoisted_11, [ createElementVNode("div", _hoisted_12, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(beautyPanels), ([key]) => { var _a, _b; return openBlock(), createElementBlock("div", { key, class: normalizeClass(["beauty-tabs-header-item", { "is-active": activePanel.value === key }]), onClick: ($event) => handleBeautyPanelClick(key) }, toDisplayString(unref(lang) === "zh-CN" ? (_a = unref(beautyPanels).get(key)) == null ? void 0 : _a.name : (_b = unref(beautyPanels).get(key)) == null ? void 0 : _b.nameEn), 11, _hoisted_13); }), 128)) ]), createElementVNode("div", _hoisted_14, [ withDirectives(createVNode(unref(MultiBeauty), { beautyType: unref(AdvancedBeautyType).basicBeauty, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).basicBeauty] ]), withDirectives(createVNode(unref(MultiBeauty), { beautyType: unref(AdvancedBeautyType).advancedBeauty, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).advancedBeauty] ]), withDirectives(createVNode(unref(Beauty), { beautyType: unref(AdvancedBeautyType).imageQuality, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).imageQuality] ]), withDirectives(createVNode(unref(MultiBeauty), { beautyType: unref(AdvancedBeautyType).makeup, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).makeup] ]), withDirectives(createVNode(unref(Beauty), { beautyType: unref(AdvancedBeautyType).bodyBeauty, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).bodyBeauty] ]), withDirectives(createVNode(unref(Beauty), { beautyType: unref(AdvancedBeautyType).advancedMakeup, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).advancedMakeup] ]), withDirectives(createVNode(unref(Beauty), { beautyType: unref(AdvancedBeautyType).filters, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).filters] ]), withDirectives(createVNode(unref(Beauty), { beautyType: unref(AdvancedBeautyType).motion, beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyType", "beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).motion] ]), withDirectives(createVNode(unref(VirtualBackground), { beautyItems: unref(beautyPanels), onBeautyPropertyClick: handleBeautyPropertyClick }, null, 8, ["beautyItems"]), [ [vShow, activePanel.value === unref(AdvancedBeautyType).virtualBackground] ]) ]) ]) ]) ]), _: 1 }, 8, ["visible", "title"]) ]); }; } }); export { _sfc_main as default };