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,

148 lines (147 loc) 5.91 kB
import __vite_glob_0_0 from "../BeautyConfig/BackgroundImages/background1.png.mjs"; import __vite_glob_0_1 from "../BeautyConfig/BackgroundImages/background2.png.mjs"; import { defineComponent, ref, onMounted, createElementBlock, openBlock, Fragment, renderList, normalizeClass, unref, createElementVNode, toDisplayString } from "vue"; import { storeToRefs } from "pinia"; import { AdvancedBeautyType } from "../../../type/AdvancedBeauty.mjs"; import { useBasicStore } from "../../../../stores/basic.mjs"; import useAdvancedBeautyState from "../../../hooks/useAdvancedBeautyState/index.mjs"; const _hoisted_1 = { class: "beauty-panel-container" }; const _hoisted_2 = ["title", "onClick"]; const _hoisted_3 = ["src"]; const _hoisted_4 = { class: "beauty-label" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "VirtualBackground", props: { beautyItems: {} }, emits: ["beauty-property-click"], setup(__props, { emit: __emit }) { const { virtualBackgroundImages } = useAdvancedBeautyState(); const basicStore = useBasicStore(); const { lang } = storeToRefs(basicStore); const selectedItem = ref(""); const backgroundItems = ref([]); const props = __props; const fs = require("fs"); onMounted(() => { backgroundItems.value.length = 0; getVirtualBackgroundBlurItems(); getInnerVirtualBackgroundImages(); getOuterVirtualBackgroundImages(); }); function getVirtualBackgroundBlurItems() { const virtualBackgroundItems = props.beautyItems.get( AdvancedBeautyType.virtualBackground ); if (!virtualBackgroundItems) { return; } const items = virtualBackgroundItems.items; items.forEach((beautyItem) => { const item = { ...beautyItem }; backgroundItems.value.push(item); }); } function getInnerVirtualBackgroundImages() { const imageArray = ["background1.png", "background2.png"]; imageArray.forEach(async (image) => { const imagePath = getInnerImagePath(image); if (fs.existsSync(imagePath)) { const imageName = getImageName(image); const imageUrl = new URL((/* @__PURE__ */ Object.assign({ "../BeautyConfig/BackgroundImages/background1.png": __vite_glob_0_0, "../BeautyConfig/BackgroundImages/background2.png": __vite_glob_0_1 }))[`../BeautyConfig/BackgroundImages/${image}`], import.meta.url); const item = { key: imageName, icon: imageUrl.href, name: imageName, nameEn: imageName, effectName: "video_empty_segmentation", resourcePath: "segmentMotionRes.bundle/video_empty_segmentation/template.json", backgroundPath: imagePath }; backgroundItems.value.push(item); } }); } function getOuterVirtualBackgroundImages() { if (virtualBackgroundImages.value.length === 0) { return; } virtualBackgroundImages.value.forEach(async (image) => { const imagePath = getOuterImagePath(image); if (fs.existsSync(imagePath)) { const imageName = getImageName(image); const item = { key: imageName, icon: getOuterIconUrl(image), name: imageName, nameEn: imageName, effectName: "video_empty_segmentation", resourcePath: "segmentMotionRes.bundle/video_empty_segmentation/template.json", backgroundPath: imagePath }; backgroundItems.value.push(item); } }); } function getImageName(path) { const lastSlashIndex = Math.max( path.lastIndexOf("/"), path.lastIndexOf("\\") ); const fileNameWithExt = lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path; const lastDotIndex = fileNameWithExt.lastIndexOf("."); return lastDotIndex > 0 ? fileNameWithExt.substring(0, lastDotIndex) : fileNameWithExt; } function getOuterIconUrl(image) { if (process.env.NODE_ENV === "production") { return `${process.resourcesPath}/plugin/Xmagic/images/${image}`; } return `./${image}`; } function getInnerImagePath(image) { if (process.env.NODE_ENV === "production") { return `${process.resourcesPath}/plugin/Xmagic/images/${image}`; } return `${process.cwd()}/node_modules/@tencentcloud/roomkit-electron-vue3/images/${image}`; } function getOuterImagePath(image) { if (process.env.NODE_ENV === "production") { return `${process.resourcesPath}/plugin/Xmagic/images/${image}`; } return `${process.env.PUBLIC_PATH}${image}`; } const emit = __emit; function handleBeautyPropertyClick(item) { selectedItem.value = item.key; emit( "beauty-property-click", AdvancedBeautyType.virtualBackground, AdvancedBeautyType.virtualBackground, item ); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ (openBlock(true), createElementBlock(Fragment, null, renderList(backgroundItems.value, (item) => { return openBlock(), createElementBlock("li", { key: item.name, class: normalizeClass(["beauty-property-item", { "is-active": selectedItem.value === item.key }]), title: unref(lang) === "zh-CN" ? item.name : item.nameEn, onClick: ($event) => handleBeautyPropertyClick(item) }, [ createElementVNode("img", { src: item.icon, class: "beauty-property-image" }, null, 8, _hoisted_3), createElementVNode("div", _hoisted_4, toDisplayString(unref(lang) === "zh-CN" ? item.name : item.nameEn), 1) ], 10, _hoisted_2); }), 128)) ]); }; } }); export { _sfc_main as default };