diff --git a/src/App.tsx b/src/App.tsx
index 6568bc5..ea818e8 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,20 +1,46 @@
import Head from './layout/head/Head.tsx';
import Body from './layout/body/Body.tsx';
import Foot from './layout/foot/Foot.tsx';
-import {GlobalContext, GlobalData} from "./context/GlobalContext.ts";
-
+import {
+ GlobalContext,
+ GlobalData,
+ GlobalDataAction,
+ GlobalDataActionType,
+ GlobalDispatchContext
+} from "./context/GlobalContext.ts";
+import {Reducer, useReducer} from "react";
const App: React.FC = () => {
-
- const globalData: GlobalData = {
+ const globalDataReducer = (state: GlobalData, action: GlobalDataAction) => {
+ if (action.type == GlobalDataActionType.REFRESH_SELF) {
+ if(action.user) {
+ state.user.balance = action.user.balance;
+ state.user.nickname = action.user.nickname;
+ state.user.username = action.user.username;
+ state.user.hasUserInfo = action.user.hasUserInfo;
+ }
+ }
+ return {
+ ...state
+ }
}
+ const [globalData, dispatch] = useReducer>(globalDataReducer, {
+ user: {
+ balance: '0',
+ username: '',
+ nickname: '',
+ hasUserInfo: false
+ }
+ });
return (
<>
-
-
-
+
+
+