增加烧录报错时的提示
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "bdqh-course-platform",
|
"name": "bdqh-course-platform",
|
||||||
"version": "3.4.4",
|
"version": "3.4.4",
|
||||||
"description": "北斗启航学习机课程平台",
|
"description": "串口配置工具",
|
||||||
"main": "./dist/main/app.js",
|
"main": "./dist/main/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"electron": "^22.0.0",
|
"electron": "^22.0.0",
|
||||||
"electron-builder": "^23.6.0",
|
"electron-builder": "^23.6.0",
|
||||||
"electron-rebuild": "3.2.9",
|
|
||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
|
|||||||
@@ -261,7 +261,8 @@ export class MainWindow extends LocalSoftwareWindow {
|
|||||||
'0x10000', bin_file_path,
|
'0x10000', bin_file_path,
|
||||||
'0x8000' , PARTITIONS_BIN_PATH], (err:any, stdout:any) => {
|
'0x8000' , PARTITIONS_BIN_PATH], (err:any, stdout:any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
event.sender.send('BURN_PROGRAM_FEEDBACK', { err } )
|
// event.sender.send('BURN_PROGRAM_FEEDBACK', { err } )
|
||||||
|
event.sender.send('BURN_PROGRAM_FEEDBACK', { err: new Error('请确保核心处理模块上未连接其他模块后重新尝试烧录') } )
|
||||||
} else {
|
} else {
|
||||||
event.sender.send('BURN_PROGRAM_FEEDBACK', { stdout })
|
event.sender.send('BURN_PROGRAM_FEEDBACK', { stdout })
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/render/utils/debounce.ts
Normal file
11
src/render/utils/debounce.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export const debounce = (fn: Function, delay: number) => {
|
||||||
|
let timeoutID: any = null;
|
||||||
|
return function () {
|
||||||
|
clearTimeout(timeoutID); // 如果之前设置了定时器,则清除
|
||||||
|
const args = arguments; // 保存当前函数的参数
|
||||||
|
const that = this; // 保存当前函数的上下文
|
||||||
|
timeoutID = setTimeout(function () {
|
||||||
|
fn.apply(that, args); // 延迟执行原函数,并传入保存的参数和上下文
|
||||||
|
}, delay);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
size="huge">
|
size="huge">
|
||||||
|
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button v-for="program, index in programs" :key="index" size="large" @click="onBurnProgramBtnClick(program.filePath)">{{ program.name }}</n-button>
|
<n-button v-for="program, index in programs" :key="index" size="large" @click="debounce(onBurnProgramBtnClick(program.filePath), 3000)">{{ program.name }}</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
|
|
||||||
</n-modal>
|
</n-modal>
|
||||||
@@ -19,23 +19,26 @@ import { h, ref, onMounted } from 'vue'
|
|||||||
import { NModal, NSpace, NButton, NSpin, NH3, useMessage, useDialog } from 'naive-ui'
|
import { NModal, NSpace, NButton, NSpin, NH3, useMessage, useDialog } from 'naive-ui'
|
||||||
import { findAllCommon } from '@/api/program'
|
import { findAllCommon } from '@/api/program'
|
||||||
import { hasIpcRenderer } from '@/utils'
|
import { hasIpcRenderer } from '@/utils'
|
||||||
|
import { debounce } from '@/utils/debounce'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
|
|
||||||
const programs = findAllCommon()
|
const programs = findAllCommon()
|
||||||
|
|
||||||
|
let burnSwitch = true
|
||||||
|
|
||||||
// TODO:烧录程序的逻辑提取到开发板(DeveloperBoard)类中
|
// TODO:烧录程序的逻辑提取到开发板(DeveloperBoard)类中
|
||||||
const onBurnProgramBtnClick = async (binFileName: string) => {
|
const onBurnProgramBtnClick = async (binFileName: string) => {
|
||||||
if (!hasIpcRenderer()) return
|
if (!hasIpcRenderer() || !burnSwitch) return
|
||||||
|
|
||||||
if (!('serial' in navigator)) return
|
if (!('serial' in navigator)) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// await navigator.serial.requestPort()
|
// await navigator.serial.requestPort()
|
||||||
|
|
||||||
|
burnSwitch = false
|
||||||
window.ipcRenderer.send('BURN_PROGRAM', binFileName)
|
window.ipcRenderer.send('BURN_PROGRAM', binFileName)
|
||||||
|
|
||||||
|
|
||||||
dialog.info({
|
dialog.info({
|
||||||
title: '系统提示',
|
title: '系统提示',
|
||||||
@@ -61,8 +64,14 @@ const onBurnProgramBtnClick = async (binFileName: string) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
message.error('程序烧录失败')
|
message.error('程序烧录失败')
|
||||||
|
setTimeout(() => {
|
||||||
|
burnSwitch = true
|
||||||
|
}, 3000)
|
||||||
} finally {
|
} finally {
|
||||||
dialog.destroyAll()
|
dialog.destroyAll()
|
||||||
|
setTimeout(() => {
|
||||||
|
burnSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +83,10 @@ const onBurnProgramFeedback = ({ err }) => {
|
|||||||
} else {
|
} else {
|
||||||
message.success('程序烧录成功')
|
message.success('程序烧录成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
burnSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
常用工具
|
常用工具
|
||||||
</n-divider>
|
</n-divider>
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button size="large" strong secondary type="primary" @click="onSystemRepairButtonClick">系统修复</n-button>
|
<n-button size="large" strong secondary type="primary" @click="debounce(onSystemRepairButtonClick(), 3000)">系统修复</n-button>
|
||||||
<n-button size="large" strong secondary type="primary" @click="onSoftwareUpgradeButtonClick">软件升级</n-button>
|
<n-button size="large" strong secondary type="primary" @click="debounce(onSoftwareUpgradeButtonClick(), 3000)">软件升级</n-button>
|
||||||
<n-button size="large" strong secondary type="primary" @click="onWirelessCommunicationModuleConfigButtonClick">通信模块配置</n-button>
|
<n-button size="large" strong secondary type="primary" @click="debounce(onWirelessCommunicationModuleConfigButtonClick(), 3000)">通信模块配置</n-button>
|
||||||
<!-- TODO: 添加无线投屏功能 -->
|
<!-- TODO: 添加无线投屏功能 -->
|
||||||
</n-space>
|
</n-space>
|
||||||
</template>
|
</template>
|
||||||
@@ -13,33 +13,50 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NDivider, NSpace, NButton, useMessage } from 'naive-ui'
|
import { NDivider, NSpace, NButton, useMessage } from 'naive-ui'
|
||||||
import { hasIpcRenderer } from '@/utils'
|
import { hasIpcRenderer } from '@/utils'
|
||||||
|
import { debounce } from '@/utils/debounce'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
|
let repairSwitch = true
|
||||||
|
let upgradeSwitch = true
|
||||||
|
let wirelessSwitch = true
|
||||||
|
|
||||||
const onSystemRepairButtonClick = () => {
|
const onSystemRepairButtonClick = () => {
|
||||||
if (!hasIpcRenderer()) return
|
if (!hasIpcRenderer() || !repairSwitch) return
|
||||||
|
repairSwitch = false
|
||||||
const result = window.ipcRenderer.sendSync('SYSTEM_REPAIR')
|
const result = window.ipcRenderer.sendSync('SYSTEM_REPAIR')
|
||||||
if (result != 'OK') {
|
if (result != 'OK') {
|
||||||
message.error(result.message)
|
message.error(result.message)
|
||||||
} else {
|
} else {
|
||||||
message.success('系统修复成功')
|
message.success('系统修复成功')
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
repairSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSoftwareUpgradeButtonClick = () => {
|
const onSoftwareUpgradeButtonClick = () => {
|
||||||
if (!hasIpcRenderer()) return
|
if (!hasIpcRenderer() || !upgradeSwitch) return
|
||||||
|
upgradeSwitch = false
|
||||||
const result = window.ipcRenderer.sendSync('SOFTWARE_UPGRADE')
|
const result = window.ipcRenderer.sendSync('SOFTWARE_UPGRADE')
|
||||||
if (result != 'OK') {
|
if (result != 'OK') {
|
||||||
message.error(result.message)
|
message.error(result.message)
|
||||||
} else {
|
} else {
|
||||||
message.success('软件升级成功')
|
message.success('软件升级成功')
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
upgradeSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
const onWirelessCommunicationModuleConfigButtonClick = () => {
|
const onWirelessCommunicationModuleConfigButtonClick = () => {
|
||||||
if (hasIpcRenderer()) window.ipcRenderer.send('LAUNCH_LOCAL_SOFTWARE', {
|
if (hasIpcRenderer() && wirelessSwitch) {
|
||||||
subWindowName: 'WirelessCommunicationModuleConfigurationWindow'
|
wirelessSwitch = false
|
||||||
})
|
window.ipcRenderer.send('LAUNCH_LOCAL_SOFTWARE', {
|
||||||
|
subWindowName: 'WirelessCommunicationModuleConfigurationWindow'
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
wirelessSwitch = true
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<n-h2>程序烧录</n-h2>
|
<n-h2>程序烧录</n-h2>
|
||||||
<n-space vertical align="center" :wrap-item="false">
|
<n-space vertical align="center" :wrap-item="false">
|
||||||
<n-button v-for="program, index in programs" :key="index" :bordered="false" size="large" @click="onBurnProgramBtnClick(program.filePath)">{{ program.name }}</n-button>
|
<n-button v-for="program, index in programs" :key="index" :bordered="false" size="large" @click="debounce(onBurnProgramBtnClick(program.filePath), 3000)">{{ program.name }}</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
import { h, onMounted, onUnmounted } from 'vue'
|
import { h, onMounted, onUnmounted } from 'vue'
|
||||||
import { NH2, NSpace, NButton, NSpin, NH3, useMessage, useDialog } from 'naive-ui'
|
import { NH2, NSpace, NButton, NSpin, NH3, useMessage, useDialog } from 'naive-ui'
|
||||||
import { hasIpcRenderer } from '@/utils'
|
import { hasIpcRenderer } from '@/utils'
|
||||||
|
import { debounce } from '@/utils/debounce'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
programs: Array<string>
|
programs: Array<string>
|
||||||
@@ -20,20 +21,23 @@ defineProps({
|
|||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
let burnSwitch = true
|
||||||
|
|
||||||
const onBurnProgramBtnClick = async (binFileName: string) => {
|
const onBurnProgramBtnClick = async (binFileName: string) => {
|
||||||
if (!hasIpcRenderer()) return
|
if (!hasIpcRenderer() || !burnSwitch) return
|
||||||
|
|
||||||
if (!('serial' in navigator)) return
|
if (!('serial' in navigator)) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// await navigator.serial.requestPort()
|
// await navigator.serial.requestPort()
|
||||||
|
|
||||||
|
burnSwitch = false
|
||||||
window.ipcRenderer.send('BURN_PROGRAM', binFileName)
|
window.ipcRenderer.send('BURN_PROGRAM', binFileName)
|
||||||
|
|
||||||
dialog.info({
|
dialog.info({
|
||||||
title: '系统提示',
|
title: '系统提示',
|
||||||
closable: false,
|
closable: true,
|
||||||
maskClosable: false,
|
maskClosable: true,
|
||||||
class: 'text-center',
|
class: 'text-center',
|
||||||
content: () => h(
|
content: () => h(
|
||||||
NSpin,
|
NSpin,
|
||||||
@@ -55,6 +59,9 @@ const onBurnProgramBtnClick = async (binFileName: string) => {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
message.error('程序烧录失败')
|
message.error('程序烧录失败')
|
||||||
dialog.destroyAll()
|
dialog.destroyAll()
|
||||||
|
setTimeout(() => {
|
||||||
|
burnSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +73,10 @@ const onBurnProgramFeedback = ({ err }) => {
|
|||||||
} else {
|
} else {
|
||||||
message.success('程序烧录成功')
|
message.success('程序烧录成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
burnSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<n-h2>配套软件</n-h2>
|
<n-h2>配套软件</n-h2>
|
||||||
|
|
||||||
<n-space vertical align="center" :wrap-item="false">
|
<n-space vertical align="center" :wrap-item="false">
|
||||||
<n-button v-for="software in softwares" :bordered="false" size="large" @click="onBtnClick(software.command, software.params)">{{ software.name }}</n-button>
|
<n-button v-for="software in softwares" :bordered="false" size="large" @click="debounce(onBtnClick(software.command, software.params), 3000)">{{ software.name }}</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -13,14 +13,21 @@
|
|||||||
import { NH2, NSpace, NButton } from 'naive-ui'
|
import { NH2, NSpace, NButton } from 'naive-ui'
|
||||||
import { Software } from '@/api/course/type.d'
|
import { Software } from '@/api/course/type.d'
|
||||||
import { hasIpcRenderer } from '@/utils'
|
import { hasIpcRenderer } from '@/utils'
|
||||||
|
import { debounce } from '@/utils/debounce'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
softwares: Array<Software>
|
softwares: Array<Software>
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let wirelessSwitch = true
|
||||||
|
|
||||||
const onBtnClick = (command: String, params: Object) => {
|
const onBtnClick = (command: String, params: Object) => {
|
||||||
if (hasIpcRenderer()) {
|
if (hasIpcRenderer() && wirelessSwitch) {
|
||||||
|
wirelessSwitch = false
|
||||||
window.ipcRenderer.send(command, params)
|
window.ipcRenderer.send(command, params)
|
||||||
|
setTimeout(() => {
|
||||||
|
wirelessSwitch = true
|
||||||
|
}, 3000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user