打包优化
This commit is contained in:
parent
f6aca11a83
commit
f0c79d64cd
7
main.js
7
main.js
|
|
@ -64,9 +64,6 @@ class AppWindow extends BrowserWindow {
|
|||
// this.loadFile(path.resolve(__dirname, './dist/index.html'))
|
||||
this.once('ready-to-show', () => {
|
||||
this.show();
|
||||
mainWindow.webContents.send('changeLocalStorage', {
|
||||
env,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -485,6 +482,10 @@ app.on('ready', () => {
|
|||
ipcMain.handle('getVersion', () => {
|
||||
return app.getVersion();
|
||||
});
|
||||
// 获取环境
|
||||
ipcMain.handle('getEnv', () => {
|
||||
return env;
|
||||
});
|
||||
// 获取窗口是否显示
|
||||
ipcMain.handle('isVisible', () => {
|
||||
return mainWindow.isVisible();
|
||||
|
|
|
|||
|
|
@ -51,6 +51,10 @@ window.electron = {
|
|||
getVersion: () => {
|
||||
return ipcRenderer.invoke('getVersion')
|
||||
},
|
||||
// 获取环境
|
||||
getEnv: () => {
|
||||
return ipcRenderer.invoke('getEnv')
|
||||
},
|
||||
// 获取窗口是否显示
|
||||
isVisible: () => {
|
||||
return ipcRenderer.invoke('isVisible')
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ const App: React.FC = () => {
|
|||
document.addEventListener('keydown', (event) => {
|
||||
if (event.keyCode == 122) {
|
||||
event.preventDefault();
|
||||
} else if (((event.ctrlKey && event.keyCode == 82) || event.keyCode == 116) && storage.getItem('env') !== 'development') {
|
||||
} else if (((event.ctrlKey && event.keyCode == 82) || event.keyCode == 116) && window.electron.getEnv() !== 'development') {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
|
@ -288,6 +288,8 @@ const App: React.FC = () => {
|
|||
storage.removeItem('user')
|
||||
navigate('/login')
|
||||
}
|
||||
} else if (e.key === 'env') {
|
||||
|
||||
}
|
||||
};
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import ImageUrl from '@/utils/package/imageUrl';
|
||||
import { Empty, Popover } from 'antd';
|
||||
import { GetQrcode } from '@/api/Home/Index';
|
||||
import { memo, useImperativeHandle, forwardRef, useState, useEffect } from "react";
|
||||
import { storage } from '@/utils';
|
||||
import { memo, useImperativeHandle, forwardRef, useState } from "react";
|
||||
const Code = forwardRef((props: any, ref: any) => {
|
||||
useImperativeHandle(ref, () => ({
|
||||
getData: () => {
|
||||
|
|
@ -10,19 +9,15 @@ const Code = forwardRef((props: any, ref: any) => {
|
|||
}
|
||||
}))
|
||||
const [baseImage, setBaseImage] = useState('');
|
||||
const [env, setEnv] = useState('')
|
||||
const [roomNum, setRoomNum] = useState(props.roomNum);
|
||||
useEffect(() => {
|
||||
setEnv(storage.getItem('env') as string)
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
<Popover
|
||||
placement="bottom"
|
||||
onOpenChange={(e: boolean) => {
|
||||
setBaseImage('')
|
||||
if (e && env) {
|
||||
GetQrcode(roomNum, env === 'development' ? 'trial' : 'release').then(res => {
|
||||
if (e) {
|
||||
GetQrcode(roomNum, window.electron.getEnv() === 'development' ? 'trial' : 'release').then(res => {
|
||||
if (res.code === 200) {
|
||||
setBaseImage(res.data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ const VideoComponents = () => {
|
|||
}, [darkLightEnhancement]);
|
||||
useEffect(() => {
|
||||
if (typeof virtualBackground.sourceIndex === 'number') {
|
||||
if (storage.getItem('env') === 'development') {
|
||||
if (window.electron.getEnv() === 'development') {
|
||||
window.electron.getAppPath().then((res: string) => {
|
||||
const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${virtualBackground.sourceIndex + 1}.png`);
|
||||
agora.enableVirtualBackground(virtualBackground.isVirtualBackground, {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
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';
|
||||
import { forwardRef, useImperativeHandle, useState, memo, useEffect } from "react";
|
||||
import { forwardRef, useImperativeHandle, useState, memo } from "react";
|
||||
|
||||
const UpdateModal = forwardRef((props: any, ref: any) => {
|
||||
useImperativeHandle(ref, () => ({
|
||||
|
|
@ -42,14 +41,10 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
|
|||
}
|
||||
}
|
||||
}))
|
||||
const [env, setEnv] = useState('')
|
||||
const [isUpdateModal, setIsUpdateModal] = useState(false);
|
||||
const [progress, setProgress] = useState(0); // 下载进度值
|
||||
const [updateContent, setUpdateContent] = useState('') // 版本更新内容
|
||||
|
||||
useEffect(() => {
|
||||
setEnv(storage.getItem('env') as string)
|
||||
}, [])
|
||||
function getContent() {
|
||||
fetch(`${getUpdateUrl()}/update.txt?t=${+new Date()}`) // 配置服务器地址
|
||||
.then(async response => {
|
||||
|
|
@ -95,7 +90,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
|
|||
style={{ width: '100%', height: '40px', marginBottom: '10px' }}
|
||||
className={`m-ant-btn`}
|
||||
>立即更新</Button>
|
||||
{env === "development" ? <div className={styles.button2} onClick={() => setIsUpdateModal(false)}>暂不更新</div> : null}
|
||||
{window.electron.getEnv() === "development" ? <div className={styles.button2} onClick={() => setIsUpdateModal(false)}>暂不更新</div> : null}
|
||||
</div> : progress < 100 ?
|
||||
<div style={{ margin: '20px 0' }}>
|
||||
下载进度:{progress}%
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ const Login: React.FC = () => {
|
|||
roomNum: '',
|
||||
})
|
||||
const [nameModal, setNameModal] = useState(false)
|
||||
const [env, setEnv] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
window.electron.setMainWindowSize({
|
||||
|
|
@ -48,7 +47,6 @@ const Login: React.FC = () => {
|
|||
height: 520,
|
||||
key: 'login'
|
||||
})
|
||||
setEnv(storage.getItem('env') as string)
|
||||
if (storage.getItem('login')) {
|
||||
const login = JSON.parse(storage.getItem('login') as string);
|
||||
const data = {
|
||||
|
|
@ -203,7 +201,7 @@ const Login: React.FC = () => {
|
|||
<>
|
||||
<div className={styles.login}>
|
||||
<div className={styles.loginBg}>
|
||||
{env ? <img src={env === 'xy' ? ImageUrl.icon53 : ImageUrl.icon1} alt="" /> : null}
|
||||
{window.electron.getEnv() ? <img src={window.electron.getEnv() === 'xy' ? ImageUrl.icon53 : ImageUrl.icon1} alt="" /> : null}
|
||||
</div>
|
||||
<div className={styles.loginContent}>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export interface IElectronAPI {
|
|||
startLoad: () => any;
|
||||
updateHandle: () => any;
|
||||
getVersion: () => Promise<string>;
|
||||
getEnv: () => string;
|
||||
isVisible: () => Promise<string>;
|
||||
setRegistry: (uuid: string) => any;
|
||||
getRegistry: () => any;
|
||||
|
|
|
|||
|
|
@ -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 (storage.getItem('env') === 'development') {
|
||||
if (window.electron.getEnv() === '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, {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ export const storageSeeting: any = {
|
|||
}
|
||||
|
||||
export const getUpdateUrl = () => {
|
||||
let env = storage.getItem('env');
|
||||
switch (env) {
|
||||
switch (window.electron.getEnv()) {
|
||||
case 'xy':
|
||||
return 'https://meeting-api.23544.com/meeting/xysz'
|
||||
case 'development':
|
||||
|
|
@ -70,8 +69,7 @@ export const getUpdateUrl = () => {
|
|||
}
|
||||
}
|
||||
export const getTitle = () => {
|
||||
let env = storage.getItem('env');
|
||||
switch (env) {
|
||||
switch (window.electron.getEnv()) {
|
||||
case 'xy':
|
||||
return '湖北襄阳四中教研平台'
|
||||
case 'development':
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { AxiosRequestConfig, AxiosResponse } from 'axios'
|
||||
import Request from './request'
|
||||
import { constant } from '@/config'
|
||||
import storage from '../package/storage'
|
||||
// 实例化
|
||||
const req = new Request({
|
||||
baseURL: storage.getItem('env') === 'development' ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc',
|
||||
baseURL: window.electron.getEnv() === 'development' ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc',
|
||||
timeout: constant.CONFIG_REQUEST_TIMEOUT_TIME as number,
|
||||
interceptors: {
|
||||
// 请求拦截器
|
||||
|
|
|
|||
Loading…
Reference in New Issue