Browse Source

销毁
Signed-off-by: Caner <5658514@qq.com>

Caner 3 years ago
parent
commit
a4fb348957
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/pages/views/index/index.vue

+ 11 - 1
src/pages/views/index/index.vue

@@ -28,7 +28,9 @@
 <script lang="ts" setup>
 import { Painter } from '@/utils/Painter'
 import { Recorder } from '@/utils/Recorder'
-import { onMounted, ref, nextTick } from 'vue'
+import {
+  onMounted, ref, nextTick, onUnmounted
+} from 'vue'
 import { io } from 'socket.io-client'
 
 const painters: any = {}
@@ -112,6 +114,14 @@ onMounted(() => {
     socket.connect()
   })
 })
+
+onUnmounted(() => {
+  if (!socket) return
+  socket.disconnect()
+  context = null
+  canvas = null
+  recorder = null
+})
 </script>
 <style lang="less" scoped>
 .box {