diff --git a/src/components/navbar/index.vue b/src/components/navbar/index.vue index 18d82bd..aa4c88f 100644 --- a/src/components/navbar/index.vue +++ b/src/components/navbar/index.vue @@ -89,7 +89,7 @@ {{ $t('workplace.device.btn.disconnect') }} - {{ $t('workplace.device.btn.connect') + {{ $t('workplace.device.btn.connect') }} diff --git a/src/senseCraft/serial.ts b/src/senseCraft/serial.ts index 62883d4..3ef201b 100644 --- a/src/senseCraft/serial.ts +++ b/src/senseCraft/serial.ts @@ -53,7 +53,7 @@ export default class Serial extends Device { } // 如果当前在esp连接,需要断开 if ( - this.deviceStore.deviceStatus === DeviceStatus.EspConnected && + (this.deviceStore.deviceStatus === DeviceStatus.EspConnected || this.deviceStore.deviceStatus === DeviceStatus.Burning) && this.transport ) { await this.transport.disconnect(); diff --git a/src/views/setup/process/components/device.vue b/src/views/setup/process/components/device.vue index 33afd8e..01a3d18 100644 --- a/src/views/setup/process/components/device.vue +++ b/src/views/setup/process/components/device.vue @@ -38,13 +38,15 @@ + :class="['carousel-item', { 'carousel-item-selected': selectedModel === index && !isSelectedCustomModel }]" + :key="index" :onclick="() => handleSelectedModel(index)" :virtualIndex="index"> -
+
{{ deviceStore.currentModel?.name }}
@@ -145,6 +147,7 @@ const espLoaderTerminal = { const loading = ref(false); const loadingTip = ref(''); const selectedModel = ref(-1); +const isSelectedCustomModel = ref(false); const deviceName: Ref = ref(''); const deviceVersion: Ref = ref(''); @@ -307,9 +310,26 @@ const burnFirmware = async (isCustom = false) => { const handleSelectedModel = (index: number) => { selectedModel.value = index; + isSelectedCustomModel.value = false; +} + +const handleSelectedCustomModel = () => { + selectedModel.value = -1; + isSelectedCustomModel.value = true; } const handleUpload = async () => { + if (isSelectedCustomModel.value) { + Message.info('The device is running the current model'); + return + } + if (selectedModel.value > -1) { + const model = deviceStore.models[selectedModel.value]; + if (model.uuid === deviceStore.currentModel?.uuid) { + Message.info('The device is running the current model'); + return + } + } try { burnFirmware() } catch (error) { @@ -433,6 +453,20 @@ watch( handelRefresh(val); } ); + +watch( + () => deviceStore.currentModel, + (currentModel) => { + if (currentModel?.isCustom) { + isSelectedCustomModel.value = currentModel?.isCustom + } else { + const index = deviceStore.models.findIndex((model) => { + return model.uuid === currentModel?.uuid + }) + selectedModel.value = index + } + } +);