init

Change-Id: I62d8e17fdc3103133b9ddaff22c27ddd9ea9f6ac
diff --git a/src/store/index.ts b/src/store/index.ts
new file mode 100644
index 0000000..5501ef3
--- /dev/null
+++ b/src/store/index.ts
@@ -0,0 +1,12 @@
+import {configureStore} from '@reduxjs/toolkit';
+import userReducer from './userReducer';
+const store = configureStore({
+  reducer: {
+    user: userReducer,
+  }
+});
+
+export default store;
+export type RootState = ReturnType<typeof store.getState>
+
+export type AppDispatch = typeof store.dispatch
\ No newline at end of file
diff --git a/src/store/userReducer.ts b/src/store/userReducer.ts
new file mode 100644
index 0000000..f335c25
--- /dev/null
+++ b/src/store/userReducer.ts
@@ -0,0 +1,66 @@
+import { createSlice } from '@reduxjs/toolkit';
+
+interface UserState {
+    userId: number;
+    userName: string;
+    role: string;
+    isLogin: boolean;
+    uploadTraffic: number;
+    downloadTraffic: number;
+    downloadPoints: number;
+    avatar: string;
+}
+
+const initialState: UserState = {
+    userId: 0,
+    userName: '',
+    role: '',
+    isLogin: false,
+    uploadTraffic: 0,
+    downloadTraffic: 0,
+    downloadPoints: 0,
+    avatar: '',
+};
+
+
+export const userSlice = createSlice({
+    name: 'user',
+    initialState,
+    reducers: {
+        login: (state, action) => {
+                
+            state.userId = action.payload.userId;
+            state.userName = action.payload.userName;
+            state.role = action.payload.role;
+            state.isLogin = true;
+            state.uploadTraffic = action.payload.uploadTraffic;
+            state.downloadTraffic = action.payload.downloadTraffic;
+            state.downloadPoints = action.payload.downloadPoints;
+            state.avatar = action.payload.avatar;
+
+            console.log('userId', state.userId);
+        },
+        logout: (state) => {
+            state.userId = 0;
+            state.userName = '';
+            state.role = '';
+            state.isLogin = false;
+            state.uploadTraffic = 0;
+            state.downloadTraffic = 0;
+            state.downloadPoints = 0;
+            state.avatar = '';
+        },
+        updateTraffic: (state, action) => {
+            state.uploadTraffic = action.payload.uploadTraffic;
+            state.downloadTraffic = action.payload.downloadTraffic;
+            state.downloadPoints = action.payload.downloadPoints;
+        },
+        updateAvatar: (state, action) => {
+            state.avatar = action.payload.avatar;
+        }
+    },
+
+});
+
+export const { login, logout, updateTraffic } = userSlice.actions;
+export default userSlice.reducer;
\ No newline at end of file