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 @@