bfg-common 1.4.535 → 1.4.537
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,21 +42,29 @@
|
|
|
42
42
|
</button>
|
|
43
43
|
<label class="vmw-drawer-body__btn animation relative">
|
|
44
44
|
{{ localization.remoteConsole.uploadFolder }}
|
|
45
|
-
<input
|
|
46
|
-
type="file"
|
|
47
|
-
webkitdirectory
|
|
48
|
-
directory
|
|
49
|
-
multiple
|
|
50
|
-
/>
|
|
45
|
+
<input type="file" webkitdirectory directory multiple />
|
|
51
46
|
</label>
|
|
52
47
|
<label class="vmw-drawer-body__btn animation relative">
|
|
53
48
|
{{ localization.remoteConsole.uploadFiles }}
|
|
54
|
-
<input
|
|
55
|
-
type="file"
|
|
56
|
-
multiple
|
|
57
|
-
/>
|
|
49
|
+
<input type="file" multiple />
|
|
58
50
|
</label>
|
|
59
51
|
|
|
52
|
+
<select
|
|
53
|
+
v-model="usbDevice"
|
|
54
|
+
@mouseenter="hover = true"
|
|
55
|
+
@mouseleave="hover = false"
|
|
56
|
+
@change="onChangeUsbDevice"
|
|
57
|
+
>
|
|
58
|
+
<option
|
|
59
|
+
v-for="item in usbDevices"
|
|
60
|
+
:key="item.value"
|
|
61
|
+
:value="item.value"
|
|
62
|
+
:disabled="item.disabled"
|
|
63
|
+
>
|
|
64
|
+
{{ item.label }}
|
|
65
|
+
</option>
|
|
66
|
+
</select>
|
|
67
|
+
|
|
60
68
|
<select
|
|
61
69
|
v-model="codec"
|
|
62
70
|
@mouseenter="hover = true"
|
|
@@ -93,8 +101,13 @@
|
|
|
93
101
|
</template>
|
|
94
102
|
<script setup lang="ts">
|
|
95
103
|
import { useDraggable } from '@vueuse/core'
|
|
104
|
+
import type { UI_I_DeviceOption } from '~/components/common/spiceConsole/lib/models/interfaces'
|
|
96
105
|
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
97
106
|
import type { UI_T_CODEC } from '~/components/common/spiceConsole/lib/models/types'
|
|
107
|
+
import {
|
|
108
|
+
getUSBDeviceType,
|
|
109
|
+
identifyHIDDevice,
|
|
110
|
+
} from '~/components/common/spiceConsole/lib/utils/getDeviceType'
|
|
98
111
|
|
|
99
112
|
const emits = defineEmits<{
|
|
100
113
|
(event: 'toggle-fullscreen'): void
|
|
@@ -107,7 +120,7 @@ const onChangeCodec = (): void => {
|
|
|
107
120
|
if (!window.app) return
|
|
108
121
|
// @ts-ignore
|
|
109
122
|
const channels = window.app.spiceConnection.channels
|
|
110
|
-
for (
|
|
123
|
+
for (const i in channels) {
|
|
111
124
|
const channel = channels[i]
|
|
112
125
|
if (channel.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
|
|
113
126
|
channel.changeCodec(codec.value)
|
|
@@ -140,7 +153,7 @@ watch(y, () => {
|
|
|
140
153
|
})
|
|
141
154
|
|
|
142
155
|
let isDrag = false
|
|
143
|
-
const toggleDrawer = () => {
|
|
156
|
+
const toggleDrawer = (): void => {
|
|
144
157
|
if (isDrag) {
|
|
145
158
|
isDrag = false
|
|
146
159
|
return
|
|
@@ -166,6 +179,63 @@ const displaySizeInfo = (): void => {
|
|
|
166
179
|
requestAnimationFrame(displaySizeInfo)
|
|
167
180
|
}
|
|
168
181
|
displaySizeInfo()
|
|
182
|
+
|
|
183
|
+
const usbDevice = ref<number | string>(-1)
|
|
184
|
+
const usbDevices = ref<UI_I_DeviceOption[]>([
|
|
185
|
+
{ label: 'USB Device', value: -1, disabled: true },
|
|
186
|
+
{ label: 'Add USB device', value: -2 },
|
|
187
|
+
])
|
|
188
|
+
const onChangeUsbDevice = (data: any): void => {
|
|
189
|
+
if (data.target.value === '-2') {
|
|
190
|
+
getUSBDeviceInformation()
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const getUSBDeviceInformation = async (): Promise<void> => {
|
|
195
|
+
try {
|
|
196
|
+
// Запросить устройство
|
|
197
|
+
const device = await navigator.usb.requestDevice({ filters: [] })
|
|
198
|
+
usbDevice.value = setDevice(device)
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.error('Error:', error)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const setDevice = (device: any): string => {
|
|
205
|
+
const interfaces = device.configuration.interfaces
|
|
206
|
+
|
|
207
|
+
const types: any = new Set()
|
|
208
|
+
interfaces.forEach((item: any) => {
|
|
209
|
+
const classCode = item.alternate.interfaceClass
|
|
210
|
+
const subclassCode = item.alternate.interfaceSubclass
|
|
211
|
+
const protocolCode = item.alternate.interfaceProtocol
|
|
212
|
+
|
|
213
|
+
if (classCode === 0x03) {
|
|
214
|
+
// HID класс
|
|
215
|
+
types.add(identifyHIDDevice(subclassCode, protocolCode))
|
|
216
|
+
} else {
|
|
217
|
+
types.add(getUSBDeviceType(classCode))
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
const value = `${device.productId}_${device.vendorId}`
|
|
222
|
+
if (usbDevices.value.every((device) => device.value !== value)) {
|
|
223
|
+
usbDevices.value.push({
|
|
224
|
+
value,
|
|
225
|
+
label: Array.from(types).join(' / '),
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return value
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const setDefaultDevices = async (): Promise<void> => {
|
|
233
|
+
const devices = await navigator.usb.getDevices()
|
|
234
|
+
devices.forEach((device: any) => {
|
|
235
|
+
setDevice(device)
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
setDefaultDevices()
|
|
169
239
|
</script>
|
|
170
240
|
<style lang="scss" scoped>
|
|
171
241
|
.vmw-drawer {
|
|
@@ -176,6 +246,7 @@ displaySizeInfo()
|
|
|
176
246
|
width: 300px;
|
|
177
247
|
height: 100vh;
|
|
178
248
|
padding: 20px;
|
|
249
|
+
z-index: 9999;
|
|
179
250
|
|
|
180
251
|
&.show {
|
|
181
252
|
right: 0;
|
|
@@ -269,7 +340,7 @@ displaySizeInfo()
|
|
|
269
340
|
cursor: not-allowed;
|
|
270
341
|
}
|
|
271
342
|
|
|
272
|
-
input[type=
|
|
343
|
+
input[type='file'] {
|
|
273
344
|
position: absolute;
|
|
274
345
|
top: 0;
|
|
275
346
|
left: 0;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const getUSBDeviceType = (classCode: any): string => {
|
|
2
|
+
const deviceClasses = {
|
|
3
|
+
0x00: 'Undefined',
|
|
4
|
+
0x01: 'Audio',
|
|
5
|
+
0x02: 'Communications and CDC Control',
|
|
6
|
+
0x03: 'HID (Human Interface Device)',
|
|
7
|
+
0x05: 'Physical Interface Device',
|
|
8
|
+
0x06: 'Image (Scanner/Camera)',
|
|
9
|
+
0x07: 'Printer',
|
|
10
|
+
0x08: 'Mass Storage (e.g., Flash Drive)',
|
|
11
|
+
0x09: 'Hub',
|
|
12
|
+
0x0a: 'CDC-Data',
|
|
13
|
+
0x0b: 'Smart Card',
|
|
14
|
+
0x0d: 'Content Security',
|
|
15
|
+
0x0e: 'Video',
|
|
16
|
+
0x0f: 'Personal Healthcare',
|
|
17
|
+
0x10: 'Audio/Video Devices',
|
|
18
|
+
0x11: 'Billboard Device',
|
|
19
|
+
0x12: 'USB Type-C Bridge',
|
|
20
|
+
0xdc: 'Diagnostic Device',
|
|
21
|
+
0xe0: 'Wireless Controller',
|
|
22
|
+
0xef: 'Miscellaneous',
|
|
23
|
+
0xfe: 'Application-Specific',
|
|
24
|
+
0xff: 'Vendor-Specific',
|
|
25
|
+
}
|
|
26
|
+
return deviceClasses[classCode] || 'Unknown'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Функция для определения типа HID-устройства
|
|
30
|
+
export const identifyHIDDevice = (subclass: any, protocol: any): string => {
|
|
31
|
+
if (subclass === 0x01) {
|
|
32
|
+
if (protocol === 0x01) return 'Keyboard'
|
|
33
|
+
if (protocol === 0x02) return 'Mouse'
|
|
34
|
+
}
|
|
35
|
+
return 'Generic HID Device'
|
|
36
|
+
}
|