环境配置优化

This commit is contained in:
yj 2025-03-05 10:41:50 +08:00
parent 76e968322d
commit 489d5c8511
13 changed files with 21 additions and 40 deletions

View File

@ -1,6 +0,0 @@
#基础API 绝对的
VITE_BASE_URL_API = 'http://192.168.2.9:5192'
#当前IP 相对的
VITE_BASE_CURRENT_API = '.'
#开发环境
VITE_ENV = 'development'

View File

@ -1,6 +0,0 @@
#基础API 绝对的
VITE_BASE_URL_API = 'https://meeting-api.23544.com/pc'
#当前IP 相对的
VITE_BASE_CURRENT_API = '.'
#生产环境
VITE_ENV = 'production'

View File

@ -1,6 +0,0 @@
#基础API 绝对的
VITE_BASE_URL_API = 'https://meeting-api.23544.com/pc'
#当前IP 相对的
VITE_BASE_CURRENT_API = '.'
#测试环境
VITE_ENV = 'xy'

View File

@ -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,
});
});
}
}

View File

@ -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"
}
}
}

View File

@ -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({

View File

@ -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)
}

View File

@ -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, {

View File

@ -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`}
></Button>
{import.meta.env.VITE_ENV === "development" ? <div className={styles.button2} onClick={() => setIsUpdateModal(false)}></div> : null}
{storage.getItem('env') === "development" ? <div className={styles.button2} onClick={() => setIsUpdateModal(false)}></div> : null}
</div> : progress < 100 ?
<div style={{ margin: '20px 0' }}>
{progress}%

View File

@ -201,7 +201,7 @@ const Login: React.FC = () => {
<>
<div className={styles.login}>
<div className={styles.loginBg}>
<img src={import.meta.env.VITE_ENV === 'xy' ? ImageUrl.icon53 : ImageUrl.icon1} alt="" />
<img src={storage.getItem('env') === 'xy' ? ImageUrl.icon53 : ImageUrl.icon1} alt="" />
</div>
<div className={styles.loginContent}>
<div>

View File

@ -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, {

View File

@ -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 => {

View File

@ -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: {
// 请求拦截器