diff --git a/app/pages/liveRoom/index.client.vue b/app/pages/liveRoom/index.client.vue index 5e59590..cca6073 100644 --- a/app/pages/liveRoom/index.client.vue +++ b/app/pages/liveRoom/index.client.vue @@ -15,12 +15,10 @@ import {artworkBuy} from "@/api/goods/index.js" import {useI18n} from 'vue-i18n' import floating2 from '@/components/floating2/index.vue' import { useThrottleFn } from '@vueuse/core' - - const { t } = useI18n() const { auctionDetail,getAuctionDetail} = goodStore(); const player = ref(null) -const {quoteStatus, show, playerId, show1, auctionData, getSocketData, getLiveLink, fullLive} = liveStore() +const {quoteStatus, show, playerId, show1, auctionData, getSocketData, getLiveLink, fullLive,wsClient} = liveStore() const pullLink = ref('') const handlePlayerError = (error) => { showConfirmDialog({ @@ -115,7 +113,10 @@ onBeforeUnmount(() => { player.value = null }) watch(() => fullLive.value, async (newVal) => { - if (!newVal) return + if (!newVal) { + wsClient.value?.disconnect() + return + } await getSocketData() diff --git a/app/stores/live/index.js b/app/stores/live/index.js index c9b1b52..adab290 100644 --- a/app/stores/live/index.js +++ b/app/stores/live/index.js @@ -149,13 +149,13 @@ export const liveStore = createGlobalState(() => { ...extraStyle } }) - + const wsClient=ref(null) const getSocketData = async () => { - const wsClient = new WebSocketClient( + wsClient.value = new WebSocketClient( config.public.NUXT_PUBLIC_SOCKET_URL, token.value ) - const ws = wsClient.connect('/api/v1/m/auction/live', { + const ws = wsClient.value.connect('/api/v1/m/auction/live', { auctionUuid: auctionDetail.value.uuid, }) @@ -248,6 +248,7 @@ export const liveStore = createGlobalState(() => { } } return{ + wsClient, fullLive, isMinWindow, lastSnapshot,