From 39465a273f4a404d23019a182d519180e273826c Mon Sep 17 00:00:00 2001 From: guoapeng Date: Sat, 22 Mar 2025 21:57:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=96=B7=E6=B6=82=E7=BB=98=E5=88=B6?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint.config.js | 1 + src/components/common/FTButton/index.vue | 2 - src/components/spray/trayGraph/index.vue | 8 +- src/libs/socket.ts | 12 ++ src/stores/useSystemStore.ts | 2 +- src/views/spray/index.vue | 260 +++++++++++++++++++++++++++---- tsconfig.json | 1 + vite.config.ts | 2 +- 8 files changed, 250 insertions(+), 38 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 23803f2..6304f0a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -15,4 +15,5 @@ export default lintConfig({ 'ts/no-use-before-define': 0, 'no-alert': 0, }, + globals: { process: 'readonly' }, }) diff --git a/src/components/common/FTButton/index.vue b/src/components/common/FTButton/index.vue index 5ed5162..8ccabb1 100644 --- a/src/components/common/FTButton/index.vue +++ b/src/components/common/FTButton/index.vue @@ -23,10 +23,8 @@ const props = defineProps({ const isLoading = ref(false) async function handleClick() { - console.log(props.clickHandle) if (!props.clickHandle || isLoading.value) return - console.log(32452353) isLoading.value = true // 进入 loading try { await props.clickHandle() // 执行异步操作 diff --git a/src/components/spray/trayGraph/index.vue b/src/components/spray/trayGraph/index.vue index 09c7034..075a80d 100644 --- a/src/components/spray/trayGraph/index.vue +++ b/src/components/spray/trayGraph/index.vue @@ -168,11 +168,15 @@ const addLine = (stroke: string = 'green') => { layer.value.draw() } -const updateLine = (point: { x: number, y: number }, index: number) => { +const updateLine = (point: { x: number, y: number }, index: number, stroke: string = 'green') => { if (lines.value.length === 0) { return } - const currentLine = lines.value[index] // 修改: 获取最后一条线条 + + if (!lines.value[index]) { + addLine(stroke) + } + const currentLine = lines.value[index] currentLine.points([...currentLine.points(), point.x, point.y]) currentLine.getLayer()!.batchDraw() // 批量重绘提升性能 } diff --git a/src/libs/socket.ts b/src/libs/socket.ts index b264d13..4b309ab 100644 --- a/src/libs/socket.ts +++ b/src/libs/socket.ts @@ -28,6 +28,8 @@ interface socket { // eslint-disable-next-line ts/no-unsafe-function-type registerCallback: Function // eslint-disable-next-line ts/no-unsafe-function-type + unregisterCallback: Function + // eslint-disable-next-line ts/no-unsafe-function-type registerInitCallback: Function // eslint-disable-next-line ts/no-unsafe-function-type init: (receiveMessage?: Function | null, type?: string, connectURL?: string) => any @@ -95,6 +97,16 @@ export const socket: socket = { socket.receiveMessageCallBackObj[type].push(fn) }, + // 添加 unregisterCallback 方法 + unregisterCallback: (fn: any, type: any) => { + if (socket.receiveMessageCallBackObj[type]) { + const index = socket.receiveMessageCallBackObj[type].indexOf(fn) + if (index !== -1) { + socket.receiveMessageCallBackObj[type].splice(index, 1) + } + } + }, + init: async ( receiveMessageCallBack: any, type?: string, diff --git a/src/stores/useSystemStore.ts b/src/stores/useSystemStore.ts index 51d0c69..8ecdec6 100644 --- a/src/stores/useSystemStore.ts +++ b/src/stores/useSystemStore.ts @@ -16,7 +16,7 @@ export const useSystemStore = defineStore('system', { systemSensor: { humidity: 0, }, - isDebug: false, + isDebug: import.meta.env.FT_NODE_ENV === 'dev', streamVisible: false, systemList: [{ cmdCode: '' }], targetHumidity: 0, diff --git a/src/views/spray/index.vue b/src/views/spray/index.vue index 1630179..0129cbd 100644 --- a/src/views/spray/index.vue +++ b/src/views/spray/index.vue @@ -1,7 +1,6 @@