@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,
149 lines (148 loc) • 6.37 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const background1 = require("../BeautyConfig/BackgroundImages/background1.png.js");
const background2 = require("../BeautyConfig/BackgroundImages/background2.png.js");
const Vue = require("vue");
const pinia = require("pinia");
const AdvancedBeauty = require("../../../type/AdvancedBeauty.js");
const basic = require("../../../../stores/basic.js");
const index = require("../../../hooks/useAdvancedBeautyState/index.js");
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
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__ */ Vue.defineComponent({
__name: "VirtualBackground",
props: {
beautyItems: {}
},
emits: ["beauty-property-click"],
setup(__props, { emit: __emit }) {
const { virtualBackgroundImages } = index.default();
const basicStore = basic.useBasicStore();
const { lang } = pinia.storeToRefs(basicStore);
const selectedItem = Vue.ref("");
const backgroundItems = Vue.ref([]);
const props = __props;
const fs = require("fs");
Vue.onMounted(() => {
backgroundItems.value.length = 0;
getVirtualBackgroundBlurItems();
getInnerVirtualBackgroundImages();
getOuterVirtualBackgroundImages();
});
function getVirtualBackgroundBlurItems() {
const virtualBackgroundItems = props.beautyItems.get(
AdvancedBeauty.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": background1.default, "../BeautyConfig/BackgroundImages/background2.png": background2.default }))[`../BeautyConfig/BackgroundImages/${image}`], typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("core/components/AdvancedBeauty/BeautyPanel/VirtualBackground.vue2.js", document.baseURI).href);
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",
AdvancedBeauty.AdvancedBeautyType.virtualBackground,
AdvancedBeauty.AdvancedBeautyType.virtualBackground,
item
);
}
return (_ctx, _cache) => {
return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
(Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(backgroundItems.value, (item) => {
return Vue.openBlock(), Vue.createElementBlock("li", {
key: item.name,
class: Vue.normalizeClass(["beauty-property-item", {
"is-active": selectedItem.value === item.key
}]),
title: Vue.unref(lang) === "zh-CN" ? item.name : item.nameEn,
onClick: ($event) => handleBeautyPropertyClick(item)
}, [
Vue.createElementVNode("img", {
src: item.icon,
class: "beauty-property-image"
}, null, 8, _hoisted_3),
Vue.createElementVNode("div", _hoisted_4, Vue.toDisplayString(Vue.unref(lang) === "zh-CN" ? item.name : item.nameEn), 1)
], 10, _hoisted_2);
}), 128))
]);
};
}
});
exports.default = _sfc_main;