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 ? ( + +