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