diff options
| author | unknown <[email protected]> | 2022-06-24 17:11:23 +0800 |
|---|---|---|
| committer | unknown <[email protected]> | 2022-06-24 17:11:23 +0800 |
| commit | 8565e1bb597b481447d33bac6d8c48c2c45215de (patch) | |
| tree | a4f10c8f7f85a1a8b5c947f7d0d2f967d808a9c4 /UI source code/dns_mapping_ui-master/src/utils/clipboard.js | |
| parent | 8165dfcc7bdb0b2e6f1c05f8e7c93553c0e7911e (diff) | |
Diffstat (limited to 'UI source code/dns_mapping_ui-master/src/utils/clipboard.js')
| -rw-r--r-- | UI source code/dns_mapping_ui-master/src/utils/clipboard.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/UI source code/dns_mapping_ui-master/src/utils/clipboard.js b/UI source code/dns_mapping_ui-master/src/utils/clipboard.js new file mode 100644 index 0000000..e916a44 --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/utils/clipboard.js @@ -0,0 +1,36 @@ +import Vue from 'vue' +import Clipboard from 'clipboard' + +function clipboardSuccess() { + Vue.prototype.$message({ + message: 'Copy successfully', + type: 'success', + duration: 1500 + }) +} + +function clipboardError() { + Vue.prototype.$message({ + message: 'Copy failed', + type: 'error' + }) +} + +export default function handleClipboard(text, event) { + const clipboard = new Clipboard(event.target, { + text: () => text + }) + clipboard.on('success', () => { + clipboardSuccess() + clipboard.off('error') + clipboard.off('success') + clipboard.destroy() + }) + clipboard.on('error', () => { + clipboardError() + clipboard.off('error') + clipboard.off('success') + clipboard.destroy() + }) + clipboard.onClick(event) +} |
