mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-15 07:26:44 +08:00
feat: HID串口优先ttyUSB并在视频设备名称后显示路径
This commit is contained in:
@@ -537,6 +537,25 @@ export const msdApi = {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SerialDeviceOption {
|
||||||
|
path: string
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSerialDevicePriority(path: string): number {
|
||||||
|
if (/^\/dev\/ttyUSB/i.test(path)) return 0
|
||||||
|
if (/^\/dev\/(ttyS|S)/i.test(path)) return 2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortSerialDevices(serialDevices: SerialDeviceOption[]): SerialDeviceOption[] {
|
||||||
|
return [...serialDevices].sort((a, b) => {
|
||||||
|
const priorityDiff = getSerialDevicePriority(a.path) - getSerialDevicePriority(b.path)
|
||||||
|
if (priorityDiff !== 0) return priorityDiff
|
||||||
|
return a.path.localeCompare(b.path, undefined, { numeric: true, sensitivity: 'base' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Config API
|
// Config API
|
||||||
/** @deprecated 使用域特定 API(videoConfigApi, hidConfigApi 等)替代 */
|
/** @deprecated 使用域特定 API(videoConfigApi, hidConfigApi 等)替代 */
|
||||||
export const configApi = {
|
export const configApi = {
|
||||||
@@ -549,8 +568,8 @@ export const configApi = {
|
|||||||
body: JSON.stringify(updates),
|
body: JSON.stringify(updates),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
listDevices: () =>
|
listDevices: async () => {
|
||||||
request<{
|
const result = await request<{
|
||||||
video: Array<{
|
video: Array<{
|
||||||
path: string
|
path: string
|
||||||
name: string
|
name: string
|
||||||
@@ -578,7 +597,13 @@ export const configApi = {
|
|||||||
ttyd_available: boolean
|
ttyd_available: boolean
|
||||||
rustdesk_available: boolean
|
rustdesk_available: boolean
|
||||||
}
|
}
|
||||||
}>('/devices'),
|
}>('/devices')
|
||||||
|
|
||||||
|
return {
|
||||||
|
...result,
|
||||||
|
serial: sortSerialDevices(result.serial),
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出新的域分离配置 API
|
// 导出新的域分离配置 API
|
||||||
|
|||||||
@@ -753,7 +753,7 @@ watch(currentConfig, () => {
|
|||||||
:value="device.path"
|
:value="device.path"
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
>
|
>
|
||||||
{{ device.name }}
|
{{ device.name }} ({{ device.path }})
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|||||||
@@ -1654,7 +1654,7 @@ watch(updateChannel, async () => {
|
|||||||
<Label for="video-device">{{ t('settings.videoDevice') }}</Label>
|
<Label for="video-device">{{ t('settings.videoDevice') }}</Label>
|
||||||
<select id="video-device" v-model="config.video_device" class="w-full h-9 px-3 rounded-md border border-input bg-background text-sm">
|
<select id="video-device" v-model="config.video_device" class="w-full h-9 px-3 rounded-md border border-input bg-background text-sm">
|
||||||
<option value="">{{ t('settings.selectDevice') }}</option>
|
<option value="">{{ t('settings.selectDevice') }}</option>
|
||||||
<option v-for="dev in devices.video" :key="dev.path" :value="dev.path">{{ dev.name }}</option>
|
<option v-for="dev in devices.video" :key="dev.path" :value="dev.path">{{ dev.name }} ({{ dev.path }})</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user