From 440f19b436669292bbd5c4e213dcc56580d65202 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Wed, 5 Mar 2025 14:29:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 11 +++++++---- src/components/Code/index.tsx | 5 +++-- src/components/StupWizard/index.tsx | 26 ++++++++++++++------------ src/components/UpdateModal/index.tsx | 11 ++++++++--- src/page/Login/index.tsx | 7 +++++-- src/render.d.ts | 2 +- src/utils/package/public.ts | 21 ++++++++++++++------- src/utils/request/index.ts | 4 ++-- 8 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 31ca239..6e2d77e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -194,14 +194,17 @@ const App: React.FC = () => { }, [navigate]) } useEffect(() => { - document.addEventListener('keydown', (event) => { + document.addEventListener('keydown', async (event) => { if (event.keyCode == 122) { event.preventDefault(); - } else if (((event.ctrlKey && event.keyCode == 82) || event.keyCode == 116) && window.electron.getEnv() !== 'development') { - event.preventDefault(); + } else if (((event.ctrlKey && event.keyCode == 82) || event.keyCode == 116)) { + let env = await window.electron.getEnv() + if (env !== 'development') { + event.preventDefault(); + } } }); - document.getElementsByTagName('title')[0].innerText = getTitle() + getTitle() }, []) const handleResize = (): void => { setWindowSize({ diff --git a/src/components/Code/index.tsx b/src/components/Code/index.tsx index 0d7f915..dfdb306 100644 --- a/src/components/Code/index.tsx +++ b/src/components/Code/index.tsx @@ -14,10 +14,11 @@ const Code = forwardRef((props: any, ref: any) => { <> { + onOpenChange={async (e: boolean) => { setBaseImage('') if (e) { - GetQrcode(roomNum, window.electron.getEnv() === 'development' ? 'trial' : 'release').then(res => { + let env = await window.electron.getEnv() + GetQrcode(roomNum, env === 'development' ? 'trial' : 'release').then(res => { if (res.code === 200) { setBaseImage(res.data) } diff --git a/src/components/StupWizard/index.tsx b/src/components/StupWizard/index.tsx index 2af4d4b..4520f80 100644 --- a/src/components/StupWizard/index.tsx +++ b/src/components/StupWizard/index.tsx @@ -245,23 +245,25 @@ const VideoComponents = () => { }, [darkLightEnhancement]); useEffect(() => { if (typeof virtualBackground.sourceIndex === 'number') { - if (window.electron.getEnv() === 'development') { - window.electron.getAppPath().then((res: string) => { - const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${virtualBackground.sourceIndex + 1}.png`); + window.electron.getEnv().then(res=>{ + if (res === '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 { - 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/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index 65b01c9..8d16b7f 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -2,7 +2,7 @@ import styles from '@/components/UpdateModal/index.module.scss' import ImageUrl from '@/utils/package/imageUrl'; import { getUpdateUrl } from '@/utils/package/public'; import { Button, Flex, Modal, Progress } from 'antd'; -import { forwardRef, useImperativeHandle, useState, memo } from "react"; +import { forwardRef, useImperativeHandle, useState, memo, useEffect } from "react"; const UpdateModal = forwardRef((props: any, ref: any) => { useImperativeHandle(ref, () => ({ @@ -44,7 +44,12 @@ const UpdateModal = forwardRef((props: any, ref: any) => { const [isUpdateModal, setIsUpdateModal] = useState(false); const [progress, setProgress] = useState(0); // 下载进度值 const [updateContent, setUpdateContent] = useState('') // 版本更新内容 - + const [env, setEnv] = useState('') + useEffect(() => { + window.electron.getEnv().then(res => { + setEnv(res) + }) + }, []) function getContent() { fetch(`${getUpdateUrl()}/update.txt?t=${+new Date()}`) // 配置服务器地址 .then(async response => { @@ -90,7 +95,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { style={{ width: '100%', height: '40px', marginBottom: '10px' }} className={`m-ant-btn`} >立即更新 - {window.electron.getEnv() === "development" ?
setIsUpdateModal(false)}>暂不更新
: null} + {env === "development" ?
setIsUpdateModal(false)}>暂不更新
: null} : progress < 100 ?
下载进度:{progress}% diff --git a/src/page/Login/index.tsx b/src/page/Login/index.tsx index c4a9ae0..03d9011 100644 --- a/src/page/Login/index.tsx +++ b/src/page/Login/index.tsx @@ -40,13 +40,16 @@ const Login: React.FC = () => { roomNum: '', }) const [nameModal, setNameModal] = useState(false) - + const [env, setEnv] = useState('') useEffect(() => { window.electron.setMainWindowSize({ width: 752, height: 520, key: 'login' }) + window.electron.getEnv().then(res => { + setEnv(res) + }) if (storage.getItem('login')) { const login = JSON.parse(storage.getItem('login') as string); const data = { @@ -201,7 +204,7 @@ const Login: React.FC = () => { <>
- {window.electron.getEnv() ? : null} + {env ? : null}
diff --git a/src/render.d.ts b/src/render.d.ts index fcdbed6..b25715f 100644 --- a/src/render.d.ts +++ b/src/render.d.ts @@ -27,7 +27,7 @@ export interface IElectronAPI { startLoad: () => any; updateHandle: () => any; getVersion: () => Promise; - getEnv: () => string; + getEnv: () => Promise; isVisible: () => Promise; setRegistry: (uuid: string) => any; getRegistry: () => any; diff --git a/src/utils/package/public.ts b/src/utils/package/public.ts index 5705ac6..566a45d 100644 --- a/src/utils/package/public.ts +++ b/src/utils/package/public.ts @@ -58,8 +58,9 @@ export const storageSeeting: any = { }, } -export const getUpdateUrl = () => { - switch (window.electron.getEnv()) { +export const getUpdateUrl = async () => { + let env = await window.electron.getEnv() + switch (env) { case 'xy': return 'https://meeting-api.23544.com/meeting/xysz' case 'development': @@ -68,15 +69,21 @@ export const getUpdateUrl = () => { return 'https://meeting-api.23544.com/meeting/update' } } -export const getTitle = () => { - switch (window.electron.getEnv()) { +export const getTitle = async () => { + let env = await window.electron.getEnv() + let str; + switch (env) { case 'xy': - return '湖北襄阳四中教研平台' + str = '湖北襄阳四中教研平台' + break; case 'development': - return '智汇享' + str = '智汇享' + break; default: - return '智汇享' + str = '智汇享' + break; } + document.getElementsByTagName('title')[0].innerText = str } export const compareVersions = (version1: string, version2: string): number => { const v1Parts = version1.split('.').map(Number); diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts index 285faf9..2346eed 100644 --- a/src/utils/request/index.ts +++ b/src/utils/request/index.ts @@ -1,9 +1,10 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios' import Request from './request' import { constant } from '@/config' +let baseURL = !location.hostname.includes('meeting-api.23544.com') ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc' // 实例化 const req = new Request({ - baseURL: window.electron.getEnv() === 'development' ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc', + baseURL, timeout: constant.CONFIG_REQUEST_TIMEOUT_TIME as number, interceptors: { // 请求拦截器 @@ -21,5 +22,4 @@ const request = (config: any) => { } return req.request(config) } - export default request