bfg-common 1.4.535 → 1.4.536
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,24 @@
|
|
|
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 v-model="usbDevice" @change="onChangeUsbDevice">
|
|
53
|
+
<option
|
|
54
|
+
v-for="item in usbDevices"
|
|
55
|
+
:key="item.value"
|
|
56
|
+
:value="item.value"
|
|
57
|
+
:disabled="item.disabled"
|
|
58
|
+
>
|
|
59
|
+
{{ item.label }}
|
|
60
|
+
</option>
|
|
61
|
+
</select>
|
|
62
|
+
|
|
60
63
|
<select
|
|
61
64
|
v-model="codec"
|
|
62
65
|
@mouseenter="hover = true"
|
|
@@ -93,8 +96,13 @@
|
|
|
93
96
|
</template>
|
|
94
97
|
<script setup lang="ts">
|
|
95
98
|
import { useDraggable } from '@vueuse/core'
|
|
99
|
+
import type { UI_I_DeviceOption } from '~/components/common/spiceConsole/lib/models/interfaces'
|
|
96
100
|
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
97
101
|
import type { UI_T_CODEC } from '~/components/common/spiceConsole/lib/models/types'
|
|
102
|
+
import {
|
|
103
|
+
getUSBDeviceType,
|
|
104
|
+
identifyHIDDevice,
|
|
105
|
+
} from '~/components/common/spiceConsole/lib/utils/getDeviceType'
|
|
98
106
|
|
|
99
107
|
const emits = defineEmits<{
|
|
100
108
|
(event: 'toggle-fullscreen'): void
|
|
@@ -107,7 +115,7 @@ const onChangeCodec = (): void => {
|
|
|
107
115
|
if (!window.app) return
|
|
108
116
|
// @ts-ignore
|
|
109
117
|
const channels = window.app.spiceConnection.channels
|
|
110
|
-
for (
|
|
118
|
+
for (const i in channels) {
|
|
111
119
|
const channel = channels[i]
|
|
112
120
|
if (channel.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
|
|
113
121
|
channel.changeCodec(codec.value)
|
|
@@ -140,7 +148,7 @@ watch(y, () => {
|
|
|
140
148
|
})
|
|
141
149
|
|
|
142
150
|
let isDrag = false
|
|
143
|
-
const toggleDrawer = () => {
|
|
151
|
+
const toggleDrawer = (): void => {
|
|
144
152
|
if (isDrag) {
|
|
145
153
|
isDrag = false
|
|
146
154
|
return
|
|
@@ -166,6 +174,63 @@ const displaySizeInfo = (): void => {
|
|
|
166
174
|
requestAnimationFrame(displaySizeInfo)
|
|
167
175
|
}
|
|
168
176
|
displaySizeInfo()
|
|
177
|
+
|
|
178
|
+
const usbDevice = ref<number | string>(-1)
|
|
179
|
+
const usbDevices = ref<UI_I_DeviceOption[]>([
|
|
180
|
+
{ label: 'USB Device', value: -1, disabled: true },
|
|
181
|
+
{ label: 'Add USB device', value: -2 },
|
|
182
|
+
])
|
|
183
|
+
const onChangeUsbDevice = (data: any): void => {
|
|
184
|
+
if (data.target.value === '-2') {
|
|
185
|
+
getUSBDeviceInformation()
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const getUSBDeviceInformation = async (): Promise<void> => {
|
|
190
|
+
try {
|
|
191
|
+
// Запросить устройство
|
|
192
|
+
const device = await navigator.usb.requestDevice({ filters: [] })
|
|
193
|
+
usbDevice.value = setDevice(device)
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error('Error:', error)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const setDevice = (device: any): string => {
|
|
200
|
+
const interfaces = device.configuration.interfaces
|
|
201
|
+
|
|
202
|
+
const types: any = new Set()
|
|
203
|
+
interfaces.forEach((item: any) => {
|
|
204
|
+
const classCode = item.alternate.interfaceClass
|
|
205
|
+
const subclassCode = item.alternate.interfaceSubclass
|
|
206
|
+
const protocolCode = item.alternate.interfaceProtocol
|
|
207
|
+
|
|
208
|
+
if (classCode === 0x03) {
|
|
209
|
+
// HID класс
|
|
210
|
+
types.add(identifyHIDDevice(subclassCode, protocolCode))
|
|
211
|
+
} else {
|
|
212
|
+
types.add(getUSBDeviceType(classCode))
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
const value = `${device.productId}_${device.vendorId}`
|
|
217
|
+
if (usbDevices.value.every((device) => device.value !== value)) {
|
|
218
|
+
usbDevices.value.push({
|
|
219
|
+
value,
|
|
220
|
+
label: Array.from(types).join(' / '),
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return value
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const setDefaultDevices = async (): Promise<void> => {
|
|
228
|
+
const devices = await navigator.usb.getDevices()
|
|
229
|
+
devices.forEach((device: any) => {
|
|
230
|
+
setDevice(device)
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
setDefaultDevices()
|
|
169
234
|
</script>
|
|
170
235
|
<style lang="scss" scoped>
|
|
171
236
|
.vmw-drawer {
|
|
@@ -176,6 +241,7 @@ displaySizeInfo()
|
|
|
176
241
|
width: 300px;
|
|
177
242
|
height: 100vh;
|
|
178
243
|
padding: 20px;
|
|
244
|
+
z-index: 9999;
|
|
179
245
|
|
|
180
246
|
&.show {
|
|
181
247
|
right: 0;
|
|
@@ -269,7 +335,7 @@ displaySizeInfo()
|
|
|
269
335
|
cursor: not-allowed;
|
|
270
336
|
}
|
|
271
337
|
|
|
272
|
-
input[type=
|
|
338
|
+
input[type='file'] {
|
|
273
339
|
position: absolute;
|
|
274
340
|
top: 0;
|
|
275
341
|
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
|
+
}
|