diff --git a/admin/src/install/directives/copy.ts b/admin/src/install/directives/copy.ts new file mode 100644 index 00000000..c0b1909c --- /dev/null +++ b/admin/src/install/directives/copy.ts @@ -0,0 +1,28 @@ +/** + * perm 操作权限处理 + * 指令用法: + * 编辑 + */ + +import feedback from '@/utils/feedback' +import useClipboard from 'vue-clipboard3' +const clipboard = 'data-clipboard-text' +export default { + mounted: (el: HTMLElement, binding: any) => { + el.setAttribute(clipboard, binding.value) + const { toClipboard } = useClipboard() + + el.onclick = () => { + toClipboard(el.getAttribute(clipboard)!) + .then(() => { + feedback.msgSuccess('复制成功') + }) + .catch(() => { + feedback.msgError('复制失败') + }) + } + }, + updated: (el: HTMLElement, binding: any) => { + el.setAttribute(clipboard, binding.value) + } +} diff --git a/admin/src/views/channel/h5.vue b/admin/src/views/channel/h5.vue index a98d45f5..efbdfe47 100644 --- a/admin/src/views/channel/h5.vue +++ b/admin/src/views/channel/h5.vue @@ -27,7 +27,7 @@ {{ formData.accessLink }} - 复制 + 复制 @@ -39,7 +39,6 @@