Commit ba6edb7fb2ae5d37fe033650fbfc60cacbcd3899
Merge branch 'local_dev_ft' into 'main'
pref:优化Topic可以复制 See merge request huang/yun-teng-iot-front!437
Showing
2 changed files
with
51 additions
and
1 deletions
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | import { BasicTable, useTable } from '/@/components/Table'; | 2 | import { BasicTable, useTable } from '/@/components/Table'; |
3 | import { list, topicTableColumn } from './topic'; | 3 | import { list, topicTableColumn } from './topic'; |
4 | + import { unref } from 'vue'; | ||
5 | + import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; | ||
6 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
4 | 7 | ||
8 | + const { createMessage } = useMessage(); | ||
5 | const [register] = useTable({ | 9 | const [register] = useTable({ |
6 | title: 'Topic', | 10 | title: 'Topic', |
7 | showIndexColumn: false, | 11 | showIndexColumn: false, |
@@ -10,10 +14,51 @@ | @@ -10,10 +14,51 @@ | ||
10 | bordered: true, | 14 | bordered: true, |
11 | showTableSetting: true, | 15 | showTableSetting: true, |
12 | }); | 16 | }); |
17 | + const handeleCopy = (e) => { | ||
18 | + const { isSuccessRef } = useCopyToClipboard(JSON.parse(JSON.stringify(unref(e), null, 2))); | ||
19 | + unref(isSuccessRef); | ||
20 | + createMessage.success('复制成功!'); | ||
21 | + }; | ||
13 | </script> | 22 | </script> |
14 | 23 | ||
15 | <template> | 24 | <template> |
16 | <section class="bg-gray-100 p-4 dark:bg-dark-900 w-full h-full"> | 25 | <section class="bg-gray-100 p-4 dark:bg-dark-900 w-full h-full"> |
17 | - <BasicTable @register="register" /> | 26 | + <BasicTable @register="register"> |
27 | + <template #function="{ record }"> | ||
28 | + <a-tooltip :title="record.function"> | ||
29 | + <a-button type="text" class="ml-2" @click="handeleCopy(record.function)"> | ||
30 | + <span>{{ record.function.slice(0, 13) }}</span> | ||
31 | + </a-button> | ||
32 | + </a-tooltip> | ||
33 | + </template> | ||
34 | + <template #release="{ record }"> | ||
35 | + <a-tooltip :title="record.release"> | ||
36 | + <a-button type="text" class="ml-2" @click="handeleCopy(record.release)"> | ||
37 | + <span>{{ record.release.slice(0, 30) }}</span> | ||
38 | + </a-button> | ||
39 | + </a-tooltip> | ||
40 | + </template> | ||
41 | + <template #subscribe="{ record }"> | ||
42 | + <a-tooltip :title="record.subscribe"> | ||
43 | + <a-button type="text" class="ml-2" @click="handeleCopy(record.subscribe)"> | ||
44 | + <span>{{ record.subscribe.slice(0, 30) }}</span> | ||
45 | + </a-button> | ||
46 | + </a-tooltip> | ||
47 | + </template> | ||
48 | + <template #platform="{ record }"> | ||
49 | + <a-tooltip :title="record.platform"> | ||
50 | + <a-button type="text" class="ml-2" @click="handeleCopy(record.platform)"> | ||
51 | + <span>{{ record.platform }}</span> | ||
52 | + </a-button> | ||
53 | + </a-tooltip> | ||
54 | + </template> | ||
55 | + <template #device="{ record }"> | ||
56 | + <a-tooltip :title="record.device"> | ||
57 | + <a-button type="text" class="ml-2" @click="handeleCopy(record.device)"> | ||
58 | + <span>{{ record.device }}</span> | ||
59 | + </a-button> | ||
60 | + </a-tooltip> | ||
61 | + </template> | ||
62 | + </BasicTable> | ||
18 | </section> | 63 | </section> |
19 | </template> | 64 | </template> |
@@ -29,26 +29,31 @@ export const topicTableColumn: BasicColumn[] = [ | @@ -29,26 +29,31 @@ export const topicTableColumn: BasicColumn[] = [ | ||
29 | title: '功能', | 29 | title: '功能', |
30 | dataIndex: 'function', | 30 | dataIndex: 'function', |
31 | width: 100, | 31 | width: 100, |
32 | + slots: { customRender: 'function' }, | ||
32 | }, | 33 | }, |
33 | { | 34 | { |
34 | title: '发布主题', | 35 | title: '发布主题', |
35 | dataIndex: 'release', | 36 | dataIndex: 'release', |
36 | width: 120, | 37 | width: 120, |
38 | + slots: { customRender: 'release' }, | ||
37 | }, | 39 | }, |
38 | { | 40 | { |
39 | title: '订阅主题', | 41 | title: '订阅主题', |
40 | dataIndex: 'subscribe', | 42 | dataIndex: 'subscribe', |
41 | width: 120, | 43 | width: 120, |
44 | + slots: { customRender: 'subscribe' }, | ||
42 | }, | 45 | }, |
43 | { | 46 | { |
44 | title: '平台', | 47 | title: '平台', |
45 | dataIndex: 'platform', | 48 | dataIndex: 'platform', |
46 | width: 30, | 49 | width: 30, |
50 | + slots: { customRender: 'platform' }, | ||
47 | }, | 51 | }, |
48 | { | 52 | { |
49 | title: '设备', | 53 | title: '设备', |
50 | dataIndex: 'device', | 54 | dataIndex: 'device', |
51 | width: 30, | 55 | width: 30, |
56 | + slots: { customRender: 'device' }, | ||
52 | }, | 57 | }, |
53 | ]; | 58 | ]; |
54 | 59 |