Commit a0931ab7532aaba621bb472953034be3ae47a969

Authored by xp.Huang
2 parents a078fae6 c18c6144

Merge branch 'fix/DEFECT-1384' into 'main_dev'

修复复制粘贴问题

See merge request yunteng/thingskit-front!686
@@ -29,7 +29,8 @@ @@ -29,7 +29,8 @@
29 import { useDesign } from '/@/hooks/web/useDesign'; 29 import { useDesign } from '/@/hooks/web/useDesign';
30 import { useI18n } from '/@/hooks/web/useI18n'; 30 import { useI18n } from '/@/hooks/web/useI18n';
31 import { useMessage } from '/@/hooks/web/useMessage'; 31 import { useMessage } from '/@/hooks/web/useMessage';
32 - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 32 +
  33 + import { useClipboard } from '@vueuse/core';
33 34
34 import { updateColorWeak } from '/@/logics/theme/updateColorWeak'; 35 import { updateColorWeak } from '/@/logics/theme/updateColorWeak';
35 import { updateGrayMode } from '/@/logics/theme/updateGrayMode'; 36 import { updateGrayMode } from '/@/logics/theme/updateGrayMode';
@@ -47,11 +48,10 @@ @@ -47,11 +48,10 @@
47 const userStore = useUserStore(); 48 const userStore = useUserStore();
48 const appStore = useAppStore(); 49 const appStore = useAppStore();
49 50
50 - function handleCopy() {  
51 - const { isSuccessRef } = useCopyToClipboard(  
52 - JSON.stringify(unref(appStore.getProjectConfig), null, 2)  
53 - );  
54 - unref(isSuccessRef) && 51 + async function handleCopy() {
  52 + const { copied, copy } = useClipboard({ legacy: true });
  53 + copy(JSON.stringify(unref(appStore.getProjectConfig), null, 2));
  54 + unref(copied) &&
55 createSuccessModal({ 55 createSuccessModal({
56 title: t('layout.setting.operatingTitle'), 56 title: t('layout.setting.operatingTitle'),
57 content: t('layout.setting.operatingContent'), 57 content: t('layout.setting.operatingContent'),
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 import { ref, unref } from 'vue'; 7 import { ref, unref } from 'vue';
8 import { nextTick } from 'vue'; 8 import { nextTick } from 'vue';
9 import { ModalParamsType } from '/#/utils'; 9 import { ModalParamsType } from '/#/utils';
10 - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 10 + import { useClipboard } from '@vueuse/core';
11 import { useMessage } from '/@/hooks/web/useMessage'; 11 import { useMessage } from '/@/hooks/web/useMessage';
12 import { computed } from 'vue'; 12 import { computed } from 'vue';
13 13
@@ -64,10 +64,10 @@ @@ -64,10 +64,10 @@
64 return unref(record).viewType === ViewTypeEnum.PUBLIC_VIEW; 64 return unref(record).viewType === ViewTypeEnum.PUBLIC_VIEW;
65 }); 65 });
66 66
67 - const { clipboardRef, isSuccessRef } = useCopyToClipboard();  
68 - const handleCopy = () => {  
69 - clipboardRef.value = unref(link);  
70 - if (unref(isSuccessRef)) { 67 + const { copied, copy } = useClipboard({ legacy: true });
  68 + const handleCopy = async () => {
  69 + await copy(unref(link));
  70 + if (unref(copied)) {
71 createMessage.success('复制成功~'); 71 createMessage.success('复制成功~');
72 } 72 }
73 }; 73 };
@@ -74,7 +74,6 @@ @@ -74,7 +74,6 @@
74 import { Empty, Image, Tooltip } from 'ant-design-vue'; 74 import { Empty, Image, Tooltip } from 'ant-design-vue';
75 import { descSchema } from '../../config/detail.config'; 75 import { descSchema } from '../../config/detail.config';
76 import { useAsyncScript } from '/@/hooks/web/useAsyncScript'; 76 import { useAsyncScript } from '/@/hooks/web/useAsyncScript';
77 - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';  
78 import { useMessage } from '/@/hooks/web/useMessage'; 77 import { useMessage } from '/@/hooks/web/useMessage';
79 import { BAI_DU_MAP_URL } from '/@/utils/fnUtils'; 78 import { BAI_DU_MAP_URL } from '/@/utils/fnUtils';
80 import { BasicModal, useModal } from '/@/components/Modal'; 79 import { BasicModal, useModal } from '/@/components/Modal';
@@ -84,6 +83,7 @@ @@ -84,6 +83,7 @@
84 import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 83 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
85 import { DeviceTypeEnum } from '/@/api/device/model/deviceModel'; 84 import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
86 import { useAuthDeviceDetail } from '../../hook/useAuthDeviceDetail'; 85 import { useAuthDeviceDetail } from '../../hook/useAuthDeviceDetail';
  86 + import { useClipboard } from '@vueuse/core';
87 87
88 import wz from '/@/assets/images/wz.png'; 88 import wz from '/@/assets/images/wz.png';
89 import { useAsyncQueue } from '../../../localtion/useAsyncQueue'; 89 import { useAsyncQueue } from '../../../localtion/useAsyncQueue';
@@ -165,33 +165,35 @@ @@ -165,33 +165,35 @@
165 } 165 }
166 166
167 const { createMessage } = useMessage(); 167 const { createMessage } = useMessage();
168 - const { clipboardRef } = useCopyToClipboard();  
169 - const copyTbDeviceId = () => {  
170 - clipboardRef.value = props.deviceDetail.tbDeviceId;  
171 - if (unref(clipboardRef)) { 168 + const { copied, copy } = useClipboard({ legacy: true });
  169 +
  170 + const copyTbDeviceId = async () => {
  171 + await copy(props.deviceDetail.tbDeviceId);
  172 + if (unref(copied)) {
172 createMessage.success('复制成功~'); 173 createMessage.success('复制成功~');
173 } 174 }
174 }; 175 };
175 const copyDeviceToken = async () => { 176 const copyDeviceToken = async () => {
176 const token = await getDeviceToken(props.deviceDetail.tbDeviceId); 177 const token = await getDeviceToken(props.deviceDetail.tbDeviceId);
177 if (token.credentialsType === 'ACCESS_TOKEN') { 178 if (token.credentialsType === 'ACCESS_TOKEN') {
178 - clipboardRef.value = token.credentialsId; 179 + await copy(token.credentialsId);
179 } else { 180 } else {
180 - clipboardRef.value = token.credentialsValue; 181 + await copy(token.credentialsValue);
  182 + }
  183 + if (unref(copied)) {
  184 + createMessage.success('复制成功~');
181 } 185 }
182 - createMessage.success('复制成功~');  
183 }; 186 };
184 const [registerModal, { openModal }] = useModal(); 187 const [registerModal, { openModal }] = useModal();
185 const manageDeviceToken = async () => { 188 const manageDeviceToken = async () => {
186 const token = await getDeviceToken(props.deviceDetail.tbDeviceId); 189 const token = await getDeviceToken(props.deviceDetail.tbDeviceId);
187 openModal(true, token); 190 openModal(true, token);
188 }; 191 };
189 - const copyTopic = (val) => {  
190 - const { isSuccessRef } = useCopyToClipboard(  
191 - JSON.parse(JSON.stringify(unref(val), null, 2))  
192 - );  
193 - unref(isSuccessRef);  
194 - createMessage.success('复制成功!'); 192 + const copyTopic = async (val) => {
  193 + await copy(JSON.parse(JSON.stringify(unref(val), null, 2)));
  194 + if (unref(copied)) {
  195 + createMessage.success('复制成功!');
  196 + }
195 }; 197 };
196 198
197 const [registerTopicModal, { openModal: openTopicModal }] = useModal(); 199 const [registerTopicModal, { openModal: openTopicModal }] = useModal();
@@ -215,7 +215,7 @@ @@ -215,7 +215,7 @@
215 import { USER_INFO_KEY } from '/@/enums/cacheEnum'; 215 import { USER_INFO_KEY } from '/@/enums/cacheEnum';
216 import { getAuthCache } from '/@/utils/auth'; 216 import { getAuthCache } from '/@/utils/auth';
217 import { authBtn } from '/@/enums/roleEnum'; 217 import { authBtn } from '/@/enums/roleEnum';
218 - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 218 + import { useClipboard } from '@vueuse/core';
219 import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 219 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
220 import { Authority } from '/@/components/Authority'; 220 import { Authority } from '/@/components/Authority';
221 import { useRoute, useRouter } from 'vue-router'; 221 import { useRoute, useRouter } from 'vue-router';
@@ -371,10 +371,10 @@ @@ -371,10 +371,10 @@
371 function goDeviceProfile(e) { 371 function goDeviceProfile(e) {
372 go(PageEnum.DEVICE_PROFILE + '?name=' + String(e)); 372 go(PageEnum.DEVICE_PROFILE + '?name=' + String(e));
373 } 373 }
374 - const { clipboardRef } = useCopyToClipboard();  
375 - const copySN = (snCode: string) => {  
376 - clipboardRef.value = snCode;  
377 - if (unref(clipboardRef)) { 374 + const { copied, copy } = useClipboard({ legacy: true });
  375 + const copySN = async (snCode: string) => {
  376 + await copy(snCode);
  377 + if (unref(copied)) {
378 createMessage.success('复制成功~'); 378 createMessage.success('复制成功~');
379 } 379 }
380 }; 380 };
@@ -6,10 +6,11 @@ import { numberRule } from '/@/utils/rules'; @@ -6,10 +6,11 @@ import { numberRule } from '/@/utils/rules';
6 6
7 import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi'; 7 import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi';
8 import { FormField, FunctionType } from './step/cpns/physical/cpns/config'; 8 import { FormField, FunctionType } from './step/cpns/physical/cpns/config';
9 -import { h } from 'vue'; 9 +import { h, unref } from 'vue';
10 import { Tag, Tooltip } from 'ant-design-vue'; 10 import { Tag, Tooltip } from 'ant-design-vue';
11 import { EventType, EventTypeColor, EventTypeName } from '../list/cpns/tabs/EventManage/config'; 11 import { EventType, EventTypeColor, EventTypeName } from '../list/cpns/tabs/EventManage/config';
12 -import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 12 +
  13 +import { useClipboard } from '@vueuse/core';
13 import { useMessage } from '/@/hooks/web/useMessage'; 14 import { useMessage } from '/@/hooks/web/useMessage';
14 15
15 export enum Mode { 16 export enum Mode {
@@ -39,11 +40,11 @@ export enum ModelOfMatterPermission { @@ -39,11 +40,11 @@ export enum ModelOfMatterPermission {
39 RELEASE = 'api:yt:things_model:release', 40 RELEASE = 'api:yt:things_model:release',
40 } 41 }
41 42
42 -const handleCopy = (value: string) => { 43 +const handleCopy = async (value: string) => {
43 const { createMessage } = useMessage(); 44 const { createMessage } = useMessage();
44 - const { clipboardRef, isSuccessRef } = useCopyToClipboard(value);  
45 - clipboardRef.value = value;  
46 - if (isSuccessRef.value) createMessage.success('复制成功~'); 45 + const { copied, copy } = useClipboard({ legacy: true });
  46 + await copy(value);
  47 + if (unref(copied)) createMessage.success('复制成功~');
47 else createMessage.error('复制失败~'); 48 else createMessage.error('复制失败~');
48 }; 49 };
49 50
@@ -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 { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 45 + import { useClipboard } from '@vueuse/core';
46 46
47 const props = defineProps<{ 47 const props = defineProps<{
48 record: DeviceRecord; 48 record: DeviceRecord;
@@ -58,15 +58,15 @@ @@ -58,15 +58,15 @@
58 58
59 const activeKey = ref(FunctionType.PROPERTIES); 59 const activeKey = ref(FunctionType.PROPERTIES);
60 60
61 - const { clipboardRef, isSuccessRef } = useCopyToClipboard(jsonValue.value);  
62 - const handleCopy = () => { 61 + const { copied, copy } = useClipboard({ legacy: true });
  62 + const handleCopy = async () => {
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 - clipboardRef.value = jsonValue.value;  
69 - if (unref(isSuccessRef)) createMessage.success('复制成功!'); 68 + await copy(jsonValue.value);
  69 + if (unref(copied)) createMessage.success('复制成功!');
70 else createMessage.error('复制失败!'); 70 else createMessage.error('复制失败!');
71 } catch (e) { 71 } catch (e) {
72 console.log(e); 72 console.log(e);
1 import { BasicColumn } from '/@/components/Table/src/types/table'; 1 import { BasicColumn } from '/@/components/Table/src/types/table';
2 import { h, unref } from 'vue'; 2 import { h, unref } from 'vue';
3 -import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 3 +import { useClipboard } from '@vueuse/core';
4 import { useMessage } from '/@/hooks/web/useMessage'; 4 import { useMessage } from '/@/hooks/web/useMessage';
5 const { createMessage } = useMessage(); 5 const { createMessage } = useMessage();
6 6
7 -export const handeleCopy = (e) => {  
8 - const { isSuccessRef } = useCopyToClipboard(JSON.parse(JSON.stringify(unref(e), null, 2)));  
9 - unref(isSuccessRef);  
10 - createMessage.success('复制成功!'); 7 +export const handeleCopy = async (e) => {
  8 + const { copied, copy } = useClipboard({ legacy: true });
  9 + await copy(JSON.parse(JSON.stringify(unref(e), null, 2)));
  10 + if (unref(copied)) {
  11 + createMessage.success('复制成功!');
  12 + }
11 }; 13 };
12 14
13 export const topicTableColumn: BasicColumn[] = [ 15 export const topicTableColumn: BasicColumn[] = [
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 getDeviceProfileInfoById, 13 getDeviceProfileInfoById,
14 getOtaPackageInfo, 14 getOtaPackageInfo,
15 } from '/@/api/ota'; 15 } from '/@/api/ota';
16 - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 16 + import { useClipboard } from '@vueuse/core';
17 import { useDownload } from '../hook/useDownload'; 17 import { useDownload } from '../hook/useDownload';
18 import { Authority } from '/@/components/Authority'; 18 import { Authority } from '/@/components/Authority';
19 import { OtaPermissionKey } from '../config/config'; 19 import { OtaPermissionKey } from '../config/config';
@@ -86,19 +86,19 @@ @@ -86,19 +86,19 @@
86 }); 86 });
87 }; 87 };
88 88
89 - const { clipboardRef, isSuccessRef } = useCopyToClipboard('');  
90 - const copyPackageId = () => {  
91 - clipboardRef.value = otaRecord.value.id.id;  
92 - if (unref(isSuccessRef)) createMessage.success('复制成功'); 89 + const { copied, copy } = useClipboard({ legacy: true });
  90 + const copyPackageId = async () => {
  91 + await copy(otaRecord.value.id.id);
  92 + if (unref(copied)) createMessage.success('复制成功');
93 }; 93 };
94 94
95 - const copyUrl = () => { 95 + const copyUrl = async () => {
96 if (!unref(otaRecord).url) { 96 if (!unref(otaRecord).url) {
97 createMessage.warning('无直接URL'); 97 createMessage.warning('无直接URL');
98 return; 98 return;
99 } 99 }
100 - clipboardRef.value = otaRecord.value.url;  
101 - if (unref(isSuccessRef)) createMessage.success('复制成功'); 100 + await copy(otaRecord.value.url);
  101 + if (unref(copied)) createMessage.success('复制成功');
102 }; 102 };
103 103
104 const setLoading = (status: boolean) => { 104 const setLoading = (status: boolean) => {
@@ -7,7 +7,6 @@ import { devicePage } from '/@/api/device/deviceManager'; @@ -7,7 +7,6 @@ import { devicePage } from '/@/api/device/deviceManager';
7 import { Tag } from 'ant-design-vue'; 7 import { Tag } from 'ant-design-vue';
8 import { DeviceRecord } from '/@/api/device/model/deviceModel'; 8 import { DeviceRecord } from '/@/api/device/model/deviceModel';
9 import { FETCH_SETTING } from '/@/components/Table/src/const'; 9 import { FETCH_SETTING } from '/@/components/Table/src/const';
10 -import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';  
11 import { useMessage } from '/@/hooks/web/useMessage'; 10 import { useMessage } from '/@/hooks/web/useMessage';
12 import { 11 import {
13 BasicInfoFormField, 12 BasicInfoFormField,
@@ -16,6 +15,7 @@ import { @@ -16,6 +15,7 @@ import {
16 DeviceStatusNameEnum, 15 DeviceStatusNameEnum,
17 DeviceTypeNameEnum, 16 DeviceTypeNameEnum,
18 } from '../enum'; 17 } from '../enum';
  18 +import { useClipboard } from '@vueuse/core';
19 19
20 export const stepConfig = ['选择流转方式', '完善配置参数']; 20 export const stepConfig = ['选择流转方式', '完善配置参数'];
21 21
@@ -73,7 +73,7 @@ const deviceTableFormSchema: FormSchema[] = [ @@ -73,7 +73,7 @@ const deviceTableFormSchema: FormSchema[] = [
73 }, 73 },
74 ]; 74 ];
75 75
76 -const { clipboardRef, isSuccessRef } = useCopyToClipboard(); 76 +const { copied, copy } = useClipboard({ legacy: true });
77 77
78 const { createMessage } = useMessage(); 78 const { createMessage } = useMessage();
79 79
@@ -105,9 +105,9 @@ const deviceTableColumn: BasicColumn[] = [ @@ -105,9 +105,9 @@ const deviceTableColumn: BasicColumn[] = [
105 'div', 105 'div',
106 { 106 {
107 class: 'cursor-pointer', 107 class: 'cursor-pointer',
108 - onClick: () => {  
109 - clipboardRef.value = record.name;  
110 - if (unref(isSuccessRef)) createMessage.success('复制成功~'); 108 + onClick: async () => {
  109 + await copy(record.name);
  110 + if (unref(copied)) createMessage.success('复制成功~');
111 }, 111 },
112 }, 112 },
113 [ 113 [
@@ -8,7 +8,7 @@ import { devicePage } from '/@/api/device/deviceManager'; @@ -8,7 +8,7 @@ import { devicePage } from '/@/api/device/deviceManager';
8 import { Tag } from 'ant-design-vue'; 8 import { Tag } from 'ant-design-vue';
9 import { DeviceRecord } from '/@/api/device/model/deviceModel'; 9 import { DeviceRecord } from '/@/api/device/model/deviceModel';
10 import { FETCH_SETTING } from '/@/components/Table/src/const'; 10 import { FETCH_SETTING } from '/@/components/Table/src/const';
11 -import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 11 +import { useClipboard } from '@vueuse/core';
12 import { useMessage } from '/@/hooks/web/useMessage'; 12 import { useMessage } from '/@/hooks/web/useMessage';
13 13
14 const typeValue = ref(''); 14 const typeValue = ref('');
@@ -102,7 +102,7 @@ const deviceTableFormSchema: FormSchema[] = [ @@ -102,7 +102,7 @@ const deviceTableFormSchema: FormSchema[] = [
102 }, 102 },
103 }, 103 },
104 ]; 104 ];
105 -const { clipboardRef, isSuccessRef } = useCopyToClipboard(); 105 +const { copied, copy } = useClipboard({ legacy: true });
106 const { createMessage } = useMessage(); 106 const { createMessage } = useMessage();
107 const deviceTableColumn: BasicColumn[] = [ 107 const deviceTableColumn: BasicColumn[] = [
108 { 108 {
@@ -132,9 +132,9 @@ const deviceTableColumn: BasicColumn[] = [ @@ -132,9 +132,9 @@ const deviceTableColumn: BasicColumn[] = [
132 'div', 132 'div',
133 { 133 {
134 class: 'cursor-pointer', 134 class: 'cursor-pointer',
135 - onClick: () => {  
136 - clipboardRef.value = record.name;  
137 - if (unref(isSuccessRef)) createMessage.success('复制成功~'); 135 + onClick: async () => {
  136 + await copy(record.name);
  137 + if (unref(copied)) createMessage.success('复制成功~');
138 }, 138 },
139 }, 139 },
140 [ 140 [
@@ -123,7 +123,7 @@ @@ -123,7 +123,7 @@
123 import 'ace-builds/src-noconflict/mode-javascript'; // 默认设置的语言模式 123 import 'ace-builds/src-noconflict/mode-javascript'; // 默认设置的语言模式
124 import { beautify } from 'ace-builds/src-noconflict/ext-beautify.js'; 124 import { beautify } from 'ace-builds/src-noconflict/ext-beautify.js';
125 import { CopyOutlined } from '@ant-design/icons-vue'; 125 import { CopyOutlined } from '@ant-design/icons-vue';
126 - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 126 + import { useClipboard } from '@vueuse/core';
127 import { useMessage } from '/@/hooks/web/useMessage'; 127 import { useMessage } from '/@/hooks/web/useMessage';
128 import { findDictItemByCode } from '/@/api/system/dict'; 128 import { findDictItemByCode } from '/@/api/system/dict';
129 import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 129 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
@@ -171,7 +171,7 @@ @@ -171,7 +171,7 @@
171 171
172 const { createMessage } = useMessage(); 172 const { createMessage } = useMessage();
173 173
174 - const { clipboardRef, copiedRef } = useCopyToClipboard(); 174 + const { copied, copy } = useClipboard({ legacy: true });
175 175
176 const aceEditor = ref(); 176 const aceEditor = ref();
177 177
@@ -236,15 +236,15 @@ @@ -236,15 +236,15 @@
236 handleFormat(); 236 handleFormat();
237 }; 237 };
238 238
239 - const handleCopy = () => { 239 + const handleCopy = async () => {
240 const valueRef = aceEditor.value.getValue(); 240 const valueRef = aceEditor.value.getValue();
241 const value = unref(valueRef); 241 const value = unref(valueRef);
242 if (!value) { 242 if (!value) {
243 createMessage.warning('请输入要拷贝的内容!'); 243 createMessage.warning('请输入要拷贝的内容!');
244 return; 244 return;
245 } 245 }
246 - clipboardRef.value = value;  
247 - if (unref(copiedRef)) { 246 + await copy(value);
  247 + if (unref(copied)) {
248 createMessage.success('复制成功!'); 248 createMessage.success('复制成功!');
249 } 249 }
250 }; 250 };