diff --git a/front/public/img/login_bg.jpg b/front/public/img/login_bg.jpg
deleted file mode 100644
index 996657c..0000000
Binary files a/front/public/img/login_bg.jpg and /dev/null differ
diff --git a/front/src/App.jsx b/front/src/App.jsx
index c836087..c61ac68 100644
--- a/front/src/App.jsx
+++ b/front/src/App.jsx
@@ -14,6 +14,7 @@ class App extends Component {
constructor(props) {
super(props);
this.state = {};
+ window.reactHistory = this.props.history;
}
render() {
diff --git a/front/src/components/Hello/index.jsx b/front/src/components/Hello/index.jsx
deleted file mode 100644
index 0e54fdf..0000000
--- a/front/src/components/Hello/index.jsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import React, { Component } from "react";
-import { Button } from "antd";
-import styles1 from "./index.module.less";
-
-class Hello extends Component {
- render() {
- return (
-
- hello
-
world
-
-
heihei
-
- );
- }
-}
-
-export default Hello;
diff --git a/front/src/components/Hello/index.module.less b/front/src/components/Hello/index.module.less
deleted file mode 100644
index e1a652e..0000000
--- a/front/src/components/Hello/index.module.less
+++ /dev/null
@@ -1,15 +0,0 @@
-.main {
- width: 100%;
- height: 50px;
- text-align: center;
-
- .text {
- font-size: 2em;
- }
-
- :global {
- .text1 {
- color: green;
- }
- }
-}
diff --git a/front/src/global.less b/front/src/global.less
new file mode 100644
index 0000000..d817c53
--- /dev/null
+++ b/front/src/global.less
@@ -0,0 +1 @@
+@mainBgColor: #ffffff;
diff --git a/front/src/layout/LoginLayout/index.module.less b/front/src/layout/LoginLayout/index.module.less
index 150bb96..245c8a4 100644
--- a/front/src/layout/LoginLayout/index.module.less
+++ b/front/src/layout/LoginLayout/index.module.less
@@ -1,8 +1,7 @@
+@import "../../global.less";
+
.main {
- // background-image: url("/img/login_bg.jpg");
- background-color: #f1f1f1;
- background-repeat: no-repeat;
- background-size: 100% 100%;
+ background-color: @mainBgColor;
display: flex;
justify-content: center;
diff --git a/front/src/layout/MainLayout/index.jsx b/front/src/layout/MainLayout/index.jsx
index e69de29..0e1a1d9 100644
--- a/front/src/layout/MainLayout/index.jsx
+++ b/front/src/layout/MainLayout/index.jsx
@@ -0,0 +1,82 @@
+import React from "react";
+import { Link, withRouter } from "react-router-dom";
+import { Menu, Dropdown, Divider } from "antd";
+import { connect } from "react-redux";
+import styles from "./index.module.less";
+import { changeLoginInfo, DATA_NAME } from "../../redux/action/LoginInfoAction";
+
+function mapStateToProps(state) {
+ return state[DATA_NAME];
+}
+
+function mapDispatchToProps(dispatch) {
+ return {
+ updateLoginInfo: (token, userInfo) => dispatch(changeLoginInfo(token, userInfo))
+ };
+}
+
+class MainLayout extends React.Component {
+ constructor(props) {
+ super(props);
+ console.log(props);
+ this.state = {};
+ }
+
+ renderUserArea() {
+ const { userInfo } = this.props;
+ const menu = (
+
+ );
+ if (userInfo !== null) {
+ return (
+
+ {userInfo.username}
+
+ );
+ } else {
+ return (
+
+ 登陆
+ 注册
+
+ );
+ }
+ }
+
+ onClick = e => {
+ const { history } = this.props;
+ switch (e.key) {
+ case "logout":
+ this.props.updateLoginInfo(null, null);
+ localStorage.removeItem("token");
+ localStorage.removeItem("userInfo");
+ history.replace("/");
+ break;
+ default:
+ break;
+ }
+ };
+
+ render() {
+ return (
+
+
+
+ {this.renderUserArea()}
+
+
+
{this.props.children}
+
+ );
+ }
+}
+
+export default withRouter(
+ connect(
+ mapStateToProps,
+ mapDispatchToProps
+ )(MainLayout)
+);
diff --git a/front/src/layout/MainLayout/index.module.less b/front/src/layout/MainLayout/index.module.less
index e69de29..0d69fc6 100644
--- a/front/src/layout/MainLayout/index.module.less
+++ b/front/src/layout/MainLayout/index.module.less
@@ -0,0 +1,18 @@
+@import "../../global.less";
+
+.main {
+ background-color: @mainBgColor;
+ min-width: 1366px;
+
+ .header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 0.1rem 0.5rem;
+ }
+
+ .content {
+ margin: 0 10%;
+ margin-top: 0.2rem;
+ }
+}
diff --git a/front/src/pages/index.jsx b/front/src/pages/index.jsx
deleted file mode 100644
index 3ed940e..0000000
--- a/front/src/pages/index.jsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import React from "react";
-import { Button } from "antd";
-import httpUtil from "../util/httpUtil.js";
-
-class Main extends React.Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
-
- testPriviledge = () => {
- httpUtil.get("/priviledgeTest");
- };
-
- render() {
- return (
-
- );
- }
-}
-
-export default Main;
diff --git a/front/src/pages/index.module.less b/front/src/pages/index.module.less
deleted file mode 100644
index e69de29..0000000
diff --git a/front/src/pages/manage/OverView/index.jsx b/front/src/pages/manage/OverView/index.jsx
index c9f8c24..1f72b63 100644
--- a/front/src/pages/manage/OverView/index.jsx
+++ b/front/src/pages/manage/OverView/index.jsx
@@ -1,12 +1,73 @@
import React from "react";
+import { Tree, Empty, Button } from "antd";
+import MainLayout from "../../../layout/MainLayout";
+import httpUtil from "../../../util/httpUtil";
+
+const { TreeNode } = Tree;
export default class OverView extends React.Component {
constructor(props) {
super(props);
- this.state = {};
+ this.state = {
+ treeData: [],
+ isEdit: false,
+ expandKeys: ["0"]
+ };
}
+ componentDidMount() {
+ httpUtil.get("/bookmark/currentUser").then(res => {
+ const data = {
+ bookmarkId: 0,
+ userId: 0,
+ name: "我的书签",
+ children: res
+ };
+ this.setState({ treeData: [data] });
+ });
+ }
+
+ renderTreeNodes(items) {
+ return items.map(item => {
+ if (item.children && item.children.length > 0) {
+ return (
+
+ {this.renderTreeNodes(item.children)}
+
+ );
+ }
+ return ;
+ });
+ }
+
+ treeNodeSelect = e => {
+ console.log(e);
+ };
+
render() {
- return 主界面
;
+ console.log("页面刷新了");
+ const { isEdit, treeData, expandKeys } = this.state;
+ const isEmply = treeData.length === 1 && treeData[0].children && treeData[0].children.length === 0;
+ return (
+
+
+
+
+ {treeData.length ? (
+
+ {this.renderTreeNodes(treeData)}
+
+ ) : null}
+ {isEmply ? (
+
+
+
+ ) : null}
+
+ );
}
}
diff --git a/front/src/util/httpUtil.js b/front/src/util/httpUtil.js
index 0fc4575..4b3cc68 100644
--- a/front/src/util/httpUtil.js
+++ b/front/src/util/httpUtil.js
@@ -1,9 +1,6 @@
import { notification } from "antd";
-import { createBrowserHistory } from "history";
import axios from "axios";
-const history = createBrowserHistory();
-
//定义http实例
const instance = axios.create({
baseURL: "/bookmark/api",
@@ -48,10 +45,8 @@ function showError(response) {
if (response) {
description = response.message;
if (response.code === -1) {
- setTimeout(() => {
- let redirect = encodeURIComponent(window.location.pathname + window.location.search);
- history.replace("/public/login?redirect=" + redirect);
- }, 1000);
+ let redirect = encodeURIComponent(window.location.pathname + window.location.search);
+ window.reactHistory.replace("/public/login?redirect=" + redirect);
}
} else {
description = "无网络连接";