diff --git a/src/pages/Article/index.tsx b/src/pages/Article/index.tsx index 67b5c45..14630e7 100644 --- a/src/pages/Article/index.tsx +++ b/src/pages/Article/index.tsx @@ -27,6 +27,8 @@ export default () => { const { RangePicker } = DatePicker; const getArticleList = async () => { + setLoading(true); + try { const { data } = await getArticleListAPI(); setArticleList(data); @@ -34,8 +36,6 @@ export default () => { } catch (error) { setLoading(false); } - - setLoading(false); }; const delArticleData = async (id: number) => { @@ -166,11 +166,10 @@ export default () => { const { data } = await getArticleListAPI({ query }); setArticleList(data); + setLoading(false) } catch (error) { setLoading(false) } - - setLoading(false) } const [cateList, setCateList] = useState([]) @@ -187,7 +186,6 @@ export default () => { } useEffect(() => { - setLoading(true); getArticleList() getCateList() getTagList() diff --git a/src/pages/Cate/index.tsx b/src/pages/Cate/index.tsx index 69c1393..6c3d5af 100644 --- a/src/pages/Cate/index.tsx +++ b/src/pages/Cate/index.tsx @@ -19,17 +19,16 @@ const CatePage = () => { const [form] = Form.useForm(); const getCateList = async () => { - setLoading(true) - try { + setLoading(true) + const { data } = await getCateListAPI(); data.sort((a, b) => a.order - b.order) setList(data); + setLoading(false) } catch (error) { setLoading(false) } - - setLoading(false) }; useEffect(() => { @@ -46,20 +45,19 @@ const CatePage = () => { }; const editCateData = async (id: number) => { - setIsMethod("edit"); - setIsModelOpen(true); - setEditLoading(true) - try { + setIsMethod("edit"); + setIsModelOpen(true); + setEditLoading(true) + const { data } = await getCateDataAPI(id); setIsCateShow(data.type === "cate" ? false : true); setCate(data); form.setFieldsValue(data); + setEditLoading(false) } catch (error) { setEditLoading(false) } - - setEditLoading(false) }; const delCateData = async (id: number) => { @@ -67,8 +65,8 @@ const CatePage = () => { try { await delCateDataAPI(id); - message.success('🎉 删除分类成功'); await getCateList(); + message.success('🎉 删除分类成功'); } catch (error) { setLoading(false) } @@ -98,11 +96,11 @@ const CatePage = () => { setIsModelOpen(false); setIsMethod("create") }) + + setBtnLoading(false) } catch (error) { setBtnLoading(false) } - - setBtnLoading(false) }; const closeModel = () => { diff --git a/src/pages/Oss/index.tsx b/src/pages/Oss/index.tsx index 3ebb84d..cf5d881 100644 --- a/src/pages/Oss/index.tsx +++ b/src/pages/Oss/index.tsx @@ -102,6 +102,8 @@ export default () => { }, []); const enableOssData = async (id: number) => { + setLoading(true) + try { await enableOssDataAPI(id); await getOssList(); @@ -112,6 +114,8 @@ export default () => { }; const disableOssData = async (id: number) => { + setLoading(true) + try { await disableOssDataAPI(id); await getOssList();