mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-07 13:24:11 +08:00
移除 react-ga 依赖
This commit is contained in:
parent
39250531fb
commit
96da44a884
@ -1,2 +1 @@
|
||||
VITE_APP_URL=
|
||||
VITE_G_ID=
|
@ -21,7 +21,6 @@
|
||||
"prop-types": "^15.8.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-ga": "^3.3.1",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-router-dom": "^6.9.0",
|
||||
"redux": "^4.2.1",
|
||||
|
24
src/App.tsx
24
src/App.tsx
@ -1,31 +1,13 @@
|
||||
import { Suspense, useEffect } from "react";
|
||||
import ReactGA from "react-ga";
|
||||
import { useLocation, useRoutes } from "react-router-dom";
|
||||
import { Suspense } from "react";
|
||||
import { useRoutes } from "react-router-dom";
|
||||
import routes from "./routes";
|
||||
import "./App.scss";
|
||||
import LoadingPage from "./pages/loading";
|
||||
|
||||
const G_ID = import.meta.env.VITE_G_ID || "";
|
||||
if (G_ID) {
|
||||
ReactGA.initialize(G_ID);
|
||||
}
|
||||
|
||||
const App = () => {
|
||||
const views = useRoutes(routes);
|
||||
|
||||
const location = useLocation();
|
||||
useEffect(() => {
|
||||
if (!G_ID) {
|
||||
return;
|
||||
}
|
||||
ReactGA.pageview(location.pathname + location.search);
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
<Suspense fallback={<LoadingPage />}>
|
||||
{views}
|
||||
</Suspense>
|
||||
);
|
||||
return <Suspense fallback={<LoadingPage />}>{views}</Suspense>;
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
Loading…
x
Reference in New Issue
Block a user