fix: 删除 nmcli 命令缺失弹窗提示

This commit is contained in:
mofeng-git
2026-07-20 21:24:27 +08:00
parent 219d1ccd08
commit e0055bf491
4 changed files with 41 additions and 17 deletions

View File

@@ -115,7 +115,7 @@ export const otgNetworkApi = {
status: () => request<OtgNetworkStatus>('/otg/network/status'),
interfaces: () => request<NetworkInterfaceInfo[]>('/devices/network'),
interfaces: () => request<NetworkInterfaceInfo[]>('/devices/network', {}, { toastOnError: false }),
}
export const otgConfigApi = {

View File

@@ -653,6 +653,7 @@ export default {
otgNetworkDriver: 'Host Driver Mode',
otgNetworkInterface: 'Bridge Interface',
otgNetworkNone: 'None',
otgNetworkInterfacesLoadFailed: 'Failed to load bridge interfaces',
otgDescriptor: 'USB Device Descriptor',
vendorId: 'Vendor ID (VID)',
productId: 'Product ID (PID)',

View File

@@ -652,6 +652,7 @@ export default {
otgNetworkDriver: '目标机驱动模式',
otgNetworkInterface: '桥接网卡',
otgNetworkNone: '无',
otgNetworkInterfacesLoadFailed: '无法获取桥接网卡列表',
otgDescriptor: 'USB 设备描述符',
vendorId: '厂商 ID (VID)',
productId: '产品 ID (PID)',

View File

@@ -269,15 +269,12 @@ async function loadSectionData(section: SettingsSectionId) {
case 'video':
await Promise.all([
loadConfig(),
loadDevices(),
loadDeviceConfig(),
loadBackends(),
])
return
case 'hid':
await Promise.all([
loadConfig(),
loadDevices(),
])
await Promise.all([loadConfig(), loadHidDeviceOptions()])
return
case 'atx':
await Promise.all([
@@ -689,6 +686,7 @@ const config = ref({
const otgNetworkInterfaces = ref<NetworkInterfaceInfo[]>([])
const otgNetworkInterfacesLoaded = ref(false)
const otgNetworkInterfacesError = ref('')
const otgNetworkStatus = ref<OtgNetworkStatus | null>(null)
function syncOtgNetworkInterface() {
@@ -1569,20 +1567,30 @@ async function loadConfig() {
}
}
async function loadDevices() {
async function loadDeviceConfig() {
try {
const [deviceConfig, networkInterfaces] = await Promise.all([
configApi.listDevices(),
otgNetworkApi.interfaces().catch(() => []),
])
devices.value = deviceConfig
otgNetworkInterfaces.value = networkInterfaces
devices.value = await configApi.listDevices()
} catch {
}
}
async function loadOtgNetworkInterfaces() {
otgNetworkInterfacesError.value = ''
try {
otgNetworkInterfaces.value = await otgNetworkApi.interfaces()
otgNetworkInterfacesLoaded.value = true
syncOtgNetworkInterface()
} catch {
otgNetworkInterfaces.value = []
otgNetworkInterfacesLoaded.value = false
otgNetworkInterfacesError.value = t('settings.otgNetworkInterfacesLoadFailed')
}
}
async function loadHidDeviceOptions() {
await Promise.all([loadDeviceConfig(), loadOtgNetworkInterfaces()])
}
async function loadBackends() {
try {
const result = await streamApi.getCodecs()
@@ -2902,7 +2910,7 @@ watch(isWindows, () => {
<CardTitle>{{ t('settings.videoSettings') }}</CardTitle>
<CardDescription>{{ t('settings.videoSettingsDesc') }}</CardDescription>
</div>
<Button variant="ghost" size="icon-sm" :aria-label="t('common.refresh')" @click="loadDevices">
<Button variant="ghost" size="icon-sm" :aria-label="t('common.refresh')" @click="loadDeviceConfig">
<RefreshCw class="size-4" />
</Button>
</CardHeader>
@@ -3041,7 +3049,7 @@ watch(isWindows, () => {
<CardTitle>{{ t('settings.hidSettings') }}</CardTitle>
<CardDescription>{{ t('settings.hidSettingsDesc') }}</CardDescription>
</div>
<Button variant="ghost" size="icon-sm" :aria-label="t('common.refresh')" @click="loadDevices">
<Button variant="ghost" size="icon-sm" :aria-label="t('common.refresh')" @click="loadHidDeviceOptions">
<RefreshCw class="size-4" />
</Button>
</CardHeader>
@@ -3325,8 +3333,22 @@ watch(isWindows, () => {
</div>
<div class="space-y-2">
<Label for="otg-network-interface">{{ t('settings.otgNetworkInterface') }}</Label>
<NativeSelect id="otg-network-interface" v-model="config.otg_network_interface" class="w-full" :disabled="otgNetworkInterfaces.length === 0">
<NativeSelectOption v-if="otgNetworkInterfaces.length === 0" value="">{{ t('settings.otgNetworkNone') }}</NativeSelectOption>
<NativeSelect
id="otg-network-interface"
v-model="config.otg_network_interface"
class="w-full"
:disabled="otgNetworkInterfaces.length === 0"
:aria-invalid="Boolean(otgNetworkInterfacesError)"
>
<NativeSelectOption
v-if="otgNetworkInterfacesError"
:value="config.otg_network_interface"
>
{{ otgNetworkInterfacesError }}
</NativeSelectOption>
<NativeSelectOption v-else-if="otgNetworkInterfaces.length === 0" value="">
{{ t('settings.otgNetworkNone') }}
</NativeSelectOption>
<NativeSelectOption
v-for="item in otgNetworkInterfaces"
:key="item.name"