From 4cb89d20205d05a4fee13855c5e4ed780a07f839 Mon Sep 17 00:00:00 2001 From: none Date: Mon, 10 Apr 2023 11:28:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BC=95=E5=85=A5=E8=B0=B7=E6=AD=8C?= =?UTF-8?q?=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 ++- package.json | 6 +++++- src/App.tsx | 30 +++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index ce3783e..a2e482c 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -VITE_APP_URL= \ No newline at end of file +VITE_APP_URL= +VITE_G_ID= \ No newline at end of file diff --git a/package.json b/package.json index 526f928..caea202 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,22 @@ }, "dependencies": { "@reduxjs/toolkit": "^1.9.3", + "add": "^2.0.6", "antd": "^5.3.2", "axios": "^1.3.4", "localforage": "^1.10.0", "match-sorter": "^6.3.1", "moment": "^2.29.4", + "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", "sort-by": "^1.2.0", - "web-vitals": "^3.3.0" + "web-vitals": "^3.3.0", + "yarn": "^1.22.19" }, "devDependencies": { "@types/react": "^18.0.28", diff --git a/src/App.tsx b/src/App.tsx index 1040ca7..a4c2ce4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,31 +1,43 @@ -import { useRoutes } from "react-router-dom"; +import { Suspense, useEffect } from "react"; +import ReactGA from "react-ga"; +import { useLocation, useRoutes } from "react-router-dom"; import routes from "./routes"; import "./App.scss"; -import { Suspense } from "react"; import LoadingPage from "./pages/loading"; import { user } from "./api/index"; import { getToken } from "./utils/index"; import { useDispatch } from "react-redux"; import { loginAction } from "./store/user/loginUserSlice"; -function App() { - const Views = () => useRoutes(routes); +const G_ID = import.meta.env.VITE_G_ID || ""; +if (G_ID) { + ReactGA.initialize(G_ID); +} + +const App = () => { const dispatch = useDispatch(); - const getUser = () => { + const Views = () => useRoutes(routes); + + if (getToken()) { user.detail().then((res: any) => { const data = res.data; dispatch(loginAction(data)); }); - }; - if (getToken()) { - getUser(); } + const location = useLocation(); + useEffect(() => { + if (!G_ID) { + return; + } + ReactGA.pageview(location.pathname + location.search); + }, [location]); + return ( }> ); -} +}; export default App; From 2bb831bf7cf589e1ccecf89305d453e02840ec4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 11 Apr 2023 16:42:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?api=E9=87=8D=E5=A4=8D=E4=B8=A4=E6=AC=A1?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/user-info/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compenents/user-info/index.tsx b/src/compenents/user-info/index.tsx index e8957f7..22dc743 100644 --- a/src/compenents/user-info/index.tsx +++ b/src/compenents/user-info/index.tsx @@ -22,7 +22,9 @@ export const UserInfoModel: React.FC = ({ open, onCancel }) => { const [idCard, setIdCard] = useState(""); useEffect(() => { - getUser(); + if (open) { + getUser(); + } }, [form, open]); const getUser = () => { From 2a5eab39a648fa860070fa7a9bd68c69c6343f12 Mon Sep 17 00:00:00 2001 From: none Date: Wed, 12 Apr 2023 11:39:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +--- src/main.tsx | 9 +-------- src/reportWebVitals.ts | 15 --------------- 3 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 src/reportWebVitals.ts diff --git a/package.json b/package.json index caea202..2d56ee7 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ "react-redux": "^8.0.5", "react-router-dom": "^6.9.0", "redux": "^4.2.1", - "sort-by": "^1.2.0", - "web-vitals": "^3.3.0", - "yarn": "^1.22.19" + "sort-by": "^1.2.0" }, "devDependencies": { "@types/react": "^18.0.28", diff --git a/src/main.tsx b/src/main.tsx index eca299d..92d8eed 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,8 +1,6 @@ -import React from "react"; import ReactDOM from "react-dom/client"; import { Provider } from "react-redux"; import store from "./store"; -import reportWebVitals from "./reportWebVitals"; import { BrowserRouter } from "react-router-dom"; import { ConfigProvider } from "antd"; import zhCN from "antd/locale/zh_CN"; @@ -20,9 +18,4 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( -); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); +); \ No newline at end of file diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts deleted file mode 100644 index 49a2a16..0000000 --- a/src/reportWebVitals.ts +++ /dev/null @@ -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;