fix: 修改ui,并修复bug

This commit is contained in:
SikongJueluo 2025-07-22 02:28:39 +08:00
parent 5804863af7
commit 1ce12120a0
3 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import { createInjectionState } from "@vueuse/core"; import { autoResetRef, createInjectionState } from "@vueuse/core";
import { shallowRef, reactive, ref, computed } from "vue"; import { shallowRef, reactive, ref, computed } from "vue";
import { Mutex } from "async-mutex"; import { Mutex } from "async-mutex";
import { import {
@ -83,6 +83,10 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() =
alert.info("配置已重置", 2000); alert.info("配置已重置", 2000);
}; };
const clearOscilloscopeData = () => {
oscData.value = undefined;
}
// 获取数据 // 获取数据
const getOscilloscopeData = async () => { const getOscilloscopeData = async () => {
try { try {
@ -173,6 +177,7 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() =
return; return;
} }
isCapturing.value = false; isCapturing.value = false;
stopAutoRefresh();
const release = await operationMutex.acquire(); const release = await operationMutex.acquire();
try { try {
const client = AuthManager.createAuthenticatedOscilloscopeApiClient(); const client = AuthManager.createAuthenticatedOscilloscopeApiClient();
@ -181,7 +186,6 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() =
alert.info("捕获已停止", 2000); alert.info("捕获已停止", 2000);
} catch (error) { } catch (error) {
alert.error("停止捕获失败", 3000); alert.error("停止捕获失败", 3000);
isCapturing.value = true;
} finally { } finally {
release(); release();
} }
@ -274,6 +278,7 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(() =
applyConfiguration, applyConfiguration,
resetConfiguration, resetConfiguration,
clearOscilloscopeData,
getOscilloscopeData, getOscilloscopeData,
startCapture, startCapture,
stopCapture, stopCapture,

View File

@ -2,10 +2,7 @@
<div class="w-full h-100 flex flex-col"> <div class="w-full h-100 flex flex-col">
<!-- 原有内容 --> <!-- 原有内容 -->
<v-chart v-if="hasData" class="w-full h-full" :option="option" autoresize /> <v-chart v-if="hasData" class="w-full h-full" :option="option" autoresize />
<div <div v-else class="w-full h-full flex flex-col gap-4 items-center justify-center text-gray-500">
v-else
class="w-full h-full flex flex-col gap-4 items-center justify-center text-gray-500"
>
<span> 暂无数据 </span> <span> 暂无数据 </span>
<!-- 采集控制按钮 --> <!-- 采集控制按钮 -->
<div class="flex justify-center items-center mb-2"> <div class="flex justify-center items-center mb-2">
@ -16,13 +13,11 @@
!oscManager.isCapturing.value, !oscManager.isCapturing.value,
'from-red-500 to-red-600 hover:from-red-600 hover:to-red-700 focus:ring-red-300': 'from-red-500 to-red-600 hover:from-red-600 hover:to-red-700 focus:ring-red-300':
oscManager.isCapturing.value, oscManager.isCapturing.value,
}" }" @click="
@click="
oscManager.isCapturing.value oscManager.isCapturing.value
? oscManager.stopCapture() ? oscManager.stopCapture()
: oscManager.startCapture() : oscManager.startCapture()
" ">
>
<span class="flex items-center gap-2"> <span class="flex items-center gap-2">
<template v-if="oscManager.isCapturing.value"> <template v-if="oscManager.isCapturing.value">
<Square class="w-5 h-5" /> <Square class="w-5 h-5" />
@ -162,7 +157,7 @@ const option = computed((): EChartsOption => {
saveAsImage: {}, saveAsImage: {},
}, },
}, },
dataZoom: [ dataZoom: (oscManager.isCapturing.value) ? [] : [
{ {
type: "inside", type: "inside",
start: 0, start: 0,

View File

@ -8,10 +8,15 @@
<Activity class="w-5 h-5" /> <Activity class="w-5 h-5" />
波形显示 波形显示
</div> </div>
<div> <div class="flex items-center gap-2">
<button class="btn btn-warning" @click="osc.stopCapture" :disabled="!osc.isCapturing.value"> <button class="btn btn-sm btn-warning" @click="osc.stopCapture" :disabled="!osc.isCapturing.value">
停止捕获 停止捕获
</button> </button>
<div class="flex items-center gap-2">
<button class="btn btn-sm btn-error" @click="osc.clearOscilloscopeData">
清空
</button>
</div>
</div> </div>
</h2> </h2>
<OscilloscopeWaveformDisplay /> <OscilloscopeWaveformDisplay />