fix(otg): 优化运行时状态监测与未枚举提示

This commit is contained in:
mofeng-git
2026-03-28 22:06:53 +08:00
parent a2a8b3802d
commit 7d52b2e2ea
4 changed files with 151 additions and 125 deletions

View File

@@ -363,7 +363,7 @@ export default {
recovered: 'HID Recovered',
recoveredDesc: '{backend} HID device reconnected successfully',
errorHints: {
udcNotConfigured: 'Target host has not finished USB enumeration yet',
udcNotConfigured: 'OTG is ready, waiting for the target host to connect and finish USB enumeration',
disabled: 'HID backend is disabled',
hidDeviceMissing: 'HID gadget device node is missing, try restarting HID service',
notOpened: 'HID device is not open, try restarting HID service',

View File

@@ -363,7 +363,7 @@ export default {
recovered: 'HID 已恢复',
recoveredDesc: '{backend} HID 设备已成功重连',
errorHints: {
udcNotConfigured: '被控机尚未完成 USB 枚举',
udcNotConfigured: 'OTG 已就绪,等待被控机连接并完成 USB 枚举',
disabled: 'HID 后端已禁用',
hidDeviceMissing: '未找到 HID 设备节点,可尝试重启 HID 服务',
notOpened: 'HID 设备尚未打开,可尝试重启 HID 服务',

View File

@@ -241,6 +241,7 @@ const videoDetails = computed<StatusDetail[]>(() => {
const hidStatus = computed<'connected' | 'connecting' | 'disconnected' | 'error'>(() => {
const hid = systemStore.hid
if (hid?.errorCode === 'udc_not_configured') return 'disconnected'
if (hid?.error) return 'error'
// In WebRTC mode, check DataChannel status first
@@ -348,11 +349,13 @@ const hidDetails = computed<StatusDetail[]>(() => {
const hid = systemStore.hid
if (!hid) return []
const errorMessage = buildHidErrorMessage(hid.error, hid.errorCode, hid.backend)
const hidErrorStatus: StatusDetail['status'] =
hid.errorCode === 'udc_not_configured' ? 'warning' : 'error'
const details: StatusDetail[] = [
{ label: t('statusCard.device'), value: hid.device || '-' },
{ label: t('statusCard.backend'), value: hid.backend || t('common.unknown') },
{ label: t('statusCard.initialized'), value: hid.initialized ? t('statusCard.yes') : t('statusCard.no'), status: hid.error ? 'error' : hid.initialized ? 'ok' : 'warning' },
{ label: t('statusCard.initialized'), value: hid.initialized ? t('statusCard.yes') : t('statusCard.no'), status: hid.error && hid.errorCode !== 'udc_not_configured' ? 'error' : hid.initialized ? 'ok' : 'warning' },
{ label: t('statusCard.online'), value: hid.online ? t('statusCard.yes') : t('statusCard.no'), status: hid.online ? 'ok' : hid.initialized ? 'warning' : 'error' },
{ label: t('statusCard.currentMode'), value: mouseMode.value === 'absolute' ? t('statusCard.absolute') : t('statusCard.relative'), status: 'ok' },
{
@@ -365,10 +368,10 @@ const hidDetails = computed<StatusDetail[]>(() => {
]
if (hid.errorCode) {
details.push({ label: t('statusCard.errorCode'), value: hid.errorCode, status: 'error' })
details.push({ label: t('statusCard.errorCode'), value: hid.errorCode, status: hidErrorStatus })
}
if (errorMessage) {
details.push({ label: t('common.error'), value: errorMessage, status: 'error' })
details.push({ label: t('common.error'), value: errorMessage, status: hidErrorStatus })
}
// Add HID channel info based on video mode