caner 1 year ago
parent
commit
ef8e1aebca

+ 45 - 10
src/App.vue

@@ -10,7 +10,7 @@ import Signal from '@/components/signal.vue'
 const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms))
 const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms))
 const iceServers = [
 const iceServers = [
   {
   {
-    urls: ['stun:caner.top:3478']
+    urls: [ 'stun:caner.top:3478' ]
   },
   },
   {
   {
     urls: 'turn:caner.top:3478',
     urls: 'turn:caner.top:3478',
@@ -210,7 +210,7 @@ window.$electron.on('message', async (msg: any) => {
 window.$electron.send('close-loading')
 window.$electron.send('close-loading')
 
 
 // 监听按钮状态
 // 监听按钮状态
-watch([audioState, warnAudio, conctrlGrears], () => {
+watch([ audioState, warnAudio, conctrlGrears ], () => {
   if (showLoading.value) return
   if (showLoading.value) return
   if (audioState.value) {
   if (audioState.value) {
     audioStateNum.value++
     audioStateNum.value++
@@ -226,31 +226,66 @@ onUnmounted(() => close())
 </script>
 </script>
 <template>
 <template>
   <template v-if="isLogin">
   <template v-if="isLogin">
-    <video ref="remoteVideo" autoplay playsinline />
+    <video
+      ref="remoteVideo"
+      autoplay
+      playsinline
+    />
     <div class="marke">
     <div class="marke">
       <div class="marke-left">
       <div class="marke-left">
         <!-- 音频状态 -->
         <!-- 音频状态 -->
-        <Record class="marke-audio" :size="25" :audio-state="micState" @callBack="sendAudio" />
+        <Record
+          class="marke-audio"
+          :size="25"
+          :audio-state="micState"
+          @callBack="sendAudio"
+        />
         <!-- 喇叭状态 -->
         <!-- 喇叭状态 -->
-        <Icon name="audio" :size="25" :color="(!!(audioStateNum % 2)) ? '#00CED1' : 'rgba(0, 0, 0, 0.3)'" />
+        <Icon
+          name="audio"
+          :size="25"
+          :color="(!!(audioStateNum % 2)) ? '#00CED1' : 'rgba(0, 0, 0, 0.3)'"
+        />
         <!-- 电量状态 -->
         <!-- 电量状态 -->
         <Battery :quantity="quantity" />
         <Battery :quantity="quantity" />
         <!-- 信号 -->
         <!-- 信号 -->
         <Signal :signal-value="signalValue" />
         <Signal :signal-value="signalValue" />
       </div>
       </div>
       <div class="marke-right">
       <div class="marke-right">
-        <Icon name="min" :size="20" color="#fff" @click="titleEvent('minWin')" />
-        <Icon :name="winMaxOrMin ? 'max' : 'maxMin'" :size="20" color="#fff" @click="titleEvent('maxWin')" />
-        <Icon name="close" :size="20" color="#fff" @click="titleEvent('closeWin')" />
+        <Icon
+          name="min"
+          :size="20"
+          color="#fff"
+          @click="titleEvent('minWin')"
+        />
+        <Icon
+          :name="winMaxOrMin ? 'max' : 'maxMin'"
+          :size="20"
+          color="#fff"
+          @click="titleEvent('maxWin')"
+        />
+        <Icon
+          name="close"
+          :size="20"
+          color="#fff"
+          @click="titleEvent('closeWin')"
+        />
       </div>
       </div>
     </div>
     </div>
     <!-- 码数 -->
     <!-- 码数 -->
     <div class="gauge">
     <div class="gauge">
-      <Gauge :value="SpeedValue" :gears="conctrlNum % 2 ? '倒档' : '前进'" />
+      <Gauge
+        :value="SpeedValue"
+        :gears="conctrlNum % 2 ? '倒档' : '前进'"
+      />
     </div>
     </div>
     <Loading v-if="showLoading" />
     <Loading v-if="showLoading" />
   </template>
   </template>
-  <Login v-else v-model="error" @loginBack="login" />
+  <Login
+    v-else
+    v-model="error"
+    @loginBack="login"
+  />
 </template>
 </template>
 <style scoped lang="scss">
 <style scoped lang="scss">
 video {
 video {

+ 8 - 2
src/components/battery.vue

@@ -1,7 +1,13 @@
 <template>
 <template>
-  <div class="electric" :class="bgClass">
+  <div
+    class="electric"
+    :class="bgClass"
+  >
     <div class="electric-panel">
     <div class="electric-panel">
-      <div class="electric-panel-remainder" :style="{ width: quantity + '%' }" />
+      <div
+        class="electric-panel-remainder"
+        :style="{ width: quantity + '%' }"
+      />
     </div>
     </div>
     <div class="electric-berText">
     <div class="electric-berText">
       {{ quantity }}%
       {{ quantity }}%

+ 10 - 7
src/components/gauge.vue

@@ -8,7 +8,7 @@ import {
   onMounted, ref, watch
   onMounted, ref, watch
 } from 'vue'
 } from 'vue'
 
 
-echarts.use([GaugeChart, LabelLayout, UniversalTransition, CanvasRenderer])
+echarts.use([ GaugeChart, LabelLayout, UniversalTransition, CanvasRenderer ])
 const props = defineProps<{
 const props = defineProps<{
   value: number,
   value: number,
   gears: string
   gears: string
@@ -52,9 +52,9 @@ const option = ref({
       show: true
       show: true
     },
     },
     radius: '190%',
     radius: '190%',
-    center: ['50%', '98%'],
+    center: [ '50%', '98%' ],
     detail: {
     detail: {
-      offsetCenter: [0, -25],
+      offsetCenter: [ 0, -25 ],
       valueAnimation: true,
       valueAnimation: true,
       formatter: (value: number) => `{value|${value.toFixed(0)}}{unit|km/h}\n{num|${props.gears}}`,
       formatter: (value: number) => `{value|${value.toFixed(0)}}{unit|km/h}\n{num|${props.gears}}`,
       rich: {
       rich: {
@@ -66,19 +66,19 @@ const option = ref({
         unit: {
         unit: {
           fontSize: 20,
           fontSize: 20,
           color: '#FFFFFF',
           color: '#FFFFFF',
-          padding: [0, 0, 0, 10]
+          padding: [ 0, 0, 0, 10 ]
         },
         },
         num: {
         num: {
           fontSize: 20,
           fontSize: 20,
           color: '#FFFFFF',
           color: '#FFFFFF',
-          padding: [0, 0, 0, 10]
+          padding: [ 0, 0, 0, 10 ]
         }
         }
       }
       }
     },
     },
     pointer: {
     pointer: {
       show: false
       show: false
     },
     },
-    data: [0]
+    data: [ 0 ]
   }
   }
 })
 })
 
 
@@ -111,7 +111,10 @@ onUnmounted(() => {
 })
 })
 </script>
 </script>
 <template>
 <template>
-  <div id="charts" ref="chartDom" />
+  <div
+    id="charts"
+    ref="chartDom"
+  />
 </template>
 </template>
 <style scoped>
 <style scoped>
 #charts {
 #charts {

+ 9 - 2
src/components/icon.vue

@@ -11,7 +11,14 @@ const newColor = computed(() => `${props.color ?? '#ccc'}`)
 const newSize = computed(() => `${props.size ? (`${props.size}px`) : '16px'}`)
 const newSize = computed(() => `${props.size ? (`${props.size}px`) : '16px'}`)
 </script>
 </script>
 <template>
 <template>
-  <svg aria-hidden="true" :fill="newColor" :style="`width:${newSize};height:${newSize}`">
-    <use :href="symbolId" :fill="newColor" />
+  <svg
+    aria-hidden="true"
+    :fill="newColor"
+    :style="`width:${newSize};height:${newSize}`"
+  >
+    <use
+      :href="symbolId"
+      :fill="newColor"
+    />
   </svg>
   </svg>
 </template>
 </template>

+ 53 - 14
src/components/login.vue

@@ -6,8 +6,7 @@ const room = ref(localStorage.getItem('ROOM') || '')
 const url = ref(localStorage.getItem('URL') || '')
 const url = ref(localStorage.getItem('URL') || '')
 const props = defineProps<{ modelValue: string }>()
 const props = defineProps<{ modelValue: string }>()
 const err = computed(() => props.modelValue)
 const err = computed(() => props.modelValue)
-const emit = defineEmits<{
-  (evt: 'update:modelValue', value: string): void
+const emit = defineEmits<{(evt: 'update:modelValue', value: string): void
   (evt: 'loginBack', value: { name: string, room: string, url: string }): void
   (evt: 'loginBack', value: { name: string, room: string, url: string }): void
 }>()
 }>()
 
 
@@ -19,7 +18,7 @@ function titleEvent(type: string) {
   window.$electron?.send(type)
   window.$electron?.send(type)
 }
 }
 
 
-watch([name, room, url], ([_, __, ___], [_o, __o, ___o]) => {
+watch([ name, room, url ], ([ _, __, ___ ], [ _o, __o, ___o ]) => {
   if (_ && __ && ___) emit('update:modelValue', '')
   if (_ && __ && ___) emit('update:modelValue', '')
   if (___ !== ___o) localStorage.setItem('URL', ___)
   if (___ !== ___o) localStorage.setItem('URL', ___)
   if (_ !== _o) localStorage.setItem('NAME', _)
   if (_ !== _o) localStorage.setItem('NAME', _)
@@ -29,29 +28,69 @@ watch([name, room, url], ([_, __, ___], [_o, __o, ___o]) => {
 <template>
 <template>
   <div class="login">
   <div class="login">
     <div class="login-title">
     <div class="login-title">
-      <Icon name="min" :size="20" color="#fff" @click="titleEvent('minWin')" />
-      <Icon name="close" :size="20" color="#fff" @click="titleEvent('closeWin')" />
+      <Icon
+        name="min"
+        :size="20"
+        color="#fff"
+        @click="titleEvent('minWin')"
+      />
+      <Icon
+        name="close"
+        :size="20"
+        color="#fff"
+        @click="titleEvent('closeWin')"
+      />
     </div>
     </div>
     <div class="login-content">
     <div class="login-content">
       <div class="login-content-left" />
       <div class="login-content-left" />
-      <div class="login-content-right" @keydown.enter="login">
+      <div
+        class="login-content-right"
+        @keydown.enter="login"
+      >
         <p>Hello, 欢迎登录</p>
         <p>Hello, 欢迎登录</p>
         <div>
         <div>
-          <Icon name="server" :size="25" />
-          <input v-model="url" type="text" placeholder="mqtts://*******" maxlength="50">
+          <Icon
+            name="server"
+            :size="25"
+          />
+          <input
+            v-model="url"
+            type="text"
+            placeholder="mqtts://*******"
+            maxlength="50"
+          >
         </div>
         </div>
         <div>
         <div>
-          <Icon name="username" :size="25" />
-          <input v-model="room" type="text" placeholder="请输入房间" maxlength="20">
+          <Icon
+            name="username"
+            :size="25"
+          />
+          <input
+            v-model="room"
+            type="text"
+            placeholder="请输入房间"
+            maxlength="20"
+          >
         </div>
         </div>
         <div>
         <div>
-          <Icon name="password" :size="25" />
-          <input v-model="name" type="text" placeholder="请输入名称" maxlength="20">
+          <Icon
+            name="password"
+            :size="25"
+          />
+          <input
+            v-model="name"
+            type="text"
+            placeholder="请输入名称"
+            maxlength="20"
+          >
         </div>
         </div>
         <span>{{ err }}</span>
         <span>{{ err }}</span>
         <div>
         <div>
-          <button :disabled="!name && !room && !url && !url.includes('mqtts://')"
-            :class="{ resetStyle: name && room && url && url.includes('mqtts://') }" @click="login">
+          <button
+            :disabled="!name && !room && !url && !url.includes('mqtts://')"
+            :class="{ resetStyle: name && room && url && url.includes('mqtts://') }"
+            @click="login"
+          >
             加入
             加入
           </button>
           </button>
         </div>
         </div>

+ 6 - 2
src/components/record.vue

@@ -1,5 +1,9 @@
 <template>
 <template>
-  <Icon name="mic" :size="size" :color="show ? '#00CED1' : 'rgba(0, 0, 0, 0.3)'" />
+  <Icon
+    name="mic"
+    :size="size"
+    :color="show ? '#00CED1' : 'rgba(0, 0, 0, 0.3)'"
+  />
 </template>
 </template>
 <script setup lang="ts">
 <script setup lang="ts">
 import { onMounted, ref, watch } from 'vue'
 import { onMounted, ref, watch } from 'vue'
@@ -12,7 +16,7 @@ const props = defineProps<{
   audioState: boolean,
   audioState: boolean,
   size: number
   size: number
 }>()
 }>()
-const emit = defineEmits<{ (evt: 'callBack', value: Blob): void }>()
+const emit = defineEmits<{(evt: 'callBack', value: Blob): void }>()
 
 
 // 初始化音频
 // 初始化音频
 async function initRecorder() {
 async function initRecorder() {

+ 5 - 1
src/components/signal.vue

@@ -1,7 +1,11 @@
 <template>
 <template>
   <div class="signal-box">
   <div class="signal-box">
     <ul>
     <ul>
-      <li v-for="(item, idex) in list" :key="idex" :class="item.class" />
+      <li
+        v-for="(item, idex) in list"
+        :key="idex"
+        :class="item.class"
+      />
     </ul>
     </ul>
   </div>
   </div>
 </template>
 </template>