Skip to content

Commit

Permalink
Give feedback for failure on reading chip-id and flash-id
Browse files Browse the repository at this point in the history
Signed-off-by: xychen <xychen@listenai.com>
  • Loading branch information
xychen committed May 8, 2024
1 parent d1ac5c5 commit 8b3c489
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
</n-flex>

<n-flex align="center">
<n-element :class="$style.info" :style="{ width: '16em' }">
<n-skeleton v-if="busyForInfo" width="16em" />
<n-element v-else :class="$style.info" :style="{ width: '16em' }">
Chip ID: <selectable-text selectable>{{ chipId || 'N/A' }}</selectable-text>
</n-element>
<n-element :class="$style.info" :style="{ width: '16em' }">
<n-skeleton v-if="busyForInfo" width="16em" />
<n-element v-else :class="$style.info" :style="{ width: '16em' }">
Flash ID: <selectable-text selectable>{{ flashInfo || 'N/A' }}</selectable-text>
</n-element>
<n-button secondary size="small" :disabled="selectedPort == null || busyForFlash" :loading="busyForInfo"
@click="fetchInfo">
:style="{ width: '6em' }" @click="fetchInfo">
获取
</n-button>
</n-flex>
Expand Down Expand Up @@ -75,8 +77,10 @@ import {
NFlex,
NInput,
NProgress,
NSkeleton,
NSpin,
NText,
useMessage,
} from 'naive-ui';
import { imageSize, type IFlashImage } from '@/utils/images';
import { cskburn } from '@/utils/cskburn';
Expand Down Expand Up @@ -116,12 +120,14 @@ const busyForFlash = computed(() => status.value == FlashStatus.CONNECTING || st
const readyToFlash = computed(() => selectedPort.value != null && image.value != null && !hasError.value);
const message = useMessage();
async function fetchInfo(): Promise<void> {
chipId.value = null;
flashId.value = null;
flashSize.value = null;
await busyOn(cskburn(selectedPort.value!, 1500000, [], {
const result = await busyOn(cskburn(selectedPort.value!, 1500000, [], {
onChipId(id) {
chipId.value = id;
},
Expand All @@ -130,6 +136,10 @@ async function fetchInfo(): Promise<void> {
flashSize.value = size;
},
}), busyForInfo);
if (result.code != 0) {
message.error('获取信息失败');
}
}
const errors = computed(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/AppWindow.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<n-config-provider :theme="darkMode ? darkTheme : null">
<n-dialog-provider>
<App />
<n-message-provider>
<App />
</n-message-provider>
</n-dialog-provider>
<n-global-style />
</n-config-provider>
Expand All @@ -13,6 +15,7 @@ import {
NConfigProvider,
NDialogProvider,
NGlobalStyle,
NMessageProvider,
darkTheme,
useOsTheme,
} from 'naive-ui';
Expand Down

0 comments on commit 8b3c489

Please sign in to comment.