浏览代码

修复token失效回调登录页报错

shaogen1995 2 年之前
父节点
当前提交
c6223803c1

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

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

+ 7 - 5
src/store/action/goods.ts

@@ -7,10 +7,12 @@ import { AppDispatch } from "..";
 export const getGoodsList = (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 },
+      });
+    }
   };
 };
 
@@ -25,7 +27,7 @@ export const goodsUploadAPI = (data: any) => {
   UpAsyncLodingDom.style.opacity = 1;
 
   return http.post("cms/goods/upload", data, {
-    timeout:30000,
+    timeout: 30000,
     // 显示进度条
     onUploadProgress: (e: any) => {
       const complete = (e.loaded / e.total) * 100 || 0;

+ 1 - 1
src/store/action/h5code.ts

@@ -6,6 +6,6 @@ import { AppDispatch } from "..";
 export const getH5InfoAPI = (id: number) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get(`show/goods/detail/${id}`);
-    dispatch({ type: "h5code/getInfo", payload: res.data });
+    if (res.code === 0) dispatch({ type: "h5code/getInfo", payload: res.data });
   };
 };

+ 7 - 5
src/store/action/log.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 });
+    }
   };
 };

+ 13 - 11
src/store/action/login.ts

@@ -24,17 +24,19 @@ 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) => {
-      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) => {
+        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 });
+    }
   };
 };

+ 9 - 7
src/store/action/role.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 });
   };
 };
 

+ 12 - 8
src/store/action/user.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 });
+    }
   };
 };
 

+ 2 - 2
src/store/action/wall.ts

@@ -22,7 +22,7 @@ export const editWallAutoApi = (data: EditWallAutoApi) => {
 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 });
   };
 };
 
@@ -45,7 +45,7 @@ export const wallUploadAPI = (data: any) => {
   UpAsyncLodingDom.style.opacity = 1;
 
   return http.post("cms/wall/upload", data, {
-    timeout:30000,
+    timeout: 30000,
     // 显示进度条
     onUploadProgress: (e: any) => {
       const complete = (e.loaded / e.total) * 100 || 0;