fix:修复文件导入时数据不同步问题
This commit is contained in:
parent
b7c8fdc40a
commit
90957f2864
@ -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, getBookmarkList } from "../../../util/cacheUtil";
|
import { addNode, getBookmarkList, clearCache } from "../../../util/cacheUtil";
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return state[action.DATA_NAME];
|
return state[action.DATA_NAME];
|
||||||
@ -148,8 +148,9 @@ class AddModal extends React.Component {
|
|||||||
.put("/bookmark/uploadBookmarkFile", form, {
|
.put("/bookmark/uploadBookmarkFile", form, {
|
||||||
headers: { "Content-Type": "multipart/form-data" }
|
headers: { "Content-Type": "multipart/form-data" }
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(async res => {
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
|
await clearCache();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
.catch(res => this.setState({ isLoading: false }));
|
.catch(res => this.setState({ isLoading: false }));
|
||||||
|
@ -4,7 +4,12 @@ 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, getBookmarkList } from "../../../util/cacheUtil";
|
import {
|
||||||
|
deleteNodes,
|
||||||
|
moveNode,
|
||||||
|
getBookmarkList,
|
||||||
|
updateCurrentChangeTime
|
||||||
|
} from "../../../util/cacheUtil";
|
||||||
const { TreeNode } = Tree;
|
const { TreeNode } = Tree;
|
||||||
|
|
||||||
function menuVisible(item, visible) {
|
function menuVisible(item, visible) {
|
||||||
@ -189,7 +194,7 @@ function deleteBookmark(nodeList) {
|
|||||||
* @param {*} info
|
* @param {*} info
|
||||||
*/
|
*/
|
||||||
export async function onDrop(info) {
|
export async function onDrop(info) {
|
||||||
const { treeData, updateTreeData, loadedKeys, changeLoadedKeys } = this.props;
|
const { updateTreeData, loadedKeys, changeLoadedKeys } = this.props;
|
||||||
const target = info.node.props.dataRef;
|
const target = info.node.props.dataRef;
|
||||||
if (!info.dropToGap && target.type === 0) {
|
if (!info.dropToGap && target.type === 0) {
|
||||||
message.error("无法移动到书签内部");
|
message.error("无法移动到书签内部");
|
||||||
@ -203,16 +208,15 @@ export async function onDrop(info) {
|
|||||||
loadedKeys.splice(index, 1);
|
loadedKeys.splice(index, 1);
|
||||||
changeLoadedKeys(loadedKeys);
|
changeLoadedKeys(loadedKeys);
|
||||||
}
|
}
|
||||||
httpUtil
|
try {
|
||||||
.post("/bookmark/moveNode", body)
|
await httpUtil.post("/bookmark/moveNode", body);
|
||||||
.then(res => {
|
|
||||||
message.success("移动完成");
|
message.success("移动完成");
|
||||||
updateTreeData([...getBookmarkList("")]);
|
updateTreeData([...getBookmarkList("")]);
|
||||||
this.setState({ isLoading: false });
|
} catch (error) {
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.setState({ isLoading: false });
|
|
||||||
message.error("后台移动失败,将于2s后刷新页面,以免前后台数据不一致");
|
message.error("后台移动失败,将于2s后刷新页面,以免前后台数据不一致");
|
||||||
setTimeout(window.location.reload, 2000);
|
setTimeout(window.location.reload, 2000);
|
||||||
});
|
} finally {
|
||||||
|
this.setState({ isLoading: false });
|
||||||
|
}
|
||||||
|
await updateCurrentChangeTime();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user