Skip to content

Commit

Permalink
fix: 离开页面关闭socket连接
Browse files Browse the repository at this point in the history
  • Loading branch information
lovezhangchuangxin committed Nov 10, 2024
1 parent ef31070 commit ef7a914
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/structure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { structuresMap } from 'packages/core/src'
import { structuresMap } from '@star-angry/core'
import { req } from './req'

export class StructureApi {
Expand Down
6 changes: 5 additions & 1 deletion packages/game/src/views/planet/PlanetPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'
import { io, Socket } from 'socket.io-client'
import { message as toast } from '@/utils/message'
import { structuresMap, StructureType } from '@star-angry/core'
Expand All @@ -43,6 +43,10 @@ onMounted(() => {
}, 1000)
})
onUnmounted(() => {
socket.value?.disconnect()
})
// 获取建筑
const getStructures = () => {
socket.value
Expand Down

0 comments on commit ef7a914

Please sign in to comment.