From aaf28a42c2a2fda28c9a9567ea0eb5403337242c Mon Sep 17 00:00:00 2001 From: Soybean Date: Tue, 7 May 2024 18:20:23 +0800 Subject: [PATCH] optimize(projects): optimize plugin_copy --- src/router/elegant/routes.ts | 4 ++-- src/views/plugin/copy/index.vue | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/router/elegant/routes.ts b/src/router/elegant/routes.ts index 406b48ce..e3c0ca2c 100644 --- a/src/router/elegant/routes.ts +++ b/src/router/elegant/routes.ts @@ -338,7 +338,7 @@ export const generatedRoutes: GeneratedRoute[] = [ title: '插件示例', i18nKey: 'route.plugin', order: 7, - icon: 'clarity:plugin-line', + icon: 'clarity:plugin-line' }, children: [ { @@ -348,7 +348,7 @@ export const generatedRoutes: GeneratedRoute[] = [ meta: { title: '剪贴板', icon: 'mdi:clipboard-outline', - i18nKey: 'route.plugin_copy', + i18nKey: 'route.plugin_copy' } } ] diff --git a/src/views/plugin/copy/index.vue b/src/views/plugin/copy/index.vue index 2c2cbaf2..bb744c68 100644 --- a/src/views/plugin/copy/index.vue +++ b/src/views/plugin/copy/index.vue @@ -2,26 +2,29 @@ import { ref } from 'vue'; import { useClipboard } from '@vueuse/core'; -const source = ref(''); const { copy, isSupported } = useClipboard(); -function handleCopy() { +const source = ref(''); + +async function handleCopy() { if (!isSupported) { window.$message?.error('您的浏览器不支持Clipboard API'); return; } + if (!source.value) { window.$message?.error('请输入要复制的内容'); return; } - copy(source.value); + + await copy(source.value); window.$message?.success(`复制成功:${source.value}`); }