diff --git a/main.js b/main.js index 6020baa..66d6199 100644 --- a/main.js +++ b/main.js @@ -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') - }); }); diff --git a/preload.js b/preload.js index d499723..f47e665 100644 --- a/preload.js +++ b/preload.js @@ -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) + }, } \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 03de7af..f2c55a9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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(); + const updateModalRef = useRef(); 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 = () => { + ) } diff --git a/src/components/UpdateModal/index.module.scss b/src/components/UpdateModal/index.module.scss new file mode 100644 index 0000000..1fdb8ee --- /dev/null +++ b/src/components/UpdateModal/index.module.scss @@ -0,0 +1 @@ +.isUpdateModal {} \ No newline at end of file diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx new file mode 100644 index 0000000..2f8c1b6 --- /dev/null +++ b/src/components/UpdateModal/index.tsx @@ -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 ( + <> + setIsUpdateModal(false)} + centered + width={'400px'} + > +
+ +
+
+ + ) +}) + +export default UpdateModal \ No newline at end of file diff --git a/src/render.d.ts b/src/render.d.ts index b07f90e..a732862 100644 --- a/src/render.d.ts +++ b/src/render.d.ts @@ -4,8 +4,8 @@ export interface IElectronAPI { setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void; getIsMaximized: () => Promise; 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 {