refactor: remove electron lib
This commit is contained in:
+1
-2
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "vocechat-web",
|
||||
"version": "0.5.2",
|
||||
"version": "0.5.4",
|
||||
"homepage": "https://voce.chat",
|
||||
"dependencies": {
|
||||
"@electron-toolkit/preload": "^2.0.0",
|
||||
"@emoji-mart/react": "^1.1.1",
|
||||
"@metamask/onboarding": "^1.0.1",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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;
|
||||
@@ -5,25 +5,26 @@ import { GuestRoutes, KEY_LOCAL_TRY_PATH } from "@/app/config";
|
||||
import { useAppSelector } from "@/app/store";
|
||||
import Loading from "./Loading";
|
||||
import { shallowEqual } from "react-redux";
|
||||
import { LoginConfig } from "@/types/server";
|
||||
|
||||
interface Props {
|
||||
loginConfig: LoginConfig | null;
|
||||
children: ReactElement;
|
||||
redirectTo?: string;
|
||||
}
|
||||
const GuestAllows = GuestRoutes.map((path) => {
|
||||
return { path };
|
||||
});
|
||||
const RequireAuth: FC<Props> = ({ children, redirectTo = "/login" }) => {
|
||||
const RequireAuth: FC<Props> = ({ children, redirectTo = "/login", loginConfig }) => {
|
||||
const location = useLocation();
|
||||
const matches = matchRoutes(GuestAllows, location);
|
||||
const allowGuest = matches ? !!matches[0].pathname : false;
|
||||
const token = useAppSelector((store) => store.authData.token, shallowEqual);
|
||||
const guest = useAppSelector((store) => store.authData.guest, shallowEqual);
|
||||
const initialized = useAppSelector((store) => store.authData.initialized, shallowEqual);
|
||||
const loginConfig = useAppSelector((store) => store.server.loginConfig, shallowEqual);
|
||||
console.info("check basic info", loginConfig);
|
||||
// 初始化login配置检查
|
||||
if (!loginConfig) return <Loading fullscreen={true} context="auth-route" />;
|
||||
if (!loginConfig) return <Loading fullscreen={true} reload context="auth-route" />;
|
||||
// 未初始化 则先走setup 流程
|
||||
if (!initialized) return <Navigate to={`/onboarding`} replace />;
|
||||
// 开启guest 并且没token 而且是允许guest访问的路由 则先去过渡页登录
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { lazy, memo, useEffect } from "react";
|
||||
import { lazy, useEffect, memo } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { Provider, shallowEqual } 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 { compareVersion, isElectronContext } from "@/utils";
|
||||
import { compareVersion } from "@/utils";
|
||||
import { vapidKey } from "../app/config";
|
||||
import store, { useAppSelector } from "../app/store";
|
||||
import NotFoundPage from "./404";
|
||||
@@ -40,6 +38,7 @@ const HomePage = lazy(() => import("./home"));
|
||||
|
||||
let toastId: string;
|
||||
const PageRoutes = () => {
|
||||
const loginConfig = useAppSelector((store) => store.server.loginConfig, shallowEqual);
|
||||
const version = useAppSelector((store) => store.server.version, shallowEqual);
|
||||
const online = useAppSelector((store) => store.ui.online, shallowEqual);
|
||||
// 提前获取device token
|
||||
@@ -70,7 +69,7 @@ const PageRoutes = () => {
|
||||
path="/invite_private/:channel_id"
|
||||
element={
|
||||
<LazyIt>
|
||||
<RequireAuth>
|
||||
<RequireAuth loginConfig={loginConfig}>
|
||||
<InvitePrivate />
|
||||
</RequireAuth>
|
||||
</LazyIt>
|
||||
@@ -174,7 +173,7 @@ const PageRoutes = () => {
|
||||
path="/"
|
||||
element={
|
||||
<LazyIt>
|
||||
<RequireAuth>
|
||||
<RequireAuth loginConfig={loginConfig}>
|
||||
{/* 只允许活跃一个tab标签 */}
|
||||
<RequireSingleTab>
|
||||
<HomePage />
|
||||
@@ -295,7 +294,6 @@ const PageRoutes = () => {
|
||||
function ReduxRoutes() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
{isElectronContext() && <Electron />}
|
||||
<Meta />
|
||||
<PageRoutes />
|
||||
</Provider>
|
||||
|
||||
Vendored
+13
-7
@@ -1,5 +1,12 @@
|
||||
import { IAgoraRTCClient, ICameraVideoTrack, ILocalAudioTrack, ILocalVideoTrack, IMicrophoneAudioTrack, IRemoteAudioTrack, IRemoteVideoTrack } from "agora-rtc-sdk-ng";
|
||||
import {ElectronAPI} from '@electron-toolkit/preload';
|
||||
import {
|
||||
IAgoraRTCClient,
|
||||
ICameraVideoTrack,
|
||||
ILocalAudioTrack,
|
||||
ILocalVideoTrack,
|
||||
IMicrophoneAudioTrack,
|
||||
IRemoteAudioTrack,
|
||||
IRemoteVideoTrack
|
||||
} from "agora-rtc-sdk-ng";
|
||||
interface BeforeInstallPromptEvent extends Event {
|
||||
/**
|
||||
* Returns an array of DOMString items containing the platforms on which the event was dispatched.
|
||||
@@ -28,17 +35,16 @@ export declare global {
|
||||
import localforage from "localforage";
|
||||
|
||||
interface Window {
|
||||
electron: ElectronAPI;
|
||||
__WB_MANIFEST: Array<PrecacheEntry | string>;
|
||||
skipWaiting: () => void;
|
||||
CACHE: { [key: string]: typeof localforage | undefined };
|
||||
VOICE_CLIENT?: IAgoraRTCClient;
|
||||
VOICE_TRACK_MAP: {
|
||||
[key: number]: IRemoteAudioTrack | IMicrophoneAudioTrack | undefined | null
|
||||
},
|
||||
[key: number]: IRemoteAudioTrack | IMicrophoneAudioTrack | undefined | null;
|
||||
};
|
||||
VIDEO_TRACK_MAP: {
|
||||
[key: number]: IRemoteVideoTrack | ICameraVideoTrack | ShareScreenTrack | undefined | null
|
||||
},
|
||||
[key: number]: IRemoteVideoTrack | ICameraVideoTrack | ShareScreenTrack | undefined | null;
|
||||
};
|
||||
}
|
||||
interface WindowEventMap {
|
||||
beforeinstallprompt: BeforeInstallPromptEvent;
|
||||
|
||||
@@ -1259,11 +1259,6 @@
|
||||
"@babel/helper-validator-identifier" "^7.22.5"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@electron-toolkit/preload@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://mirrors.cloud.tencent.com/npm/@electron-toolkit/preload/-/preload-2.0.0.tgz#1b704c4c4643ae1d960835db196625e17c9dcf4e"
|
||||
integrity sha512-zpZDzbqJTZQC5d4LRs2EKruKWnqah+T75s+niBYFemYLtiW5TTZcWi3Q8UxHqnwTudDMuWJb233aaS2yjx3Xiw==
|
||||
|
||||
"@emoji-mart/react@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://mirrors.cloud.tencent.com/npm/@emoji-mart/react/-/react-1.1.1.tgz#ddad52f93a25baf31c5383c3e7e4c6e05554312a"
|
||||
|
||||
Reference in New Issue
Block a user