fea: 前端完成动态ip与动态mac的适配
This commit is contained in:
@@ -74,8 +74,6 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
// 新增板卡(管理员权限)
|
||||
async function addBoard(
|
||||
name: string,
|
||||
ipAddr: string,
|
||||
port: number,
|
||||
): Promise<{ success: boolean; error?: string; boardId?: string }> {
|
||||
try {
|
||||
// 验证管理员权限
|
||||
@@ -86,19 +84,19 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
}
|
||||
|
||||
// 验证输入参数
|
||||
if (!name || !ipAddr || !port) {
|
||||
console.error("参数验证失败", { name, ipAddr, port });
|
||||
if (!name) {
|
||||
console.error("参数验证失败", { name });
|
||||
return { success: false, error: "参数不完整" };
|
||||
}
|
||||
|
||||
const client = AuthManager.createAuthenticatedDataClient();
|
||||
const boardId = await client.addBoard(name, ipAddr, port);
|
||||
const boardId = await client.addBoard(name);
|
||||
|
||||
if (boardId) {
|
||||
console.log("新增板卡成功", { boardId, name, ipAddr, port });
|
||||
console.log("新增板卡成功", { boardId, name});
|
||||
// 刷新板卡列表
|
||||
await getAllBoards();
|
||||
return { success: true};
|
||||
return { success: true };
|
||||
} else {
|
||||
console.error("新增板卡失败:返回ID为空");
|
||||
return { success: false, error: "新增板卡失败" };
|
||||
@@ -116,7 +114,9 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
}
|
||||
|
||||
// 删除板卡(管理员权限)
|
||||
async function deleteBoard(boardId: string): Promise<{ success: boolean; error?: string }> {
|
||||
async function deleteBoard(
|
||||
boardId: string,
|
||||
): Promise<{ success: boolean; error?: string }> {
|
||||
try {
|
||||
// 验证管理员权限
|
||||
const hasAdminAuth = await AuthManager.verifyAdminAuth();
|
||||
@@ -167,7 +167,7 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
if (!isUndefined(appBitstream1)) cnt++;
|
||||
if (!isUndefined(appBitstream2)) cnt++;
|
||||
if (!isUndefined(appBitstream3)) cnt++;
|
||||
|
||||
|
||||
if (cnt === 0) {
|
||||
console.error("未选择比特流文件");
|
||||
return { success: false, error: "未选择比特流文件" };
|
||||
@@ -175,7 +175,7 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
|
||||
try {
|
||||
console.log("开始上传比特流", { boardIp: board.ipAddr, fileCount: cnt });
|
||||
|
||||
|
||||
const uploadResult = await remoteUpdater.uploadBitstreams(
|
||||
board.ipAddr,
|
||||
toFileParameterOrNull(goldBitstream),
|
||||
@@ -198,7 +198,10 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
);
|
||||
|
||||
if (downloadResult != cnt) {
|
||||
console.error("固化比特流失败", { expected: cnt, actual: downloadResult });
|
||||
console.error("固化比特流失败", {
|
||||
expected: cnt,
|
||||
actual: downloadResult,
|
||||
});
|
||||
return { success: false, error: "固化比特流失败" };
|
||||
} else {
|
||||
console.log("固化比特流成功", { count: downloadResult });
|
||||
@@ -212,18 +215,18 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
|
||||
// 热启动位流
|
||||
async function hotresetBitstream(
|
||||
board: BoardData,
|
||||
bitstreamNum: number
|
||||
board: BoardData,
|
||||
bitstreamNum: number,
|
||||
): Promise<{ success: boolean; error?: string }> {
|
||||
try {
|
||||
console.log("开始热启动比特流", { boardIp: board.ipAddr, bitstreamNum });
|
||||
|
||||
|
||||
const ret = await remoteUpdater.hotResetBitstream(
|
||||
board.ipAddr,
|
||||
board.port,
|
||||
bitstreamNum,
|
||||
);
|
||||
|
||||
|
||||
if (ret) {
|
||||
console.log("热启动比特流成功");
|
||||
return { success: true };
|
||||
@@ -253,7 +256,11 @@ const [useProvideBoardManager, useBoardManager] = createInjectionState(() => {
|
||||
const file = target.files?.[0];
|
||||
if (file) {
|
||||
(board as any)[fileKey] = file;
|
||||
console.log(`文件选择成功`, { boardIp: board.ipAddr, fileKey, fileName: file.name });
|
||||
console.log(`文件选择成功`, {
|
||||
boardIp: board.ipAddr,
|
||||
fileKey,
|
||||
fileName: file.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user