Преглед изворни кода

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

shaogen1995 пре 2 година
родитељ
комит
ca00c790d3

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

@@ -152,7 +152,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 - 5
src/store/action/exhibit.ts

@@ -7,9 +7,10 @@ import { AppDispatch } from "..";
 export const getExhibitListAPI = () => {
   return async (dispatch: AppDispatch) => {
     const res = await http.get("cms/exhibition/getList");
-    const list: ExhibitTableType[] = res.data;
-
-    dispatch({ type: "exhibit/getList", payload: list });
+    if (res.code === 0) {
+      const list: ExhibitTableType[] = res.data;
+      dispatch({ type: "exhibit/getList", payload: list });
+    }
   };
 };
 
@@ -31,7 +32,7 @@ export const exhibitUploadAPI = (data: any) => {
   UpAsyncLodingDom.style.opacity = 1;
 
   return http.post("cms/exhibition/upload", data, {
-    timeout:30000,
+    timeout: 30000,
     // 显示进度条
     onUploadProgress: (e: any) => {
       const complete = (e.loaded / e.total) * 100 || 0;
@@ -44,5 +45,5 @@ export const exhibitUploadAPI = (data: any) => {
  * 编辑展馆
  */
 export const exhibitionSaveAPI = (data: ExhibitTableType) => {
-  return http.post("cms/exhibition/save",data);
+  return http.post("cms/exhibition/save", data);
 };

+ 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;

+ 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 });
+    }
   };
 };

+ 7 - 6
src/store/action/user.ts

@@ -7,16 +7,17 @@ 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 });
+    }
   };
 };
 
-
 /**
  * 用户-是否显示
  */