瀏覽代碼

修复token失效异步回调登录页错误

shaogen1995 2 年之前
父節點
當前提交
80accecab2

+ 1 - 1
houtai/src/pages/Layout/index.tsx

@@ -256,7 +256,7 @@ function Layout() {
 
   const checkPassWord = (rule: any, value: any = "") => {
     if (value !== oldPasswordValue.current)
-      return Promise.reject("新密码不一致!");
+      return Promise.reject("新密码不一致!");
     else return Promise.resolve(value);
   };
 

+ 6 - 4
houtai/src/store/action/B2Goods.ts

@@ -9,10 +9,12 @@ import store, { AppDispatch } from "..";
 export const getGoodsListAPI = (data: any) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("cms/goods/pageList", data);
-    dispatch({
-      type: "goods/getList",
-      payload: { list: res.data.records, total: res.data.total },
-    });
+    if (res.code === 0) {
+      dispatch({
+        type: "goods/getList",
+        payload: { list: res.data.records, total: res.data.total },
+      });
+    }
   };
 };
 

+ 1 - 1
houtai/src/store/action/B3Wall.ts

@@ -24,7 +24,7 @@ export const editWallAutoApi = (data: { content: string }) => {
 export const getWallTableListAPI = () => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get("cms/wall/list");
-    dispatch({ type: "wall/getList", payload: res.data });
+    if (res.code === 0) dispatch({ type: "wall/getList", payload: res.data });
   };
 };
 

+ 8 - 5
houtai/src/store/action/B4Barrage.ts

@@ -6,10 +6,12 @@ import { AppDispatch } from "..";
 export const getBarrageListAPI = (data: any) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("cms/barrage/pageList", data);
-    dispatch({
-      type: "barrage/getList",
-      payload: { list: res.data.records, total: res.data.total },
-    });
+    if (res.code === 0) {
+      dispatch({
+        type: "barrage/getList",
+        payload: { list: res.data.records, total: res.data.total },
+      });
+    }
   };
 };
 
@@ -47,6 +49,7 @@ export const barrageGetConfigAPI = () => {
 export const barrageGetUnauditedAPI = () => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get("cms/barrage/getUnaudited");
-    dispatch({ type: "barrage/stateNum", payload: res.data });
+    if (res.code === 0)
+      dispatch({ type: "barrage/stateNum", payload: res.data });
   };
 };

+ 7 - 6
houtai/src/store/action/B5Topic.ts

@@ -8,11 +8,12 @@ import { AppDispatch } from "..";
 export const getTopicListAPI = (data: any) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("cms/question/pageList", data);
-
-    dispatch({
-      type: "topic/getList",
-      payload: { list: res.data.records, total: res.data.total },
-    });
+    if (res.code === 0) {
+      dispatch({
+        type: "topic/getList",
+        payload: { list: res.data.records, total: res.data.total },
+      });
+    }
   };
 };
 
@@ -56,4 +57,4 @@ export const getTopicDetailAPI = (id: number) => {
  */
 export const topicGetBindingAPI = (goodsId: number) => {
   return http.get(`cms/question/getBinding/${goodsId}`);
-};
+};

+ 6 - 4
houtai/src/store/action/B6Smart.ts

@@ -29,10 +29,12 @@ export const smartDisplayAPI = (id: number, display: number) => {
 export const smartGetListAPI = (type: "hot" | "play") => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get(`cms/guide/list/${type}`);
-    dispatch({
-      type: type === "hot" ? "smart/getHotList" : "smart/getAutoList",
-      payload: res.data,
-    });
+    if (res.code === 0) {
+      dispatch({
+        type: type === "hot" ? "smart/getHotList" : "smart/getAutoList",
+        payload: res.data,
+      });
+    }
   };
 };
 

+ 12 - 8
houtai/src/store/action/C1User.ts

@@ -7,12 +7,14 @@ import { AppDispatch } from "..";
 export const getUserListAPI = (data: UserTableAPIType) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("sys/user/list", data);
-    const obj = {
-      list: res.data.records,
-      total: res.data.total,
-    };
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total,
+      };
 
-    dispatch({ type: "user/getList", payload: obj });
+      dispatch({ type: "user/getList", payload: obj });
+    }
   };
 };
 
@@ -22,9 +24,11 @@ export const getUserListAPI = (data: UserTableAPIType) => {
 export const getUserRoleAPI = () => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get("sys/user/getRole");
-    const data: RoleTableType[] = res.data;
-    const newData = data.map((v) => ({ label: v.roleName, value: v.id }));
-    dispatch({ type: "user/getRoleList", payload: newData });
+    if (res.code === 0) {
+      const data: RoleTableType[] = res.data;
+      const newData = data.map((v) => ({ label: v.roleName, value: v.id }));
+      dispatch({ type: "user/getRoleList", payload: newData });
+    }
   };
 };
 

+ 9 - 7
houtai/src/store/action/C2Role.ts

@@ -7,13 +7,14 @@ import { AppDispatch } from "..";
 export const getRoleListAPI = (data: any) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("sys/role/listCountPage", data);
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total,
+      };
 
-    const obj = {
-      list: res.data.records,
-      total: res.data.total,
-    };
-
-    dispatch({ type: "Role/getList", payload: obj });
+      dispatch({ type: "Role/getList", payload: obj });
+    }
   };
 };
 
@@ -37,7 +38,8 @@ export const roleDisplayAPI = (id: number, display: number) => {
 export const getPermissionsAPI = () => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get("sys/resource/getTreePermissions");
-    dispatch({ type: "login/setAuthPageArr", payload: res.data });
+    if (res.code === 0)
+      dispatch({ type: "login/setAuthPageArr", payload: res.data });
   };
 };
 

+ 7 - 5
houtai/src/store/action/C3log.ts

@@ -6,10 +6,12 @@ import { AppDispatch } from "..";
 export const getLogListAPI = (data: any) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("sys/log/list", data);
-    const obj = {
-      list: res.data.records,
-      total: res.data.total,
-    };
-    dispatch({ type: "log/getList", payload: obj });
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total,
+      };
+      dispatch({ type: "log/getList", payload: obj });
+    }
   };
 };

+ 15 - 13
houtai/src/store/action/login.ts

@@ -24,19 +24,21 @@ export const passWordEditAPI = (data: any) => {
 export const getDictListAPI = () => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get("cms/dict/getList");
-    const list: DictListTypeAPI[] = res.data;
-    const obj = {
-      age: [{ label: "全部", value: "", type: "age" }],
-      texture: [{ label: "全部", value: "", type: "texture" }],
-      level: [{ label: "全部", value: "", type: "level" }],
-      source: [{ label: "全部", value: "", type: "source" }],
-    } as DictListTypeObj;
-    list.forEach((v) => {
-      if (v.type !== "province") {
-        obj[v.type].push({ label: v.name, value: v.name, type: v.type });
-      }
-    });
+    if (res.code === 0) {
+      const list: DictListTypeAPI[] = res.data;
+      const obj = {
+        age: [{ label: "全部", value: "", type: "age" }],
+        texture: [{ label: "全部", value: "", type: "texture" }],
+        level: [{ label: "全部", value: "", type: "level" }],
+        source: [{ label: "全部", value: "", type: "source" }],
+      } as DictListTypeObj;
+      list.forEach((v) => {
+        if (v.type !== "province") {
+          obj[v.type].push({ label: v.name, value: v.name, type: v.type });
+        }
+      });
 
-    dispatch({ type: "login/getDictList", payload: obj });
+      dispatch({ type: "login/getDictList", payload: obj });
+    }
   };
 };