// +----------------------------------------------------------------------
|
// | CMS [ CMS赋能开发者,助力企业发展 ]
|
// +----------------------------------------------------------------------
|
// | Copyright (c) 2016~2021 https://www.CMS.com All rights reserved.
|
// +----------------------------------------------------------------------
|
// | Licensed CMS并不是自由软件,未经许可不能去掉CMS相关版权
|
// +----------------------------------------------------------------------
|
// | Author: CMS Team <admin@CMS.com>
|
// +----------------------------------------------------------------------
|
|
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.destroy()
|
})
|
clipboard.on('error', () => {
|
clipboardError()
|
clipboard.destroy()
|
})
|
clipboard.onClick(event)
|
}
|