只显示插入的USB设备

This commit is contained in:
fangxiang 2022-02-19 15:35:16 +08:00
parent 899690e180
commit 41d3ca271b
5 changed files with 75 additions and 9 deletions

View File

@ -745,6 +745,16 @@ export default class ClientConnection {
); );
} }
public async getUsbDevices() {
try {
return await this.doRpc<Protocol.GetUsbDevicesResponseEntity>(
new Protocol.GetUsbDevicesRequestEntity(0)
);
} catch (e) {
console.error(e);
}
}
public destory() { public destory() {
if (this.ws) { if (this.ws) {
this.ws.onclose = null; this.ws.onclose = null;

View File

@ -377,12 +377,6 @@ export default defineComponent({
value: "media", 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 = [ 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 { return {
show_dialog, show_dialog,
loading, loading,
@ -575,14 +594,17 @@ export default defineComponent({
refresh_file_list, refresh_file_list,
refresh_file_list_async, refresh_file_list_async,
status, status,
showDialog(in_status: string) { async showDialog(in_status: string) {
status.value = in_status; status.value = in_status;
refresh_usb_devices();
refresh_file_list(); refresh_file_list();
show_dialog.value = true; show_dialog.value = true;
}, },
showDialogAsync(in_status: string) { showDialogAsync(in_status: string) {
return new Promise((_resolve, _reject) => { return new Promise((_resolve, _reject) => {
status.value = in_status; status.value = in_status;
refresh_usb_devices();
refresh_file_list(); refresh_file_list();
show_dialog.value = true; show_dialog.value = true;
resolve = _resolve; resolve = _resolve;

View File

@ -982,7 +982,7 @@ export default defineComponent({
const request = new Protocol.SetSystemNetworkRequestEntity(); const request = new Protocol.SetSystemNetworkRequestEntity();
request.auto_ip = auto_ip.value == $t.t("enable"); request.auto_ip = auto_ip.value == $t.t("enable");
request.ip_address = ip_address.value; request.ip_address = ip_address.value;
request.gtateway = gateway.value; request.gateway = gateway.value;
request.net_mask = netmask.value; request.net_mask = netmask.value;
request.mac_address = mac_address.value; request.mac_address = mac_address.value;

View File

@ -293,6 +293,10 @@ export namespace Protocol {
return Commands.PROTOCOL_PREFIX + "RpcGetSystemTimes"; return Commands.PROTOCOL_PREFIX + "RpcGetSystemTimes";
} }
public static get kRpcGetUsbDevices() {
return Commands.PROTOCOL_PREFIX + "RpcGetUsbDevices";
}
static _all_commands = new Set([ static _all_commands = new Set([
Commands.kUnKnowCommand, Commands.kUnKnowCommand,
Commands.kSearchDevice, Commands.kSearchDevice,
@ -364,6 +368,7 @@ export namespace Protocol {
Commands.kDesktopResolutionChangedNotify, Commands.kDesktopResolutionChangedNotify,
Commands.kDesktopDisconnectNotify, Commands.kDesktopDisconnectNotify,
Commands.kRpcGetSystemTimes, Commands.kRpcGetSystemTimes,
Commands.kRpcGetUsbDevices,
]); ]);
public static get AllCommands() { public static get AllCommands() {
@ -1309,7 +1314,7 @@ export namespace Protocol {
export class SetSystemNetworkRequestEntity extends Protocol.PacketEntity { export class SetSystemNetworkRequestEntity extends Protocol.PacketEntity {
auto_ip: boolean = false; auto_ip: boolean = false;
ip_address: string = "192.168.1.68"; 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"; net_mask: string = "255.255.255.0";
mac_address: string = "04:D9:F5:D3:F4:C5"; mac_address: string = "04:D9:F5:D3:F4:C5";
@ -1705,4 +1710,23 @@ export namespace Protocol {
this.command = Commands.kRpcGetSystemTimes; 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;
}
}
} }

View File

@ -329,4 +329,14 @@ export default {
"server run time": "服务运行时间", "server run time": "服务运行时间",
"current server system time": "当前服务系统时间", "current server system time": "当前服务系统时间",
"server all run 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",
}; };