Skip to content

Commit

Permalink
Merge pull request #13 from Seeed-Studio/fix/test-question
Browse files Browse the repository at this point in the history
Fix/test question
  • Loading branch information
wutiange authored Jan 18, 2024
2 parents 36eb6b0 + 8b4baa7 commit 1e52726
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/pages/setup/process/components/Device.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<div class="device-item"> {{ $t('workplace.device.noconnect') }} </div>
</a-space>
<div v-else>
<template v-if="deviceStore.currentAvailableModel">
<template
v-if="
deviceStore.currentAvailableModel &&
deviceStore.deviceStatus === DeviceStatus.SerialConnected
"
>
<div class="device-basic-info">
<a-space class="device-item">
<div class="device-item-title">{{
Expand Down
21 changes: 16 additions & 5 deletions src/pages/setup/process/grove_ai_we2/Device.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@
await Promise.all([
device.value?.getName(),
device.value?.getVersion(),
device.value?.getInfo().then((base64Str) => {
if (!base64Str) return null;
const str = decode(base64Str);
return JSON.parse(str);
}),
retry(
() =>
device.value?.getInfo().then((base64Str) => {
if (!base64Str) return null;
try {
const str = decode(base64Str);
return JSON.parse(str);
} catch (error) {
console.error(error);
return null;
}
}),
5,
1000,
null
),
device.value?.getModel(),
device.value?.getID(),
]);
Expand Down
8 changes: 6 additions & 2 deletions src/pages/setup/process/xiao_esp32s3/Device.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
let model = null;
if (base64Str) {
const str = decode(base64Str);
model = JSON.parse(str);
try {
const str = decode(base64Str);
model = JSON.parse(str);
} catch (error) {
console.error(error);
}
}
deviceStore.setDeviceName(name);
deviceStore.setDeviceVersion(version);
Expand Down
5 changes: 1 addition & 4 deletions src/sscma/grove_ai_we2/deviceHimax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ class Himax extends Device {
// }
this.hasStart = false;
const tempCache = [...this.cacheData];
requestIdleCallback(() => {
this.parseAndProcessData(tempCache);
});
// this.parseAndProcessData(tempCache);
this.parseAndProcessData(tempCache);
this.cacheData = [];
} else if (this.hasStart) {
this.cacheData.push(num);
Expand Down
3 changes: 3 additions & 0 deletions src/utils/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export function delay(time: number, isReject = false) {
});
}

/**
* It should be noted that if the 'fn' function contains 'this', please use an arrow function.
*/
export async function retry(
fn: () => Promise<any>,
retryCount: number,
Expand Down

0 comments on commit 1e52726

Please sign in to comment.