diff --git a/src/components/Oscilloscope/OscilloscopeManager.ts b/src/components/Oscilloscope/OscilloscopeManager.ts index 821e82d..5b3cee3 100644 --- a/src/components/Oscilloscope/OscilloscopeManager.ts +++ b/src/components/Oscilloscope/OscilloscopeManager.ts @@ -1,4 +1,4 @@ -import { createInjectionState } from "@vueuse/core"; +import { autoResetRef, createInjectionState } from "@vueuse/core"; import { shallowRef, reactive, ref, computed } from "vue"; import { Mutex } from "async-mutex"; import { @@ -83,6 +83,10 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() = alert.info("配置已重置", 2000); }; + const clearOscilloscopeData = () => { + oscData.value = undefined; + } + // 获取数据 const getOscilloscopeData = async () => { try { @@ -173,6 +177,7 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() = return; } isCapturing.value = false; + stopAutoRefresh(); const release = await operationMutex.acquire(); try { const client = AuthManager.createAuthenticatedOscilloscopeApiClient(); @@ -181,7 +186,6 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() = alert.info("捕获已停止", 2000); } catch (error) { alert.error("停止捕获失败", 3000); - isCapturing.value = true; } finally { release(); } @@ -274,6 +278,7 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() = applyConfiguration, resetConfiguration, + clearOscilloscopeData, getOscilloscopeData, startCapture, stopCapture, diff --git a/src/components/Oscilloscope/OscilloscopeWaveformDisplay.vue b/src/components/Oscilloscope/OscilloscopeWaveformDisplay.vue index e0264ea..4c4b801 100644 --- a/src/components/Oscilloscope/OscilloscopeWaveformDisplay.vue +++ b/src/components/Oscilloscope/OscilloscopeWaveformDisplay.vue @@ -2,10 +2,7 @@
-
+
暂无数据
@@ -16,13 +13,11 @@ !oscManager.isCapturing.value, 'from-red-500 to-red-600 hover:from-red-600 hover:to-red-700 focus:ring-red-300': oscManager.isCapturing.value, - }" - @click=" + }" @click=" oscManager.isCapturing.value ? oscManager.stopCapture() : oscManager.startCapture() - " - > + ">