feat: electron-toolkit

This commit is contained in:
Tristan Yang
2023-07-03 12:09:41 +08:00
parent 0ec8fdafc2
commit 69df0ccb1d
5 changed files with 29 additions and 1 deletions
+18
View File
@@ -0,0 +1,18 @@
import { useEffect } from "react";
// type Props = {};
const Electron = () => {
useEffect(() => {
if (window.electron === undefined) return;
const handleData = (_: any, arg: any) => {
console.log("electron msg", arg);
};
console.log("ttttt", window.electron.process.platform);
window.electron.ipcRenderer.on("server-name-popover", handleData);
}, []);
return null;
};
export default Electron;
+3
View File
@@ -4,11 +4,13 @@ import { Provider } from "react-redux";
import { HashRouter, Route, Routes } from "react-router-dom";
import { isEqual } from "lodash";
import Electron from "@/components/Electron";
import Meta from "@/components/Meta";
import useDeviceToken from "@/components/Notification/useDeviceToken";
import RequireAuth from "@/components/RequireAuth";
import RequireNoAuth from "@/components/RequireNoAuth";
import RequireSingleTab from "@/components/RequireSingleTab";
import { isElectronContext } from "@/utils";
import { vapidKey } from "../app/config";
import store, { useAppSelector } from "../app/store";
import NotFoundPage from "./404";
@@ -296,6 +298,7 @@ const PageRoutes = () => {
export default function ReduxRoutes() {
return (
<Provider store={store}>
{isElectronContext() && <Electron />}
<Meta />
<PageRoutes />
</Provider>
+2 -1
View File
@@ -1,5 +1,5 @@
import { IAgoraRTCClient, ICameraVideoTrack, ILocalAudioTrack, ILocalVideoTrack, IMicrophoneAudioTrack, IRemoteAudioTrack, IRemoteVideoTrack } from "agora-rtc-sdk-ng";
import {ElectronAPI} from '@electron-toolkit/preload';
interface BeforeInstallPromptEvent extends Event {
/**
* Returns an array of DOMString items containing the platforms on which the event was dispatched.
@@ -28,6 +28,7 @@ export declare global {
import localforage from "localforage";
interface Window {
electron: ElectronAPI;
__WB_MANIFEST: Array<PrecacheEntry | string>;
skipWaiting: () => void;
CACHE: { [key: string]: typeof localforage | undefined };