fix:修复部分情况下数据不同步问题
This commit is contained in:
parent
8a82006a0b
commit
b7c8fdc40a
@ -4,7 +4,7 @@ import httpUtil from "../../../util/httpUtil";
|
|||||||
|
|
||||||
import * as action from "../../../redux/action/BookmarkTreeOverview";
|
import * as action from "../../../redux/action/BookmarkTreeOverview";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { addNode } from "../../../util/cacheUtil";
|
import { addNode, getBookmarkList } from "../../../util/cacheUtil";
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return state[action.DATA_NAME];
|
return state[action.DATA_NAME];
|
||||||
@ -173,7 +173,7 @@ class AddModal extends React.Component {
|
|||||||
if (!currentAddFolder) {
|
if (!currentAddFolder) {
|
||||||
treeData.push(res);
|
treeData.push(res);
|
||||||
}
|
}
|
||||||
updateTreeData(treeData);
|
updateTreeData([...getBookmarkList("")]);
|
||||||
closeModal();
|
closeModal();
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { Modal, Button, Tree, message, Menu, Dropdown } from "antd";
|
|||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import IconFont from "../../../components/IconFont";
|
import IconFont from "../../../components/IconFont";
|
||||||
import { stopTransfer } from "../../../util/eventUtil";
|
import { stopTransfer } from "../../../util/eventUtil";
|
||||||
import { deleteNodes, moveNode } from "../../../util/cacheUtil";
|
import { deleteNodes, moveNode, getBookmarkList } from "../../../util/cacheUtil";
|
||||||
const { TreeNode } = Tree;
|
const { TreeNode } = Tree;
|
||||||
|
|
||||||
function menuVisible(item, visible) {
|
function menuVisible(item, visible) {
|
||||||
@ -175,7 +175,7 @@ function deleteBookmark(nodeList) {
|
|||||||
treeData.splice(treeData.indexOf(item), 1);
|
treeData.splice(treeData.indexOf(item), 1);
|
||||||
});
|
});
|
||||||
changeCheckedKeys([], null);
|
changeCheckedKeys([], null);
|
||||||
updateTreeData([...treeData]);
|
updateTreeData([...getBookmarkList("")]);
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(() => reject());
|
.catch(() => reject());
|
||||||
@ -207,7 +207,7 @@ export async function onDrop(info) {
|
|||||||
.post("/bookmark/moveNode", body)
|
.post("/bookmark/moveNode", body)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
message.success("移动完成");
|
message.success("移动完成");
|
||||||
updateTreeData([...treeData]);
|
updateTreeData([...getBookmarkList("")]);
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
@ -50,7 +50,7 @@ class OverView extends React.Component {
|
|||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
this.props.refresh();
|
this.props.refresh();
|
||||||
await cacheBookmarkData();
|
await cacheBookmarkData();
|
||||||
this.props.updateTreeData([...getBookmarkList("")]);
|
this.props.updateTreeData(getBookmarkList(""));
|
||||||
this.props.changeIsInit(true);
|
this.props.changeIsInit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,12 +58,12 @@ class OverView extends React.Component {
|
|||||||
* 异步加载
|
* 异步加载
|
||||||
*/
|
*/
|
||||||
loadData = e => {
|
loadData = e => {
|
||||||
const { loadedKeys, treeData } = this.props;
|
const { loadedKeys } = this.props;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const item = e.props.dataRef;
|
const item = e.props.dataRef;
|
||||||
const newPath = item.path + "." + item.bookmarkId;
|
const newPath = item.path + "." + item.bookmarkId;
|
||||||
item.children = getBookmarkList(newPath);
|
item.children = getBookmarkList(newPath);
|
||||||
this.props.updateTreeData([...treeData]);
|
this.props.updateTreeData([...getBookmarkList("")]);
|
||||||
loadedKeys.push(item.bookmarkId.toString());
|
loadedKeys.push(item.bookmarkId.toString());
|
||||||
this.props.changeLoadedKeys(loadedKeys);
|
this.props.changeLoadedKeys(loadedKeys);
|
||||||
resolve();
|
resolve();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user