Showing
1 changed file
with
5 additions
and
6 deletions
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | import useCommon from '../hook/useCommon'; |
43 | 43 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
44 | 44 | import { getModelTsl } from '/@/api/device/modelOfMatter'; |
45 | - import { useClipboard } from '@vueuse/core'; | |
45 | + import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; | |
46 | 46 | |
47 | 47 | const props = defineProps<{ |
48 | 48 | record: DeviceRecord; |
... | ... | @@ -58,17 +58,16 @@ |
58 | 58 | |
59 | 59 | const activeKey = ref(FunctionType.PROPERTIES); |
60 | 60 | |
61 | - const { copy, isSupported } = useClipboard({ source: jsonValue }); | |
61 | + const { clipboardRef, isSuccessRef } = useCopyToClipboard(jsonValue.value); | |
62 | 62 | const handleCopy = () => { |
63 | 63 | try { |
64 | 64 | if (!jsonValue.value) { |
65 | 65 | createMessage.warning('请输入要拷贝的内容!'); |
66 | 66 | return; |
67 | 67 | } |
68 | - if (unref(isSupported)) { | |
69 | - copy(); | |
70 | - createMessage.success('复制成功!'); | |
71 | - } | |
68 | + clipboardRef.value = jsonValue.value; | |
69 | + if (unref(isSuccessRef)) createMessage.success('复制成功!'); | |
70 | + else createMessage.error('复制失败!'); | |
72 | 71 | } catch (e) { |
73 | 72 | console.log(e); |
74 | 73 | } | ... | ... |