diff --git a/package.json b/package.json index 8b7f26b..b1e85f2 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "antd": "^4.3.1", "axios": "^0.19.2", "camelcase": "^5.3.1", + "copy-to-clipboard": "^3.3.1", "dotenv": "8.2.0", "dotenv-expand": "5.1.0", "fs-extra": "^8.1.0", diff --git a/src/pages/matter/List.tsx b/src/pages/matter/List.tsx index 2f7c652..c0b952c 100644 --- a/src/pages/matter/List.tsx +++ b/src/pages/matter/List.tsx @@ -77,6 +77,7 @@ export default class List extends TankComponent { director={director} matter={matter} onCreateDirectorySuccess={this.refresh.bind(this)} + onDeleteSuccess={this.refresh.bind(this)} /> )} diff --git a/src/pages/matter/widget/MatterPanel.tsx b/src/pages/matter/widget/MatterPanel.tsx index a118759..018e73c 100644 --- a/src/pages/matter/widget/MatterPanel.tsx +++ b/src/pages/matter/widget/MatterPanel.tsx @@ -1,4 +1,5 @@ import React from "react"; +import copy from 'copy-to-clipboard'; import Matter from "../../../common/model/matter/Matter"; import TankComponent from "../../../common/component/TankComponent"; import Director from "./Director"; @@ -7,6 +8,7 @@ import Sun from "../../../common/model/global/Sun"; import StringUtil from "../../../common/util/StringUtil"; import DateUtil from "../../../common/util/DateUtil"; import AnimateUtil from "../../../common/util/AnimateUtil"; +import MessageBoxUtil from "../../../common/util/MessageBoxUtil"; import { LockFilled, UnlockFilled, @@ -15,14 +17,16 @@ import { EditFilled, DownloadOutlined, DeleteFilled, + InfoCircleTwoTone, } from "@ant-design/icons"; -import { Input, message } from 'antd'; +import { Modal } from 'antd'; import SafeUtil from "../../../common/util/SafeUtil"; interface IProps { matter: Matter; director: Director; - onCreateDirectorySuccess?: () => any + onCreateDirectorySuccess?: () => any, + onDeleteSuccess?: () => any } interface IState {} @@ -55,7 +59,6 @@ export default class MatterPanel extends TankComponent { this.updateUI(); setTimeout(() => { if (!this.inputRef.current) return; - console.log(this.inputRef.current); //如果是文件夹,全选中 let dotIndex = matter.name!.lastIndexOf("."); if (dotIndex === -1) { @@ -70,9 +73,24 @@ export default class MatterPanel extends TankComponent { }); }; - clipboard = () => {}; + clipboard = () => { + let textToCopy = this.props.matter.getDownloadUrl(); + copy(textToCopy); + MessageBoxUtil.success('操作成功'); + }; - deleteMatter = () => {}; + deleteMatter = () => { + Modal.confirm({ + title: '此操作不可撤回, 是否继续?', + icon: , + onOk: () => { + this.props.matter.httpDelete(() => { + MessageBoxUtil.success('操作成功'); + this.props.onDeleteSuccess!(); + }) + } + }); + }; changeMatterName = (e: any) => { this.renameMatterName = e.currentTarget.value; @@ -89,13 +107,13 @@ export default class MatterPanel extends TankComponent { matter.httpRename(this.renameMatterName, () => { this.renamingLoading = false; - message.success('操作成功'); + MessageBoxUtil.success('操作成功'); //告诉导演,自己编辑完毕 director.renameMode = false; matter.editMode = false },(msg:string) => { this.renamingLoading = false; - message.error(msg); + MessageBoxUtil.error(msg); //告诉导演,自己编辑完毕 director.renameMode = false; matter.editMode = false; @@ -113,7 +131,7 @@ export default class MatterPanel extends TankComponent { }, (msg: string) => { director.createMode = false; matter.editMode = false; - message.error(msg) + MessageBoxUtil.error(msg) }, () => this.updateUI()); };