topic.tsx
7.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { BasicColumn } from '/@/components/Table/src/types/table';
import { h, unref } from 'vue';
import { useClipboard } from '@vueuse/core';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
const { createMessage } = useMessage();
export const handeleCopy = async (e) => {
const { t } = useI18n();
const { copied, copy } = useClipboard({ legacy: true });
await copy(JSON.parse(JSON.stringify(unref(e), null, 2)));
if (unref(copied)) {
createMessage.success(t('common.copyOk'));
}
};
export const getTopicTableColumn = (): BasicColumn[] => {
const { t } = useI18n();
return [
{
title: t('deviceManagement.product.deviceText'),
dataIndex: 'deviceType',
width: 40,
align: 'left',
customRender: ({ text, index }: { text: any; index: number }) => {
const obj: any = {
children: text,
attrs: {},
};
if (text !== t('deviceManagement.product.gatewayWithDirectWithSensorDeviceText')) {
if (index === 0) {
obj.attrs.rowSpan = 6;
}
if (index > 0 && index < 6) {
obj.attrs.rowSpan = 0;
}
if (index > 6) {
obj.attrs.rowSpan = 0;
}
if (index === 6) {
obj.attrs.rowSpan = 4;
}
return obj;
} else {
return obj;
}
},
},
{
title: t('deviceManagement.product.featureText'),
dataIndex: 'function',
width: 80,
align: 'left',
slots: { customRender: 'function' },
},
{
title: t('deviceManagement.product.releaseTopicText'),
dataIndex: 'release',
width: 80,
align: 'left',
customRender: ({ text }: { text: any }) => {
return h(
'span',
{
style: { cursor: 'pointer' },
onClick: () => {
handeleCopy(text);
},
},
text
);
},
},
{
title: t('deviceManagement.product.subscribeTopicText'),
dataIndex: 'subscribe',
width: 80,
align: 'left',
customRender: ({ text }: { text: any }) => {
return h(
'span',
{
style: { cursor: 'pointer' },
onClick: () => {
handeleCopy(text);
},
},
text
);
},
},
{
title: t('deviceManagement.product.platformText'),
dataIndex: 'platform',
width: 30,
slots: { customRender: 'platform' },
},
{
title: t('deviceManagement.product.deviceText'),
dataIndex: 'device',
width: 30,
slots: { customRender: 'device' },
},
];
};
export const getList = () => {
const { t } = useI18n();
return [
{
// deviceType: '网关/直连设备',
deviceType: t('deviceManagement.product.gatewayWithDirectDeviceText'),
function: t('deviceManagement.product.gatewayWithDirectTelemetryText'),
release: 'v1/devices/me/telemetry',
subscribe: 'v1/devices/me/telemetry',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.gatewayWithDirectDeviceText'),
function: t('deviceManagement.product.serverCommandToDeviceText'),
release: 'v1/devices/me/rpc/request/$request_id',
subscribe: 'v1/devices/me/rpc/request/+',
platform: t('deviceManagement.product.releaseText'),
device: t('deviceManagement.product.subscribeText'),
},
{
deviceType: t('deviceManagement.product.gatewayWithDirectDeviceText'),
function: t('deviceManagement.product.deviceResponseCommandToServerText'),
release: 'v1/devices/me/rpc/response/$request_id',
subscribe: 'v1/devices/me/rpc/response/+',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.gatewayWithDirectDeviceText'),
function: t('deviceManagement.product.directAttributeReportText'),
release: 'v1/devices/me/attributes',
subscribe: 'v1/devices/me/attributes',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.gatewayWithDirectDeviceText'),
function: t('deviceManagement.product.deviceRequestServerAttributeText'),
release: 'v1/devices/me/attributes/request/$request_id',
subscribe: 'v1/devices/me/attributes/response/+',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.gatewayWithDirectDeviceText'),
function: t('deviceManagement.product.serverResponseDeviceAttributeText'),
release: 'v1/devices/me/attributes/response/$request_id',
subscribe: 'v1/devices/me/attributes/response/+',
platform: t('deviceManagement.product.releaseText'),
device: t('deviceManagement.product.subscribeText'),
},
{
deviceType: t('deviceManagement.product.sensorDeviceText'),
function: t('deviceManagement.product.deviceRequestSensorAttributeText'),
release: 'v1/gateway/attributes/request',
subscribe: 'v1/gateway/attributes/request',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.sensorDeviceText'),
function: t('deviceManagement.product.serverResponseDeviceAttributeText'),
release: 'v1/gateway/attributes/response',
subscribe: 'v1/gateway/attributes/response',
platform: t('deviceManagement.product.releaseText'),
device: t('deviceManagement.product.subscribeText'),
},
{
deviceType: t('deviceManagement.product.sensorDeviceText'),
function: t('deviceManagement.product.deviceReportClientAttributeText'),
release: 'v1/gateway/attributes',
subscribe: 'v1/gateway/attributes',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.sensorDeviceText'),
function: t('deviceManagement.product.gatewaySubTelemetryText'),
release: 'v1/gateway/telemetry',
subscribe: 'v1/gateway/telemetry',
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
{
deviceType: t('deviceManagement.product.gatewayWithDirectWithSensorDeviceText'),
function: t('deviceManagement.product.eventReportText'),
release: `v1/devices/event/\${deviceId} ${t(
'deviceManagement.product.orText'
)} \${deviceName}/\${identifier}`,
subscribe: `v1/devices/event/\${deviceId} ${t(
'deviceManagement.product.orText'
)} \${deviceName}/\${identifier}`,
platform: t('deviceManagement.product.subscribeText'),
device: t('deviceManagement.product.releaseText'),
},
];
};