|
@@ -1,58 +1,60 @@
|
|
|
-import { HomeTabUsingPostResponseTabMenus, WxLoginUsingGetResponse } from '@/apis/userApi';
|
|
|
-import StorageUtil, { EStorage } from '@/utils/storageUtil';
|
|
|
-import { createSlice } from '@reduxjs/toolkit';
|
|
|
-
|
|
|
+import {
|
|
|
+ HomeTabUsingPostResponseTabMenus,
|
|
|
+ WxLoginUsingGetResponse,
|
|
|
+} from "@/apis/userApi";
|
|
|
+import StorageUtil, { EStorage } from "@/utils/storageUtil";
|
|
|
+import { createSlice } from "@reduxjs/toolkit";
|
|
|
|
|
|
export interface IReduxStore {
|
|
|
- userInfo: WxLoginUsingGetResponse;
|
|
|
- tabMenu: HomeTabUsingPostResponseTabMenus[]
|
|
|
+ userInfo: WxLoginUsingGetResponse;
|
|
|
+ tabMenu: HomeTabUsingPostResponseTabMenus[];
|
|
|
}
|
|
|
|
|
|
const initialState = (): IReduxStore => ({
|
|
|
- userInfo: StorageUtil.get(EStorage.userInfo),
|
|
|
- tabMenu: StorageUtil.get(EStorage.tabMenu) || [
|
|
|
- {
|
|
|
- code: "home",
|
|
|
- icon: require('@/assets/icon_bottom_bar_apply.png'),
|
|
|
- iconActive: require('@/assets/icon_bottom_bar_apply_active.png'),
|
|
|
- name: "首页",
|
|
|
- },
|
|
|
- {
|
|
|
- code: "user_center",
|
|
|
- icon: require('@/assets/icon_bottom_bar_mine.png'),
|
|
|
- iconActive: require('@/assets/icon_bottom_bar_mine_active.png'),
|
|
|
- name: "我的",
|
|
|
- }
|
|
|
- ]
|
|
|
-})
|
|
|
+ userInfo: StorageUtil.get(EStorage.userInfo),
|
|
|
+ tabMenu: StorageUtil.get(EStorage.tabMenu) || [
|
|
|
+ {
|
|
|
+ code: "home",
|
|
|
+ icon: require("@/assets/icon_bottom_bar_apply.png"),
|
|
|
+ iconActive: require("@/assets/icon_bottom_bar_apply_active.png"),
|
|
|
+ name: "首页",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "user_center",
|
|
|
+ icon: require("@/assets/icon_bottom_bar_mine.png"),
|
|
|
+ iconActive: require("@/assets/icon_bottom_bar_mine_active.png"),
|
|
|
+ name: "我的",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+});
|
|
|
|
|
|
export const reducersSlice = createSlice({
|
|
|
- name: 'reducer',
|
|
|
- initialState: initialState(),
|
|
|
- reducers: {
|
|
|
- changeUserInfo: (state, action) => {
|
|
|
- state.userInfo = action.payload;
|
|
|
- },
|
|
|
- clearState: (state) => {
|
|
|
- let initState = initialState();
|
|
|
- for (const key in state) {
|
|
|
- state[key] = initState[key];
|
|
|
- }
|
|
|
- // state = initialState();
|
|
|
- },
|
|
|
- changeTabMenu: (state, action) => {
|
|
|
- state.tabMenu = action.payload;
|
|
|
- }
|
|
|
- /**更改地址 */
|
|
|
- // changeAddress: (state, action) => {
|
|
|
- // let obj = { ...action.payload };
|
|
|
- // state.wallet = obj;
|
|
|
- // },
|
|
|
+ name: "reducer",
|
|
|
+ initialState: initialState(),
|
|
|
+ reducers: {
|
|
|
+ changeUserInfo: (state, action) => {
|
|
|
+ state.userInfo = action.payload;
|
|
|
+ },
|
|
|
+ clearState: (state) => {
|
|
|
+ let initState = initialState();
|
|
|
+ for (const key in state) {
|
|
|
+ state[key] = initState[key];
|
|
|
+ }
|
|
|
+ // state = initialState();
|
|
|
+ },
|
|
|
+ changeTabMenu: (state, action) => {
|
|
|
+ state.tabMenu = action.payload;
|
|
|
+ },
|
|
|
+ /**更改地址 */
|
|
|
+ // changeAddress: (state, action) => {
|
|
|
+ // let obj = { ...action.payload };
|
|
|
+ // state.wallet = obj;
|
|
|
+ // },
|
|
|
|
|
|
- // changeTokenList: (state, action) => {
|
|
|
- // state.tokenList = action.payload;
|
|
|
- // }
|
|
|
- }
|
|
|
+ // changeTokenList: (state, action) => {
|
|
|
+ // state.tokenList = action.payload;
|
|
|
+ // }
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
-export const reduxActions = reducersSlice.actions;
|
|
|
+export const reduxActions = reducersSlice.actions;
|