fix: 修复编码器需要重新开关才能使用的问题

This commit is contained in:
SikongJueluo 2025-08-20 21:04:54 +08:00
parent 02af59c37e
commit 8ab55f411d
2 changed files with 8 additions and 2 deletions

View File

@ -112,7 +112,10 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState(
} }
function getHubProxy() { function getHubProxy() {
if (!oscilloscopeHub.value) throw new Error("Hub not initialized"); if (!oscilloscopeHub.value) {
reinitializeHub();
throw new Error("Hub not initialized");
}
return oscilloscopeHub.value.proxy; return oscilloscopeHub.value.proxy;
} }

View File

@ -55,7 +55,10 @@ export const useRotaryEncoder = defineStore("RotaryEncoder", () => {
} }
function getHubProxy() { function getHubProxy() {
if (!rotaryEncoderHub.value) throw new Error("Hub not initialized"); if (!rotaryEncoderHub.value) {
reinitializeHub();
throw new Error("Hub not initialized");
}
return rotaryEncoderHub.value.proxy; return rotaryEncoderHub.value.proxy;
} }