fix: frontend upload bitstream failed
This commit is contained in:
@@ -44,7 +44,8 @@
|
||||
import { JtagClient, type FileParameter } from "@/APIClient";
|
||||
import UploadCard from "@/components/UploadCard.vue";
|
||||
import { useDialogStore } from "@/stores/dialog";
|
||||
import { toNumber } from "lodash";
|
||||
import { Common } from "@/Common";
|
||||
import { toNumber, isUndefined } from "lodash";
|
||||
import { ref } from "vue";
|
||||
|
||||
const jtagController = new JtagClient();
|
||||
@@ -54,39 +55,30 @@ const dialog = useDialogStore();
|
||||
const boardAddress = ref("127.0.0.1"); // 默认IP地址
|
||||
const boardPort = ref("1234"); // 默认端口号
|
||||
|
||||
async function uploadBitstream(event: Event, bitstream: File) {
|
||||
if (boardAddress.value.length == 0) {
|
||||
dialog.error("开发板地址空缺");
|
||||
return;
|
||||
}
|
||||
if (boardPort.value.length == 0) {
|
||||
dialog.error("开发板端口空缺");
|
||||
return;
|
||||
async function uploadBitstream(bitstream: File): Promise<boolean> {
|
||||
if (isUndefined(boardAddress.value) || isUndefined(boardPort.value)) {
|
||||
dialog.error("开发板地址或端口空缺");
|
||||
return false;
|
||||
}
|
||||
|
||||
const fileParam: FileParameter = {
|
||||
data: bitstream,
|
||||
fileName: bitstream.name,
|
||||
};
|
||||
try {
|
||||
console.debug(`Before upload bistream: ${bitstream}`);
|
||||
const resp = await jtagController.uploadBitstream(
|
||||
boardAddress.value,
|
||||
fileParam,
|
||||
Common.toFileParameterOrNull(bitstream),
|
||||
);
|
||||
return resp
|
||||
return resp;
|
||||
} catch (e) {
|
||||
dialog.error("上传错误");
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadBitstream() {
|
||||
if (boardAddress.value.length == 0) {
|
||||
dialog.error("开发板地址空缺");
|
||||
return;
|
||||
}
|
||||
if (boardPort.value.length == 0) {
|
||||
dialog.error("开发板端口空缺");
|
||||
return;
|
||||
async function downloadBitstream(): Promise<boolean> {
|
||||
if (isUndefined(boardAddress.value) || isUndefined(boardPort.value)) {
|
||||
dialog.error("开发板地址或端口空缺");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -98,6 +90,7 @@ async function downloadBitstream() {
|
||||
} catch (e) {
|
||||
dialog.error("上传错误");
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user