diff --git a/src/locale/en-US/process.ts b/src/locale/en-US/process.ts index b00e6b2..8679c5d 100644 --- a/src/locale/en-US/process.ts +++ b/src/locale/en-US/process.ts @@ -99,7 +99,7 @@ export default { 'workplace.device.message.tip.connecting': 'Connecting', 'workplace.device.message.tip.downloading.firmware': 'Downloading firmware', 'workplace.device.message.tip.downloading.model': 'Downloading model', - 'workplace.device.message.tip.flashing': 'Flashing', + 'workplace.device.message.tip.flashing': 'Flashing, {progress}', 'workplace.device.message.tip.resetting': 'Resetting', 'workplace.device.message.tip.erasing': 'Erasing', 'workplace.firmware.eraseflash': 'Erase Device', diff --git a/src/locale/zh-CN/process.ts b/src/locale/zh-CN/process.ts index b04ffb7..8b48aea 100644 --- a/src/locale/zh-CN/process.ts +++ b/src/locale/zh-CN/process.ts @@ -91,7 +91,7 @@ export default { 'workplace.device.message.tip.connecting': '连接中', 'workplace.device.message.tip.downloading.firmware': '固件下载中', 'workplace.device.message.tip.downloading.model': '模型下载中', - 'workplace.device.message.tip.flashing': '烧录中', + 'workplace.device.message.tip.flashing': '烧录中,{progress}', 'workplace.device.message.tip.resetting': '重置中', 'workplace.device.message.tip.erasing': '擦除中', 'workplace.firmware.eraseflash': '擦除设备', diff --git a/src/pages/setup/process/components/Device.vue b/src/pages/setup/process/components/Device.vue index 12601fb..37949ea 100644 --- a/src/pages/setup/process/components/Device.vue +++ b/src/pages/setup/process/components/Device.vue @@ -496,7 +496,10 @@ } } } - loadingTip.value = t('workplace.device.message.tip.flashing'); + deviceStore.setFlashProgress('0%'); + loadingTip.value = t('workplace.device.message.tip.flashing', { + progress: deviceStore.flashProgress, + }); deviceStore.setDeviceStatus(DeviceStatus.Flashing); const result = await props.flasher.onWriteFlash(fileArray); if (result) { @@ -655,6 +658,17 @@ router.push('/setup/config'); }; + watch( + () => deviceStore.flashProgress, + () => { + if (deviceStore.deviceStatus === DeviceStatus.Flashing) { + loadingTip.value = t('workplace.device.message.tip.flashing', { + progress: deviceStore.flashProgress, + }); + } + } + ); + watch( () => deviceStore.currentModel, (model?: Model | null) => { diff --git a/src/sscma/grove_ai_we2/deviceHimax.ts b/src/sscma/grove_ai_we2/deviceHimax.ts index 941cc66..d329bfa 100644 --- a/src/sscma/grove_ai_we2/deviceHimax.ts +++ b/src/sscma/grove_ai_we2/deviceHimax.ts @@ -120,6 +120,7 @@ class Himax extends Device { const xmodem = new Xmodem({}); const progress = (current: number, total: number, percent: number) => { console.log(`progress ${current}/${total} ${percent}%`); + this.deviceStore.setFlashProgress(`${percent}%`); }; if (!this.serial) { return; diff --git a/src/sscma/xiao_esp32s3/Flasher.ts b/src/sscma/xiao_esp32s3/Flasher.ts index 4510836..ab2793d 100644 --- a/src/sscma/xiao_esp32s3/Flasher.ts +++ b/src/sscma/xiao_esp32s3/Flasher.ts @@ -56,6 +56,9 @@ class Flasher implements FlasherInterface { compress: true, reportProgress: (fileIndex, written, total) => { console.log('written ', fileIndex, ' file:', (written / total) * 100); + this.deviceStore.setFlashProgress( + `${Math.floor((written / total) * 100)}%` + ); }, } as FlashOptions; await this.espLoader?.write_flash(flashOptions); diff --git a/src/store/modules/device/index.ts b/src/store/modules/device/index.ts index 7b0c8a8..cf12cb3 100644 --- a/src/store/modules/device/index.ts +++ b/src/store/modules/device/index.ts @@ -56,6 +56,7 @@ const useDeviceStore = defineStore('device', { currentAvailableModel: false, comeToSenseCraftAI: {} as ComeToSenseCraftAIType, flashWay: FlashWayType.Prefabricated, + flashProgress: '0%', }), persist: { enabled: true, @@ -140,6 +141,9 @@ const useDeviceStore = defineStore('device', { setIsCanMqtt(isCanMqtt: boolean) { this.isCanMqtt = isCanMqtt; }, + setFlashProgress(progress: string) { + this.flashProgress = progress; + }, clearDeviceInfo() { this.deviceName = null;