From 41d3ca271b762d1b0a5472ec7c5134eb63e544a6 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Sat, 19 Feb 2022 15:35:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=98=BE=E7=A4=BA=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E7=9A=84USB=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ClientConnection.ts | 10 +++++++ src/components/FileManageDialog.vue | 36 +++++++++++++++++++++----- src/components/SystemSettingDialog.vue | 2 +- src/entities/WSProtocol.ts | 26 ++++++++++++++++++- src/i18n/zh-CN/index.ts | 10 +++++++ 5 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index eeca3ec..960bb3b 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -745,6 +745,16 @@ export default class ClientConnection { ); } + public async getUsbDevices() { + try { + return await this.doRpc( + new Protocol.GetUsbDevicesRequestEntity(0) + ); + } catch (e) { + console.error(e); + } + } + public destory() { if (this.ws) { this.ws.onclose = null; diff --git a/src/components/FileManageDialog.vue b/src/components/FileManageDialog.vue index 023b0a1..a7cded9 100644 --- a/src/components/FileManageDialog.vue +++ b/src/components/FileManageDialog.vue @@ -377,12 +377,6 @@ export default defineComponent({ value: "media", }, ]); - for (let i = 1; i < 8; ++i) { - disk_options.value.push({ - label: $t.t("usb") + i.toString(), - value: "/usb" + i.toString(), - }); - } const columns = [ { @@ -555,6 +549,31 @@ export default defineComponent({ } ); + const refresh_usb_devices = async () => { + try { + const response = await GlobalData.getInstance() + .getCurrentClient() + ?.getUsbDevices(); + if (response) { + disk_options.value = [ + { + label: $t.t("local disk"), + value: "media", + }, + ]; + + for (let item of response.usb_list) { + disk_options.value.push({ + label: $t.t(item), + value: "/" + item, + }); + } + } + } catch (e) { + console.log(e); + } + }; + return { show_dialog, loading, @@ -575,14 +594,17 @@ export default defineComponent({ refresh_file_list, refresh_file_list_async, status, - showDialog(in_status: string) { + async showDialog(in_status: string) { status.value = in_status; + refresh_usb_devices(); refresh_file_list(); + show_dialog.value = true; }, showDialogAsync(in_status: string) { return new Promise((_resolve, _reject) => { status.value = in_status; + refresh_usb_devices(); refresh_file_list(); show_dialog.value = true; resolve = _resolve; diff --git a/src/components/SystemSettingDialog.vue b/src/components/SystemSettingDialog.vue index e2712f1..e887c8b 100644 --- a/src/components/SystemSettingDialog.vue +++ b/src/components/SystemSettingDialog.vue @@ -982,7 +982,7 @@ export default defineComponent({ const request = new Protocol.SetSystemNetworkRequestEntity(); request.auto_ip = auto_ip.value == $t.t("enable"); request.ip_address = ip_address.value; - request.gtateway = gateway.value; + request.gateway = gateway.value; request.net_mask = netmask.value; request.mac_address = mac_address.value; diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 5f335c3..a0c72ad 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -293,6 +293,10 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "RpcGetSystemTimes"; } + public static get kRpcGetUsbDevices() { + return Commands.PROTOCOL_PREFIX + "RpcGetUsbDevices"; + } + static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, @@ -364,6 +368,7 @@ export namespace Protocol { Commands.kDesktopResolutionChangedNotify, Commands.kDesktopDisconnectNotify, Commands.kRpcGetSystemTimes, + Commands.kRpcGetUsbDevices, ]); public static get AllCommands() { @@ -1309,7 +1314,7 @@ export namespace Protocol { export class SetSystemNetworkRequestEntity extends Protocol.PacketEntity { auto_ip: boolean = false; ip_address: string = "192.168.1.68"; - gtateway: string = "192.168.1.1"; + gateway: string = "192.168.1.1"; net_mask: string = "255.255.255.0"; mac_address: string = "04:D9:F5:D3:F4:C5"; @@ -1705,4 +1710,23 @@ export namespace Protocol { this.command = Commands.kRpcGetSystemTimes; } } + + export class GetUsbDevicesRequestEntity extends PacketEntity { + timestamp = new Date().getMilliseconds(); + + constructor(rpcid?: number) { + super(); + this.rpc_id = rpcid ?? 0; + this.command = Commands.kRpcGetUsbDevices; + } + } + + export class GetUsbDevicesResponseEntity extends PacketEntity { + usb_list: string[] = []; + + constructor() { + super(); + this.command = Commands.kRpcGetUsbDevices; + } + } } diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 603c200..9192c94 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -329,4 +329,14 @@ export default { "server run time": "服务运行时间", "current server system time": "当前服务系统时间", "server all run time": "服务总运行时间", + tf_card: "TF卡", + usb0: "USB0", + usb1: "USB1", + usb2: "USB2", + usb3: "USB3", + usb4: "USB4", + usb5: "USB5", + usb6: "USB6", + usb7: "USB7", + usb8: "USB8", };