refactor:检查书签是否最新代码移动到书签管理页中

This commit is contained in:
fanxb 2020-02-02 00:53:42 +08:00
parent 1f430c3b48
commit e35433b178
6 changed files with 50 additions and 44 deletions

View File

@ -116,5 +116,10 @@ public class UserController {
return Result.success(userService.checkPassword(obj.getString("password")));
}
@GetMapping("/loginStatus")
public Result checkLoginStatus() {
return Result.success(null);
}
}

View File

@ -1,7 +1,6 @@
import React from "react";
import { Input, Select, Empty } from "antd";
import styles from "./index.module.less";
import httpUtil from "../../util/httpUtil";
import { keySearch } from "../../util/cacheUtil";
class Search extends React.Component {

View File

@ -1,13 +1,11 @@
import React from "react";
import { Link, withRouter } from "react-router-dom";
import { Menu, Dropdown, Divider, Modal } from "antd";
import { Menu, Dropdown, Divider} from "antd";
import httpUtil from "../../util/httpUtil";
import { connect } from "react-redux";
import styles from "./index.module.less";
import * as infoAction from "../../redux/action/LoginInfoAction";
import { checkCacheStatus, clearCache } from "../../util/cacheUtil";
const { confirm } = Modal;
function mapStateToProps(state) {
return state[infoAction.DATA_NAME];
@ -31,37 +29,8 @@ class MainLayout extends React.Component {
}
async componentWillMount() {
if (!this.props.username) {
let res = await httpUtil.get("/user/currentUserInfo");
this.props.changeUserInfo(res);
if (this.state.timer != null) {
clearInterval(this.state.timer);
}
await this.checkCache();
this.state.timer = setInterval(this.checkCache.bind(this), 5 * 60 * 1000);
}
}
async checkCache() {
//
if (this.state.showDialog) {
return;
}
let _this = this;
if (!(await checkCacheStatus())) {
this.state.showDialog = true;
confirm({
title: "缓存过期",
content: "书签数据有更新,是否立即刷新?",
onOk() {
_this.state.showDialog = false;
clearCache();
},
onCancel() {
_this.state.showDialog = false;
}
});
}
}
renderUserArea() {

View File

@ -124,12 +124,7 @@ class AddModal extends React.Component {
* 新增一个节点
*/
async addOne() {
const {
currentAddFolder,
updateTreeData,
closeModal,
treeData
} = this.props;
const { currentAddFolder, updateTreeData, closeModal } = this.props;
const path =
currentAddFolder == null
? ""

View File

@ -152,7 +152,7 @@ export function batchDelete() {
* @param {*} bookmarkIdList
*/
function deleteBookmark(nodeList) {
const { updateTreeData, treeData, changeCheckedKeys } = this.props;
const { updateTreeData, changeCheckedKeys } = this.props;
const folderIdList = [],
bookmarkIdList = [],
dataNodeList = [];

View File

@ -1,19 +1,23 @@
import React from "react";
import { Tree, Empty, Button, Spin } from "antd";
import { Tree, Empty, Button, Spin, Modal } from "antd";
import MainLayout from "../../../layout/MainLayout";
import styles from "./index.module.less";
import { batchDelete, renderTreeNodes, onDrop } from "./function.js";
import {
cacheBookmarkData,
getBookmarkList,
checkCacheStatus,
clearCache
} from "../../../util/cacheUtil";
import httpUtil from "../../../util/httpUtil";
import AddModal from "./AddModal";
import Search from "../../../components/Search";
import * as action from "../../../redux/action/BookmarkTreeOverview";
import { connect } from "react-redux";
const { confirm } = Modal;
function mapStateToProps(state) {
return state[action.DATA_NAME];
}
@ -44,6 +48,40 @@ class OverView extends React.Component {
};
}
async componentWillUnmount() {
if (this.state.timer != null) {
clearInterval(this.state.timer);
}
}
async componentWillMount() {
await httpUtil.get("/user/loginStatus");
this.state.timer = setInterval(this.checkCache.bind(this), 5 * 60 * 1000);
setTimeout(this.checkCache.bind(this), 5000);
}
async checkCache() {
//
if (this.state.showDialog) {
return;
}
let _this = this;
if (!(await checkCacheStatus())) {
this.state.showDialog = true;
confirm({
title: "缓存过期",
content: "书签数据有更新,是否立即刷新?",
onOk() {
_this.state.showDialog = false;
clearCache();
},
onCancel() {
_this.state.showDialog = false;
}
});
}
}
/**
* 初始化第一级书签
*/