This commit is contained in:
Fanrouver
2026-02-12 08:30:37 +07:00
parent 7fd99343bd
commit 1fbfa0e590
3 changed files with 119 additions and 149 deletions

No files matched your search

+6 -4
View File
@@ -1,5 +1,5 @@
// composables/useWebSocket.ts
import { ref, computed, onUnmounted } from 'vue'
import { ref, computed, onUnmounted, getCurrentInstance } from 'vue'
export interface WebSocketConfig {
url: string
@@ -168,9 +168,11 @@ export const useWebSocket = (config: WebSocketConfig) => {
}
}
onUnmounted(() => {
disconnect()
})
if (getCurrentInstance()) {
onUnmounted(() => {
disconnect()
})
}
return {
ws: computed(() => ws.value),