Browse Source

增加记录账号

Caner 2 years ago
parent
commit
c94fc81d8b
3 changed files with 11 additions and 9 deletions
  1. 1 1
      electron/main.js
  2. 5 3
      src/App.vue
  3. 5 5
      src/components/login.vue

+ 1 - 1
electron/main.js

@@ -134,7 +134,7 @@ class MainSerivce {
       if (evt === 'close-loading') {
         if (this.loadingWin) this.loadingWin.close()
         this.mainWin.show()
-        if (this.mainWin.isVisible()) this.connectLogi()
+        // if (this.mainWin.isVisible()) this.connectLogi()
       } else if (evt === 'minWin') {
         this.mainWin.minimize()
       } else if (evt === 'closeWin') {

+ 5 - 3
src/App.vue

@@ -62,6 +62,7 @@ function close(err?: string) {
 // 初始化rtc
 function initRTC() {
   try {
+    console.log('start RTC')
     Peer.value = new RTCPeerConnection({
       iceServers,
       bundlePolicy: 'max-bundle'
@@ -102,9 +103,9 @@ function initRTC() {
         sendContrlData()
       }
     }
-    console.log('rtc 初始化成功')
+    console.log('RTC SUCCESS')
   } catch (error) {
-    close('webrtc初始化失败')
+    close('RTC 初始化失败')
   }
 }
 
@@ -134,6 +135,7 @@ function sendAudio(blob: Blob) {
 function titleEvent(type: string) {
   if (type === 'maxWin') winMaxOrMin.value = !winMaxOrMin.value
   if (type === 'loginOut') {
+    console.log('mqtt close')
     close()
   } else {
     window.$electron?.send(type, winMaxOrMin.value)
@@ -144,7 +146,7 @@ function titleEvent(type: string) {
 window.$electron.on('message', async (msg: any) => {
   switch (msg.type) {
     case 'connect':
-      console.log('mqtt connected start rtc')
+      console.log('mqtt connected')
       isLogin.value = true
       showLoading.value = true
       initRTC()

+ 5 - 5
src/components/login.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
 import { computed, ref, watch } from 'vue'
 
-const name = ref('')
-const room = ref('')
+const name = ref(localStorage.getItem('NAME') || '')
+const room = ref(localStorage.getItem('ROOM') || '')
 const url = ref(localStorage.getItem('URL') || '')
 const props = defineProps<{ modelValue: string }>()
 const err = computed(() => props.modelValue)
@@ -20,9 +20,9 @@ function titleEvent(type: string) {
 
 watch([ name, room, url ], ([ _, __, ___ ], [ _o, __o, ___o ]) => {
   if (_ && __ && ___) emit('update:modelValue', '')
-  if (___ !== ___o) {
-    localStorage.setItem('URL', ___)
-  }
+  if (___ !== ___o) localStorage.setItem('URL', ___)
+  if (_ !== _o) localStorage.setItem('NAME', _)
+  if (__ !== __o) localStorage.setItem('ROOM', __)
 })
 </script>
 <template>