This commit is contained in:
yj 2024-07-24 15:44:24 +08:00
parent efed95d22f
commit 98e3f7ccbd
6 changed files with 43 additions and 14 deletions

View File

@ -173,12 +173,5 @@ app.on('ready', () => {
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
mainWindow.setPosition(x, y);
});
// 打开新页面
ipcMain.handle('openNewPage', (event, url) => {
const env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1];
const winURL = env === 'development'
? `http://localhost:3000`
: path.resolve(__dirname, './dist/index.html')
});
});

View File

@ -21,12 +21,12 @@ window.electron = {
joinNotification: (user) => {
ipcRenderer.invoke('joinNotification', user)
},
// 打开新页面
openNewPage: (url) => {
ipcRenderer.invoke('openNewPage', url)
},
// 监听退出
onQuit: (callback) => {
ipcRenderer.on('quit', callback)
},
// 监听更新
onUpdate: (callback) => {
ipcRenderer.on('update', callback)
},
}

View File

@ -11,16 +11,18 @@ import NotFound from '@/page/NotFound/index'
import { storage } from '@/utils'
import { Spin, message } from "antd";
import { onInvitation, onInvoke, onReconnected, onStart } from "@/utils/package/signalr";
import JoinMeetingModal from "./components/JoinMeetingModal";
import JoinMeetingModal from "@/components/JoinMeetingModal";
import UpdateModal from "@/components/UpdateModal";
import * as CryptoJS from 'crypto-js';
import { PostLogin } from "@/api/Login";
import { startSignalr } from '@/utils/package/signalr';
import agora from "./utils/package/agora";
import agora from "@/utils/package/agora";
const App: React.FC = () => {
const navigate = useNavigate();
const { state } = useLocation();
const joinMeetingModalRef = useRef<any>();
const updateModalRef = useRef<any>();
const [_windowSize, setWindowSize] = useState({
width: window.innerWidth,
height: window.innerHeight,
@ -114,6 +116,9 @@ const App: React.FC = () => {
onReconnected(async () => {
storage.setItem('reconnect', true)
})
window.electron.onUpdate((data:any) => {
updateModalRef.current.changeModal(data)
})
}, [])
useEffect(() => {
if (isState) {
@ -175,6 +180,7 @@ const App: React.FC = () => {
</Routes>
<Spin spinning={spinning} fullscreen />
<JoinMeetingModal ref={joinMeetingModalRef} />
<UpdateModal ref={updateModalRef} />
</>
)
}

View File

@ -0,0 +1 @@
.isUpdateModal {}

View File

@ -0,0 +1,29 @@
import styles from '@/components/UpdateModal/index.module.scss'
import { Modal } from 'antd';
import { useState, useImperativeHandle, forwardRef } from "react";
const UpdateModal = forwardRef((props: any, ref: any) => {
useImperativeHandle(ref, () => ({
changeModal: (data: any) => {
setIsUpdateModal(true)
}
}))
const [isUpdateModal, setIsUpdateModal] = useState(false);
return (
<>
<Modal
title="更新"
open={isUpdateModal}
footer={null}
onCancel={() => setIsUpdateModal(false)}
centered
width={'400px'}
>
<div className={styles.isUpdateModal}>
</div>
</Modal>
</>
)
})
export default UpdateModal

2
src/render.d.ts vendored
View File

@ -4,8 +4,8 @@ export interface IElectronAPI {
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void;
getIsMaximized: () => Promise<boolean>;
setWriteText: (text: string) => void;
openNewPage: (url: string) => void;
onQuit: (callBack:Function) => void;
onUpdate: (callBack:Function) => void;
joinNotification: (data: { name: string, body: string }) => void
}
declare global {