mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-22 02:16:30 +08:00
commit
123cf31503
@ -1 +1,2 @@
|
|||||||
VITE_APP_URL=
|
VITE_APP_URL=
|
||||||
|
VITE_G_ID=
|
@ -10,18 +10,20 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@reduxjs/toolkit": "^1.9.3",
|
"@reduxjs/toolkit": "^1.9.3",
|
||||||
|
"add": "^2.0.6",
|
||||||
"antd": "^5.3.2",
|
"antd": "^5.3.2",
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"match-sorter": "^6.3.1",
|
"match-sorter": "^6.3.1",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
|
"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.0.28",
|
"@types/react": "^18.0.28",
|
||||||
|
30
src/App.tsx
30
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 routes from "./routes";
|
||||||
import "./App.scss";
|
import "./App.scss";
|
||||||
import { Suspense } from "react";
|
|
||||||
import LoadingPage from "./pages/loading";
|
import LoadingPage from "./pages/loading";
|
||||||
import { user } from "./api/index";
|
import { user } from "./api/index";
|
||||||
import { getToken } from "./utils/index";
|
import { getToken } from "./utils/index";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { loginAction } from "./store/user/loginUserSlice";
|
import { loginAction } from "./store/user/loginUserSlice";
|
||||||
|
|
||||||
function App() {
|
const G_ID = import.meta.env.VITE_G_ID || "";
|
||||||
const Views = () => useRoutes(routes);
|
if (G_ID) {
|
||||||
|
ReactGA.initialize(G_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const getUser = () => {
|
const Views = () => useRoutes(routes);
|
||||||
|
|
||||||
|
if (getToken()) {
|
||||||
user.detail().then((res: any) => {
|
user.detail().then((res: any) => {
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
dispatch(loginAction(data));
|
dispatch(loginAction(data));
|
||||||
});
|
});
|
||||||
};
|
|
||||||
if (getToken()) {
|
|
||||||
getUser();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
@ -22,7 +22,9 @@ export const UserInfoModel: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
const [idCard, setIdCard] = useState<string>("");
|
const [idCard, setIdCard] = useState<string>("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getUser();
|
if (open) {
|
||||||
|
getUser();
|
||||||
|
}
|
||||||
}, [form, open]);
|
}, [form, open]);
|
||||||
|
|
||||||
const getUser = () => {
|
const getUser = () => {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import React from "react";
|
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
import reportWebVitals from "./reportWebVitals";
|
|
||||||
import { BrowserRouter } from "react-router-dom";
|
import { BrowserRouter } from "react-router-dom";
|
||||||
import { ConfigProvider } from "antd";
|
import { ConfigProvider } from "antd";
|
||||||
import zhCN from "antd/locale/zh_CN";
|
import zhCN from "antd/locale/zh_CN";
|
||||||
@ -21,8 +19,3 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
|||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|
||||||
// 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();
|
|
||||||
|
@ -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