diff --git a/.env.development b/.env.development deleted file mode 100644 index db62f58..0000000 --- a/.env.development +++ /dev/null @@ -1,6 +0,0 @@ -#基础API 绝对的 -VITE_BASE_URL_API = 'http://192.168.2.9:5192' -#当前IP 相对的 -VITE_BASE_CURRENT_API = '.' -#开发环境 -VITE_ENV = 'development' diff --git a/.env.production b/.env.production deleted file mode 100644 index 9f463c7..0000000 --- a/.env.production +++ /dev/null @@ -1,6 +0,0 @@ -#基础API 绝对的 -VITE_BASE_URL_API = 'https://meeting-api.23544.com/pc' -#当前IP 相对的 -VITE_BASE_CURRENT_API = '.' -#生产环境 -VITE_ENV = 'production' diff --git a/.env.xy b/.env.xy deleted file mode 100644 index 45335d0..0000000 --- a/.env.xy +++ /dev/null @@ -1,6 +0,0 @@ -#基础API 绝对的 -VITE_BASE_URL_API = 'https://meeting-api.23544.com/pc' -#当前IP 相对的 -VITE_BASE_CURRENT_API = '.' -#测试环境 -VITE_ENV = 'xy' diff --git a/main.js b/main.js index f56f1f8..0a30fd9 100644 --- a/main.js +++ b/main.js @@ -25,7 +25,7 @@ app.allowRendererProcessReuse = false; let mainWindow = null; let childWindow = {} let isMaximized = false; -let env = 'development'; //development production +let env = 'production'; //development production xy let regKey; let connection = null; let startNumber = 0; @@ -64,6 +64,9 @@ class AppWindow extends BrowserWindow { // this.loadFile(path.resolve(__dirname, './dist/index.html')) this.once('ready-to-show', () => { this.show(); + mainWindow.webContents.send('changeLocalStorage', { + env, + }); }); } } diff --git a/package.json b/package.json index 0e3c80d..912c6b3 100644 --- a/package.json +++ b/package.json @@ -6,16 +6,10 @@ "authors": "yj", "description": "智汇享", "scripts": { - "dev": "concurrently \"electron . --env=development\" \"cross-env BROWSER=none vite\"", - "prod": "concurrently \"electron . --env=production\" \"cross-env BROWSER=none vite\"", - "xy": "concurrently \"electron . --env=xy\" \"cross-env BROWSER=none vite\"", - "build": "vite build --mode development", - "build:prod": "vite build --mode production", - "build:xy": "vite build --mode xy", + "dev": "concurrently \"electron .\" \"cross-env BROWSER=none vite\"", + "build": "vite build", "preview": "vite preview", - "build:dev-win": "vite build --mode development & electron-builder -w --config=./config/development.json", - "build:prod-win": "vite build --mode production & electron-builder -w --config=./config/production.json", - "build:prod-win-xy": "vite build --mode xy & electron-builder -w --config=./config/xy.json" + "build:electron": "vite build & electron-builder -w --config=./config/development.json" }, "agora_electron": { "platform": "win32", @@ -59,4 +53,4 @@ "vite": "^2.8.0", "vite-plugin-resolve": "^2.5.1" } -} +} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 8d2314a..ef813d9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -197,11 +197,11 @@ const App: React.FC = () => { document.addEventListener('keydown', (event) => { if (event.keyCode == 122) { event.preventDefault(); - } else if (((event.ctrlKey && event.keyCode == 82) || event.keyCode == 116) && import.meta.env.VITE_ENV !== 'development') { + } else if (((event.ctrlKey && event.keyCode == 82) || event.keyCode == 116) && storage.getItem('env') !== 'development') { event.preventDefault(); } }); - document.getElementsByTagName('title')[0].innerText = getTitle(import.meta.env.VITE_ENV) + document.getElementsByTagName('title')[0].innerText = getTitle(storage.getItem('env') as string) }, []) const handleResize = (): void => { setWindowSize({ diff --git a/src/components/Code/index.tsx b/src/components/Code/index.tsx index 13d475b..b593e31 100644 --- a/src/components/Code/index.tsx +++ b/src/components/Code/index.tsx @@ -2,6 +2,7 @@ import ImageUrl from '@/utils/package/imageUrl'; import { Empty, Popover } from 'antd'; import { GetQrcode } from '@/api/Home/Index'; import { memo, useImperativeHandle, forwardRef, useState } from "react"; +import { storage } from '@/utils'; const Code = forwardRef((props: any, ref: any) => { useImperativeHandle(ref, () => ({ getData: () => { @@ -17,7 +18,7 @@ const Code = forwardRef((props: any, ref: any) => { onOpenChange={(e: boolean) => { setBaseImage('') if (e) { - GetQrcode(roomNum, import.meta.env.VITE_ENV === 'development' ? 'trial' : 'release').then(res => { + GetQrcode(roomNum, storage.getItem('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 ecea4aa..7cd49a1 100644 --- a/src/components/StupWizard/index.tsx +++ b/src/components/StupWizard/index.tsx @@ -245,7 +245,7 @@ const VideoComponents = () => { }, [darkLightEnhancement]); useEffect(() => { if (typeof virtualBackground.sourceIndex === 'number') { - if (import.meta.env.VITE_ENV === 'development') { + if (storage.getItem('env') === 'development') { window.electron.getAppPath().then((res: string) => { const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${virtualBackground.sourceIndex + 1}.png`); agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index 34c04bb..c3590e7 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -1,4 +1,5 @@ import styles from '@/components/UpdateModal/index.module.scss' +import { storage } from '@/utils'; import ImageUrl from '@/utils/package/imageUrl'; import { getUpdateUrl } from '@/utils/package/public'; import { Button, Flex, Modal, Progress } from 'antd'; @@ -46,7 +47,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { const [updateContent, setUpdateContent] = useState('') // 版本更新内容 function getContent() { - fetch(`${getUpdateUrl(import.meta.env.VITE_ENV)}/update.txt?t=${+new Date()}`) // 配置服务器地址 + fetch(`${getUpdateUrl(storage.getItem('env') as string)}/update.txt?t=${+new Date()}`) // 配置服务器地址 .then(async response => { if (response.status === 200) { return setUpdateContent(await response.text()) @@ -90,7 +91,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { style={{ width: '100%', height: '40px', marginBottom: '10px' }} className={`m-ant-btn`} >立即更新 - {import.meta.env.VITE_ENV === "development" ?
setIsUpdateModal(false)}>暂不更新
: null} + {storage.getItem('env') === "development" ?
setIsUpdateModal(false)}>暂不更新
: null} : progress < 100 ?
下载进度:{progress}% diff --git a/src/page/Login/index.tsx b/src/page/Login/index.tsx index 1ed8a1e..b277f52 100644 --- a/src/page/Login/index.tsx +++ b/src/page/Login/index.tsx @@ -201,7 +201,7 @@ const Login: React.FC = () => { <>
- +
diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index 73a81e5..364dd78 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -125,7 +125,7 @@ export const agora = { if (settingData.darkLightEnhancement) agora.setLowlightEnhanceOptions(settingData.darkLightEnhancement.isDarkLightEnhancement, settingData.darkLightEnhancement) if (settingData.virtualBackground) { if (typeof settingData.virtualBackground.sourceIndex === 'number') { - if (import.meta.env.VITE_ENV === 'development') { + if (storage.getItem('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, { diff --git a/src/utils/package/public.ts b/src/utils/package/public.ts index 48ffd91..6a8b53f 100644 --- a/src/utils/package/public.ts +++ b/src/utils/package/public.ts @@ -95,7 +95,7 @@ export const compareVersions = (version1: string, version2: string): number => { } export const isVersion = (callBack: Function) => { - axios.get(`${getUpdateUrl(import.meta.env.VITE_ENV)}/latest.yml`).then(res => { + axios.get(`${getUpdateUrl(storage.getItem('env') as string)}/latest.yml`).then(res => { if (res.status === 200 && res.data) { const data = yaml.load(res.data); // 解析 YAML 内容 window.electron.getVersion().then(req => { diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts index c8b054f..278f8b9 100644 --- a/src/utils/request/index.ts +++ b/src/utils/request/index.ts @@ -1,10 +1,10 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios' import Request from './request' import { constant } from '@/config' - +import storage from '../package/storage' // 实例化 const req = new Request({ - baseURL: import.meta.env.VITE_BASE_URL_API, + baseURL: storage.getItem('env') === 'development' ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc', timeout: constant.CONFIG_REQUEST_TIMEOUT_TIME as number, interceptors: { // 请求拦截器