From 185a95348f03d3ae0fd69c380a2fc17315621650 Mon Sep 17 00:00:00 2001 From: fanxb Date: Fri, 26 Jul 2019 11:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Perf:=20[=E5=89=8D=E5=8F=B0]:?= =?UTF-8?q?=E9=87=8D=E5=86=99=E8=8A=82=E7=82=B9=E6=93=8D=E4=BD=9C=E8=8F=9C?= =?UTF-8?q?=E5=8D=95,pc=E7=AB=AF=E9=82=AE=E4=BB=B6=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E5=8A=A8=E7=AB=AF=E7=82=B9=E5=87=BB=E7=BC=96?= =?UTF-8?q?=E8=BE=91/=E8=8F=9C=E5=8D=95=E6=8C=89=E9=92=AE=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/App.jsx | 8 +- front/src/pages/manage/OverView/function.js | 86 ++++++++++++------- front/src/pages/manage/OverView/index.jsx | 8 +- .../pages/manage/OverView/index.module.less | 1 + .../src/redux/action/BookmarkTreeOverview.js | 20 +++-- .../src/redux/reducer/BookmarkTreeOverview.js | 1 + 6 files changed, 81 insertions(+), 43 deletions(-) diff --git a/front/src/App.jsx b/front/src/App.jsx index df81037..9f5f561 100644 --- a/front/src/App.jsx +++ b/front/src/App.jsx @@ -3,7 +3,7 @@ import { Route, Switch, Redirect } from "react-router-dom"; import { message } from "antd"; import { withRouter } from "react-router-dom"; import { Provider } from "react-redux"; -import Clipboard from "clipboard"; +import ClipboardJS from "clipboard"; import store from "./redux"; import NotFound from "./pages/public/notFound/NotFound"; @@ -21,7 +21,11 @@ class App extends Component { componentDidMount() { //初始化clipboard - let clipboard = new Clipboard(".copy-to-board"); + let clipboard = new ClipboardJS(".copy-to-board", { + text: function(trigger) { + return window.copyUrl; + } + }); clipboard.on("success", function(e) { message.success("复制成功"); e.clearSelection(); diff --git a/front/src/pages/manage/OverView/function.js b/front/src/pages/manage/OverView/function.js index 4400391..ed9da35 100644 --- a/front/src/pages/manage/OverView/function.js +++ b/front/src/pages/manage/OverView/function.js @@ -1,46 +1,75 @@ import httpUtil from "../../../util/httpUtil"; import React from "react"; -import { Modal, Button, Tree, message } from "antd"; +import { Modal, Button, Tree, message, Menu, Dropdown } from "antd"; import styles from "./index.module.less"; import IconFont from "../../../components/IconFont"; +import { stopTransfer } from "../../../util/eventUtil"; const { TreeNode } = Tree; +function menuVisible(item, visible) { + if (visible) { + window.copyUrl = item.url; + } + this.props.changeCurrentClickItem(item); +} + +function menuClick(e) { + stopTransfer(e); + const { currentClickItem, addNode, editNode } = this.props; + switch (e.key) { + case "add": + addNode(currentClickItem); + break; + case "edit": + editNode(currentClickItem); + break; + case "delete": + deleteOne.call(this, currentClickItem); + break; + default: + break; + } +} + /** * 渲染树节点中节点内容 * @param {*} item */ export function renderNodeContent(item) { - const { isEdit, addNode, editNode } = this.props; + const { isEdit } = this.props; // 节点内容后面的操作按钮 - const btns = ( -
+ const menu = ( + {item.type === 0 ? ( -
+ + 复制URL + + ) : ( + + 新增 + + )} + 编辑 + 删除 + ); return ( - {item.type === 0 ? ( - - {item.name} - - ) : ( - {item.name} - )} - {isEdit ? btns : null} + {/* 触发右键菜单 */} + + {item.type === 0 ? ( + + {item.name} + + ) : ( + {item.name} + )} + + {isEdit ? ( + +