只显示插入的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() {
if (this.ws) {
this.ws.onclose = null;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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",
};