Browse Source

异步回跳登录页报错问题

shaogen1995 2 years ago
parent
commit
abd9cf2868

+ 6 - 5
houtai/src/store/action/A2News.ts

@@ -41,11 +41,12 @@ export const newSaveAPI = (data: NewsSaveApiType) => {
 export const getNewsListAPI = (data: NewsTableApiType) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("cms/news/getList", data);
-
-    dispatch({
-      type: "news/getList",
-      payload: res.data,
-    });
+    if (res.code === 0) {
+      dispatch({
+        type: "news/getList",
+        payload: res.data,
+      });
+    }
   };
 };
 

+ 6 - 4
houtai/src/store/action/A3Goods.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 },
+      });
+    }
   };
 };
 

+ 10 - 8
houtai/src/store/action/A4Venue.ts

@@ -34,30 +34,32 @@ export const venueUploadAPI = (data: any) => {
 export const getVenueListAPI = (data: VenueTableApiType) => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post("cms/exhibition/getList", data);
-    dispatch({
-      type: "venue/getList",
-      payload: res.data,
-    });
+    if (res.code === 0) {
+      dispatch({
+        type: "venue/getList",
+        payload: res.data,
+      });
+    }
   };
 };
 
 /**
  * 详情
  */
-export const getVenueDetailAPI = (id:number) => {
+export const getVenueDetailAPI = (id: number) => {
   return http.get(`cms/exhibition/detail/${id}`);
 };
 
 /**
  * 拖动排序
  */
-export const venueSortApi = (id1:number,id2:number) => {
+export const venueSortApi = (id1: number, id2: number) => {
   return http.get(`cms/exhibition/sort/${id1}/${id2}`);
 };
 
 /**
  * 新增|编辑
  */
-export const setVenueSaveApi = (data:VenueTableType) => {
-  return http.post('cms/exhibition/save',data);
+export const setVenueSaveApi = (data: VenueTableType) => {
+  return http.post("cms/exhibition/save", data);
 };

+ 12 - 10
houtai/src/store/action/layout.ts

@@ -22,16 +22,18 @@ 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" }],
-    } as DictListTypeObj;
-    list.forEach((v) => {
-      if (obj[v.type])
-        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" }],
+      } as DictListTypeObj;
+      list.forEach((v) => {
+        if (obj[v.type])
+          obj[v.type].push({ label: v.name, value: v.name, type: v.type });
+      });
 
-    dispatch({ type: "layout/getDictList", payload: obj });
+      dispatch({ type: "layout/getDictList", payload: obj });
+    }
   };
 };