From 3a5e299975aab2161c315d89c5c92c8d3e4fd117 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Wed, 23 Oct 2024 16:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E6=B8=B2=E6=9F=93=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 12 ++++++++++-- src/components/StupWizard/index.tsx | 15 ++++++++++++--- src/utils/package/agora.ts | 15 ++++++++++++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index b393e20..063155a 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "webm-duration-fix-buffer": "^1.0.0", "winreg": "^1.2.5" }, - "devDependencies": { + "devDependencies": { "@types/react": "^18.0.0", "@types/react-dom": "^17.0.25", "@vitejs/plugin-react": "^1.0.7", @@ -91,7 +91,15 @@ "directories": { "output": "electron" }, - "extraResources": [], + "extraResources": [ + { + "from": "src/assets/virtualBackground", + "to": "images", + "filter": [ + "**/*" + ] + } + ], "nsis": { "oneClick": false, "installerIcon": "build/install.ico", diff --git a/src/components/StupWizard/index.tsx b/src/components/StupWizard/index.tsx index 5d3edf0..4b4a0df 100644 --- a/src/components/StupWizard/index.tsx +++ b/src/components/StupWizard/index.tsx @@ -233,14 +233,23 @@ const VideoComponents = () => { }, [darkLightEnhancement]); useEffect(() => { if (typeof virtualBackground.sourceIndex === 'number') { - window.electron.getAppPath().then((res: string) => { - const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${virtualBackground.sourceIndex + 1}.png`); + if (import.meta.env.VITE_ENV === 'development') { + window.electron.getAppPath().then((res: string) => { + const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${virtualBackground.sourceIndex + 1}.png`); + agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { + source: imagePath, + background_source_type: 2, + color: Number(virtualBackground.color), + }) + }) + } else { + const imagePath = path.join((process as any).resourcesPath, 'images', `${virtualBackground.sourceIndex + 1}.png`); agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { source: imagePath, background_source_type: 2, color: Number(virtualBackground.color), }) - }) + } } else { agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { background_source_type: 1, diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index 7ff26dd..423e04f 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -120,14 +120,23 @@ export const agora = { agora.setLowlightEnhanceOptions(settingData.darkLightEnhancement.isDarkLightEnhancement, settingData.darkLightEnhancement) console.log(settingData); if (typeof settingData.virtualBackground.sourceIndex === 'number') { - window.electron.getAppPath().then((res: string) => { - const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${settingData.virtualBackground.sourceIndex + 1}.png`); + if (import.meta.env.VITE_ENV === 'development') { + window.electron.getAppPath().then((res: string) => { + const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${settingData.virtualBackground.sourceIndex + 1}.png`); + agora.enableVirtualBackground(settingData.virtualBackground.isVirtualBackground, { + source: imagePath, + background_source_type: 2, + color: Number(settingData.virtualBackground.color), + }) + }) + } else { + const imagePath = path.join((process as any).resourcesPath, 'images', `${settingData.virtualBackground.sourceIndex + 1}.png`); agora.enableVirtualBackground(settingData.virtualBackground.isVirtualBackground, { source: imagePath, background_source_type: 2, color: Number(settingData.virtualBackground.color), }) - }) + } } else { agora.enableVirtualBackground(settingData.virtualBackground.isVirtualBackground, { background_source_type: 1,