mirror of
https://github.com/PlayEdu/h5.git
synced 2025-06-06 14:45:33 +08:00
移除 react-ga 和 web-vitals 依赖
This commit is contained in:
parent
263a3abccb
commit
387c930795
@ -1,2 +1 @@
|
|||||||
VITE_APP_URL=
|
VITE_APP_URL=
|
||||||
VITE_G_ID=
|
|
@ -19,12 +19,10 @@
|
|||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-ga": "^3.3.1",
|
|
||||||
"react-redux": "^8.0.5",
|
"react-redux": "^8.0.5",
|
||||||
"react-router-dom": "^6.9.0",
|
"react-router-dom": "^6.9.0",
|
||||||
"redux": "^4.2.1",
|
"redux": "^4.2.1",
|
||||||
"sort-by": "^1.2.0",
|
"sort-by": "^1.2.0"
|
||||||
"web-vitals": "^3.3.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.2.0",
|
"@types/react": "^18.2.0",
|
||||||
|
18
src/App.tsx
18
src/App.tsx
@ -1,26 +1,12 @@
|
|||||||
import { Suspense, useEffect } from "react";
|
import { Suspense } from "react";
|
||||||
import ReactGA from "react-ga";
|
import { useRoutes } from "react-router-dom";
|
||||||
import { useLocation, useRoutes } from "react-router-dom";
|
|
||||||
import routes from "./routes";
|
import routes from "./routes";
|
||||||
import "./App.scss";
|
import "./App.scss";
|
||||||
import LoadingPage from "./pages/loading";
|
import LoadingPage from "./pages/loading";
|
||||||
|
|
||||||
const G_ID = import.meta.env.VITE_G_ID || "";
|
|
||||||
if (G_ID) {
|
|
||||||
ReactGA.initialize(G_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const Views = () => useRoutes(routes);
|
const Views = () => useRoutes(routes);
|
||||||
|
|
||||||
const location = useLocation();
|
|
||||||
useEffect(() => {
|
|
||||||
if (!G_ID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ReactGA.pageview(location.pathname + location.search);
|
|
||||||
}, [location]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<LoadingPage />}>
|
<Suspense fallback={<LoadingPage />}>
|
||||||
<Views />
|
<Views />
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { ReportHandler } from 'web-vitals';
|
|
||||||
|
|
||||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
||||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
||||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
||||||
getCLS(onPerfEntry);
|
|
||||||
getFID(onPerfEntry);
|
|
||||||
getFCP(onPerfEntry);
|
|
||||||
getLCP(onPerfEntry);
|
|
||||||
getTTFB(onPerfEntry);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default reportWebVitals;
|
|
Loading…
x
Reference in New Issue
Block a user