This commit is contained in:
parent
efed95d22f
commit
98e3f7ccbd
7
main.js
7
main.js
|
|
@ -173,12 +173,5 @@ app.on('ready', () => {
|
||||||
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
|
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
|
||||||
mainWindow.setPosition(x, y);
|
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')
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ window.electron = {
|
||||||
joinNotification: (user) => {
|
joinNotification: (user) => {
|
||||||
ipcRenderer.invoke('joinNotification', user)
|
ipcRenderer.invoke('joinNotification', user)
|
||||||
},
|
},
|
||||||
// 打开新页面
|
|
||||||
openNewPage: (url) => {
|
|
||||||
ipcRenderer.invoke('openNewPage', url)
|
|
||||||
},
|
|
||||||
// 监听退出
|
// 监听退出
|
||||||
onQuit: (callback) => {
|
onQuit: (callback) => {
|
||||||
ipcRenderer.on('quit', callback)
|
ipcRenderer.on('quit', callback)
|
||||||
},
|
},
|
||||||
|
// 监听更新
|
||||||
|
onUpdate: (callback) => {
|
||||||
|
ipcRenderer.on('update', callback)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
10
src/App.tsx
10
src/App.tsx
|
|
@ -11,16 +11,18 @@ import NotFound from '@/page/NotFound/index'
|
||||||
import { storage } from '@/utils'
|
import { storage } from '@/utils'
|
||||||
import { Spin, message } from "antd";
|
import { Spin, message } from "antd";
|
||||||
import { onInvitation, onInvoke, onReconnected, onStart } from "@/utils/package/signalr";
|
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 * as CryptoJS from 'crypto-js';
|
||||||
import { PostLogin } from "@/api/Login";
|
import { PostLogin } from "@/api/Login";
|
||||||
import { startSignalr } from '@/utils/package/signalr';
|
import { startSignalr } from '@/utils/package/signalr';
|
||||||
import agora from "./utils/package/agora";
|
import agora from "@/utils/package/agora";
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { state } = useLocation();
|
const { state } = useLocation();
|
||||||
const joinMeetingModalRef = useRef<any>();
|
const joinMeetingModalRef = useRef<any>();
|
||||||
|
const updateModalRef = useRef<any>();
|
||||||
const [_windowSize, setWindowSize] = useState({
|
const [_windowSize, setWindowSize] = useState({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
|
|
@ -114,6 +116,9 @@ const App: React.FC = () => {
|
||||||
onReconnected(async () => {
|
onReconnected(async () => {
|
||||||
storage.setItem('reconnect', true)
|
storage.setItem('reconnect', true)
|
||||||
})
|
})
|
||||||
|
window.electron.onUpdate((data:any) => {
|
||||||
|
updateModalRef.current.changeModal(data)
|
||||||
|
})
|
||||||
}, [])
|
}, [])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isState) {
|
if (isState) {
|
||||||
|
|
@ -175,6 +180,7 @@ const App: React.FC = () => {
|
||||||
</Routes>
|
</Routes>
|
||||||
<Spin spinning={spinning} fullscreen />
|
<Spin spinning={spinning} fullscreen />
|
||||||
<JoinMeetingModal ref={joinMeetingModalRef} />
|
<JoinMeetingModal ref={joinMeetingModalRef} />
|
||||||
|
<UpdateModal ref={updateModalRef} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
.isUpdateModal {}
|
||||||
|
|
@ -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
|
||||||
|
|
@ -4,8 +4,8 @@ export interface IElectronAPI {
|
||||||
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void;
|
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void;
|
||||||
getIsMaximized: () => Promise<boolean>;
|
getIsMaximized: () => Promise<boolean>;
|
||||||
setWriteText: (text: string) => void;
|
setWriteText: (text: string) => void;
|
||||||
openNewPage: (url: string) => void;
|
|
||||||
onQuit: (callBack:Function) => void;
|
onQuit: (callBack:Function) => void;
|
||||||
|
onUpdate: (callBack:Function) => void;
|
||||||
joinNotification: (data: { name: string, body: string }) => void
|
joinNotification: (data: { name: string, body: string }) => void
|
||||||
}
|
}
|
||||||
declare global {
|
declare global {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue