Commit ae9cf105b8c17a153133f84c9542e4d75746d50f

Authored by ww
1 parent 69534aed

fix: 修复物模型TSL复制功能失效

@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 import useCommon from '../hook/useCommon'; 42 import useCommon from '../hook/useCommon';
43 import { DeviceRecord } from '/@/api/device/model/deviceModel'; 43 import { DeviceRecord } from '/@/api/device/model/deviceModel';
44 import { getModelTsl } from '/@/api/device/modelOfMatter'; 44 import { getModelTsl } from '/@/api/device/modelOfMatter';
45 - import { useClipboard } from '@vueuse/core'; 45 + import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
46 46
47 const props = defineProps<{ 47 const props = defineProps<{
48 record: DeviceRecord; 48 record: DeviceRecord;
@@ -58,17 +58,16 @@ @@ -58,17 +58,16 @@
58 58
59 const activeKey = ref(FunctionType.PROPERTIES); 59 const activeKey = ref(FunctionType.PROPERTIES);
60 60
61 - const { copy, isSupported } = useClipboard({ source: jsonValue }); 61 + const { clipboardRef, isSuccessRef } = useCopyToClipboard(jsonValue.value);
62 const handleCopy = () => { 62 const handleCopy = () => {
63 try { 63 try {
64 if (!jsonValue.value) { 64 if (!jsonValue.value) {
65 createMessage.warning('请输入要拷贝的内容!'); 65 createMessage.warning('请输入要拷贝的内容!');
66 return; 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 } catch (e) { 71 } catch (e) {
73 console.log(e); 72 console.log(e);
74 } 73 }