git clone https://github.com/Tencent-RTC/ultra-live-electron.git
ultra-live-electron/src/TUILiveKit directory into the src directory of your project.ultra-live-electron/TUILiveKit.main.js and ultra-live-electron/TUILiveKit.preload.js files into the root directory of your project.ultra-live-electron/src/views/TUILiveKitChild.vue and ultra-live-electron/src/views/TUILiveKitMain.vue files into src/views directory of you project.src/router/index.ts file of your project:// src/router/index.tsimport { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';import HomeView from '../views/HomeView.vue';const routes: Array<RouteRecordRaw> = [{ // The default page of your application, which contains a button to trigger the opening of the TUILiveKit main windowpath: '/',name: 'home',component: HomeView},// ********************************** TUILiveKit required code start ********************************** //{ // TUILiveKit main window pagepath: '/tui-live-kit-main',name: 'tui-live-kit-main',component: () => import(/* webpackChunkName: "TUILiveKitMain" */ '../views/TUILiveKitMain.vue')},{ // TUILiveKit sub-window pagepath: '/tui-live-kit-child',name: 'tui-live-kit-child',component: () => import(/* webpackChunkName: "TUILiveKitChild" */ '../views/TUILiveKitChild.vue'),},// ********************************** TUILiveKit required code end ********************************** //];// ********************************** TUILiveKit required code start ********************************** //window.ipcRenderer.on('window-type', (event: any, type: string) => {console.log(`[router] window type:${type}`);console.log(`[router] current href:${window.location.href}`);router.replace({ name: `tui-live-kit-${type}`});});// ********************************** TUILiveKit required code end ********************************** //const router = createRouter({history: createWebHashHistory(),routes});export default router;
ultra-live-electron/public/assets directory and ultra-live-electron/public/avatar.png file into the public directory of your project.ultra-live-electron/scripts/prestart.js file into the scripts directory of your project, and add the following command in the scripts section of the package.json file of your project.{"scripts": {"prestart": "node ./scripts/prestart.js"}}
vue.config.js file of your project:// vue.config.jsconst { defineConfig } = require('@vue/cli-service')// *********************************** TUILiveKit required code start *********************************** //const os = require("os");const isProduction = process.env.NODE_ENV === "production";const platform = os.platform();// *********************************** TUILiveKit required code end *********************************** //module.exports = defineConfig({transpileDependencies: true,// *********************************** TUILiveKit required code start *********************************** //publicPath: "./",configureWebpack: {devtool: isProduction ? "source-map" : "inline-source-map",target: "electron-renderer",module: {rules: [{test: /\\.node$/,loader: "native-ext-loader",options: {rewritePath: isProduction? platform === "win32"? "./resources": "../Resources": "./node_modules/trtc-electron-sdk/build/Release",},},],},}// *********************************** TUILiveKit required code end *********************************** //});
src/debug directory and configure SDKAppID and SDKSecretKey .ultra-live-electron/src/debug directory into the src directory of your project. Open the copied file basic-info-config.js, and add the SDKAppID and SDKSecretKey obtained from Step 1: Activate the service .// basic-info-config.js/*** Tencent Cloud SDKAppID, which should be replaced with user's SDKAppID.* Enter Tencent Cloud TRTC [Console] (https://console.trtc.io/) to create an application,* and you will see the SDKAppID.* It is a unique identifier used by Tencent Cloud to identify users.*/export const SDKAppID = 0;/*** Encryption key for calculating signature, which can be obtained in the following steps:** Step1. Enter Tencent Cloud TRTC [Console](https://console.trtc.io/),* and create an application if you don't have one.* Step2. Click your application to find "Quick Start".* Step3. Click "View Secret Key" to see the encryption key for calculating UserSig,* and copy it to the following variable.** Notes: this method is only applicable for debugging Demo. Before official launch,* please migrate the UserSig calculation code and key to your backend server to avoid* unauthorized traffic use caused by the leakage of encryption key.* Document: https://www.tencentcloud.com/document/product/647/35166#Server*/export const SDKSecretKey = '';
src/main.ts file in your project, add the following configuration to enable pinia:// main.tsimport { createApp } from 'vue';// *********************************** TUILiveKit required code start *********************************** //import { createPinia } from 'pinia';import "./TUILiveKit/assets/theme.css";// *********************************** TUILiveKit required code end *********************************** //import App from './App.vue'import router from './router'createApp(App)// *********************************** TUILiveKit required code start *********************************** //.use(createPinia())// *********************************** TUILiveKit required code end *********************************** //.use(router).mount('#app');
src/global.d.ts file of your project, add the following declarations for the Window type:// src/global.d.tsexport {}declare global {interface Window {// *********************************** TUILiveKit required code start *********************************** //ipcRenderer: any;nativeWindowHandle: Uint8Array;mainWindowPort: MessagePort | null;}// *********************************** TUILiveKit required code end *********************************** //}
// HomeView.vue<template><div class="home"><button @click="openTUILiveKit">Open TUILiveKit</button></div></template><script setup lang="ts">import { ref } from 'vue';import type { Ref } from 'vue';import { getBasicInfo } from '../debug/basic-info-config';const isOpen:Ref<boolean> = ref(false);const openTUILiveKit = async () => {if (!isOpen.value) {const currentUserInfo = await getBasicInfo();if (currentUserInfo) {window.ipcRenderer.send('openTUILiveKit', {userInfo: currentUserInfo // Note: User information is required to open TUILiveKit main window});isOpen.value = true;} else {console.error('Error: cannot get current user info');}}};</script>
// preload.jsconst { ipcRenderer } = require("electron");// Enable `ipcRenderer` can be used in vue and Javascript modulewindow.ipcRenderer = ipcRenderer;
openTUILiveKit message from Vue component, the Electron main process will open the TUILiveKit main window.// main.jsconst { app, BrowserWindow, ipcMain } = require('electron');const path = require('path');// *********************************** TUILiveKit required code start *********************************** //const { TUILiveKitMain } = require("./TUILiveKit.main");// *********************************** TUILiveKit required code end *********************************** //let mainWindow = null;const createWindow = () => {mainWindow = new BrowserWindow({width: 800,height: 600,// *********************************** TUILiveKit required code start *********************************** //webPreferences: {preload: path.join(__dirname, 'preload.js'),nodeIntegration: true,contextIsolation: false,}// *********************************** TUILiveKit required code end *********************************** //});// *********************************** TUILiveKit required code start *********************************** //bindIPCMainEvent();// *********************************** TUILiveKit required code end *********************************** //if (app.isPackaged) {mainWindow.loadFile("dist/index.html");} else {mainWindow.loadURL('http://localhost:8080');}}// *********************************** TUILiveKit required code start *********************************** //function bindIPCMainEvent() {ipcMain.on("openTUILiveKit", (event, args) => {console.log(`[main] open live kit`, args);TUILiveKitMain.open(args); // Open TUILiveKit main window});}// *********************************** TUILiveKit required code end *********************************** //app.whenReady().then(() => {createWindow();app.on('activate', () => {if (BrowserWindow.getAllWindows().length === 0) createWindow()});})app.on('window-all-closed', () => {if (process.platform !== 'darwin') app.quit()});
{"main": "main.js","scripts": {"start": "electron ."}}
npm install --save pinia movable-resizable-jsnpm install --save @tencentcloud/tuiroom-engine-electron # TUILiveKit Enginenpm install --save trtc-electron-plugin-xmagic # TUILiveKit beauty pluginnpm install --save-dev native-ext-loader electron-devtools-installer electron-builder
cmd.exe and execute the following command to start the Vue web project.npm run serve
// .eslintrc.jsmodule.exports = {root: true,env: {node: true},'extends': ['plugin:vue/vue3-essential','eslint:recommended','@vue/typescript/recommended'],parserOptions: {ecmaVersion: 2020},rules: {'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off','no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',// *********************************** TUILiveKit required code start *********************************** //"vue/multi-word-component-names": process.env.NODE_ENV === 'production' ? 'warn' : 'off',// *********************************** TUILiveKit required code end *********************************** //}}
cmd.exe and execute the following command to start an Electron application in development mode:npm run start




ultra-live-electron/electron-builder.json5 file into your project's root directory. You can modify the productName and appId as you like.{"scripts": {"build:win64": "electron-builder --win --x64","pack:win64": "npm run build && npm run build:win64"}}
cmd.exe and execute the following command. The created installation package is in release directory.npm run pack:win64
npm install --save-dev typescript@4.5.5 @typescript-eslint/eslint-plugin@5.4.0 @typescript-eslint/parser@5.4.0 @vue/cli-plugin-typescript@5.0.0 @vue/eslint-config-typescript@9.1.0
ultra-live-electron/tsconfig.json file into your project root directory.ultra-live-electron/src/global.d.ts file into your project root directory.licenseURL and licenseKey. You can then add them to the src/TUILiveKit/utils/beauty.ts file to quickly enable beauty features for testing.licenseURL and licenseKey to a JavaScript file is quick and simple, but there is a very high risk of exposing both your licenseURL and licenseKey. For commercial projects, you should obtain the licenseURL and licenseKey by calling a backend service. // beauty.tsexport const XmagicLicense = {licenseURL: "",licenseKey: "",};
Feedback