From 78567a5d9a46b44f3b4160b41714627834650086 Mon Sep 17 00:00:00 2001 From: fanxb Date: Fri, 2 Aug 2019 14:31:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20[=E5=89=8D=E5=8F=B0]:?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E4=B9=A6=E7=AD=BE=E9=A1=B5=E6=98=AF=E9=87=8D?= =?UTF-8?q?=E7=BD=AEredux=E6=95=B0=E6=8D=AE=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E5=90=8E=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=B8=8A=E6=AC=A1=E7=9A=84redux=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BD=B1=E5=93=8D=E8=BF=99=E6=AC=A1=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/pages/manage/OverView/index.jsx | 49 ++++++++++++------- .../src/redux/action/BookmarkTreeOverview.js | 8 +++ .../src/redux/reducer/BookmarkTreeOverview.js | 1 + 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/front/src/pages/manage/OverView/index.jsx b/front/src/pages/manage/OverView/index.jsx index d20bbc1..64a8b6e 100644 --- a/front/src/pages/manage/OverView/index.jsx +++ b/front/src/pages/manage/OverView/index.jsx @@ -1,5 +1,5 @@ import React from "react"; -import { Tree, Empty, Button } from "antd"; +import { Tree, Empty, Button, Spin } from "antd"; import MainLayout from "../../../layout/MainLayout"; import httpUtil from "../../../util/httpUtil"; import styles from "./index.module.less"; @@ -16,6 +16,7 @@ function mapStateToProps(state) { function mapDispatchToProps(dispatch) { return { + refresh: () => dispatch(action.refresh()), updateTreeData: treeData => dispatch(action.updateTreeData(treeData)), setIsEdit: isEdit => dispatch(action.setIsEdit(isEdit)), addNode: (item, e) => dispatch(action.addNode(item, e)), @@ -29,10 +30,19 @@ function mapDispatchToProps(dispatch) { } class OverView extends React.Component { + constructor(props) { + super(props); + this.state = { + //书签树节点是否显示loading + isLoading: false + }; + } + /** * 初始化第一级书签 */ componentDidMount() { + this.props.refresh(); httpUtil .get("/bookmark/currentUser/path?path=") .then(res => { @@ -79,6 +89,7 @@ class OverView extends React.Component { render() { const { isEdit, setIsEdit, treeData, addNode, isInit, expandedKeys, checkedKeys, loadedKeys } = this.props; + const { isLoading } = this.state; const { changeExpandedKeys } = this.props; return ( @@ -107,23 +118,25 @@ class OverView extends React.Component { - - {renderTreeNodes.call(this, treeData)} - - {isInit && treeData.length === 0 ? : null} + + + {renderTreeNodes.call(this, treeData)} + + {isInit && treeData.length === 0 ? : null} + diff --git a/front/src/redux/action/BookmarkTreeOverview.js b/front/src/redux/action/BookmarkTreeOverview.js index d5ba62d..fdaf06c 100644 --- a/front/src/redux/action/BookmarkTreeOverview.js +++ b/front/src/redux/action/BookmarkTreeOverview.js @@ -21,6 +21,14 @@ export function getInitData() { }; } +export const REFRESH = "refresh"; +export const refresh = () => { + return { + type: REFRESH, + data: getInitData() + }; +}; + //定义修改modal是否显示 type export const CLOSE_MODAL = "closeModal"; diff --git a/front/src/redux/reducer/BookmarkTreeOverview.js b/front/src/redux/reducer/BookmarkTreeOverview.js index e6f7cda..c27d91c 100644 --- a/front/src/redux/reducer/BookmarkTreeOverview.js +++ b/front/src/redux/reducer/BookmarkTreeOverview.js @@ -11,6 +11,7 @@ const BookmarkTreeOverviewReducer = (state = info.getInitData(), action) => { case info.ADD_NODE: case info.EDIT_NODE: case info.CHANGE_LOADED_KEYS: + case info.REFRESH: return { ...state, ...action.data }; default: return state;