Browse Source

更新打包工具,优化打包依赖项

Caner 2 years ago
parent
commit
f44fc7ad98
7 changed files with 60 additions and 67 deletions
  1. 2 1
      .eslintrc.json
  2. 20 25
      package.json
  3. 1 1
      src/components/gauge.vue
  4. 32 32
      src/components/record.vue
  5. 4 4
      src/views/index/index.vue
  6. 1 2
      tsconfig.json
  7. 0 2
      vite.config.ts

+ 2 - 1
.eslintrc.json

@@ -38,6 +38,7 @@
     "prefer-destructuring": 0,
     "no-new": 0,
     "func-names": 0,
-    "no-nested-ternary": 0
+    "no-nested-ternary": 0,
+    "import/no-extraneous-dependencies": 0 
   }
 }

+ 20 - 25
package.json

@@ -6,48 +6,43 @@
   "description": "控制端",
   "scripts": {
     "dev": "vite",
-    "build": "vue-tsc --noEmit && vite build && yarn pmake",
-    "make": "electron-forge make",
-    "pmake": "electron-forge package"
+    "build": "vue-tsc --noEmit && vite build && electron-builder build"
   },
   "dependencies": {
-    "echarts": "^5.4.2",
-    "socket.io-client": "^4.6.1",
-    "vue": "^3.3.2",
-    "vue-router": "^4.2.0"
+    "node-hid": "^2.1.2"
   },
   "devDependencies": {
-    "@electron-forge/cli": "^6.1.1",
-    "@electron-forge/maker-zip": "^6.1.1",
     "@types/node": "^18.15.3",
     "@typescript-eslint/parser": "^5.40.0",
     "@vitejs/plugin-vue": "^4.2.3",
     "electron": "^23.1.2",
+    "electron-builder": "^23.6.0",
     "eslint": "^8.40.0",
     "eslint-config-airbnb-base": "^15.0.0",
     "eslint-plugin-import": "^2.27.5",
     "eslint-plugin-vue": "^9.13.0",
-    "node-hid": "^2.1.2",
     "sass": "^1.63.3",
     "typescript": "~5.0.4",
     "vite": "^4.3.6",
-    "vite-plugin-compression": "^0.5.1",
     "vite-plugin-electron": "^0.11.2",
     "vite-plugin-eslint": "^1.8.1",
     "vite-plugin-svg-icons": "^2.0.1",
-    "vue-tsc": "^1.6.5"
+    "vue-tsc": "^1.6.5",
+    "echarts": "^5.4.2",
+    "socket.io-client": "^4.6.1",
+    "vue": "^3.3.2",
+    "vue-router": "^4.2.0"
   },
-  "config": {
-    "forge": {
-      "packagerConfig": {
-        "asar": true,
-        "ignore": "(dist-electron|out|vite.config.ts|README.md|.env|.gitignore|.eslintrc.json|src|public|node_modules|package-lock.json)"
-      },
-      "makers": [
-        {
-          "name": "@electron-forge/maker-zip"
-        }
-      ]
-    }
+  "build": {
+    "directories": {
+      "output": "out"
+    },
+    "files": [
+      "dist/js",
+      "dist/assets",
+      "dist/index.html",
+      "electron"
+    ],
+    "asar": false
   }
-}
+}

+ 1 - 1
src/components/gauge.vue

@@ -95,7 +95,7 @@ watch(() => props.value, (v: number) => {
   chart.value.setOption(option.value)
 })
 
-watch(() => props.gears, (v) => {
+watch(() => props.gears, () => {
   if (!chart.value) return
   chart.value.setOption(option.value)
 })

+ 32 - 32
src/components/record.vue

@@ -8,47 +8,47 @@
 <script setup lang="ts">
 import { ref, watch } from 'vue'
 
-const chunks = ref([] as Blob[])
+// const chunks = ref([] as Blob[])
 const mediaRecorder = ref(null as null | MediaRecorder)
 const show = ref(false)
 
 const props = defineProps<{
   audioState: boolean
 }>()
-const emit = defineEmits<{(evt: 'callBack', value: Blob): void;
-}>()
+// const emit = defineEmits<{(evt: 'callBack', value: Blob): void;
+// }>()
 
 // 初始化音频
-async function initRecorder() {
-  try {
-    const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
-    mediaRecorder.value = new MediaRecorder(stream)
+// async function initRecorder() {
+//   try {
+//     const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
+//     mediaRecorder.value = new MediaRecorder(stream)
 
-    // 事件监听
-    mediaRecorder.value.ondataavailable = (e: { data: Blob }) => {
-      chunks.value.push(e.data)
-    }
-    mediaRecorder.value.onstart = () => {
-      chunks.value = []
-    }
-    mediaRecorder.value.onstop = () => {
-      const blob = new Blob(chunks.value, {
-        type: 'audio/webm;codecs=opus'
-      })
-      emit('callBack', blob)
-    }
-  } catch (error: any) {
-    show.value = false
-    mediaRecorder.value = null
-    let txt = '不支持的音频'
-    if (error.toString().includes('getUserMedia')) {
-      txt = '不支持webrtc音频'
-    } else {
-      txt = '未获取到音频设备'
-    }
-    new window.Notification(txt)
-  }
-}
+//     // 事件监听
+//     mediaRecorder.value.ondataavailable = (e: { data: Blob }) => {
+//       chunks.value.push(e.data)
+//     }
+//     mediaRecorder.value.onstart = () => {
+//       chunks.value = []
+//     }
+//     mediaRecorder.value.onstop = () => {
+//       const blob = new Blob(chunks.value, {
+//         type: 'audio/webm;codecs=opus'
+//       })
+//       emit('callBack', blob)
+//     }
+//   } catch (error: any) {
+//     show.value = false
+//     mediaRecorder.value = null
+//     let txt = '不支持的音频'
+//     if (error.toString().includes('getUserMedia')) {
+//       txt = '不支持webrtc音频'
+//     } else {
+//       txt = '未获取到音频设备'
+//     }
+//     new window.Notification(txt)
+//   }
+// }
 
 watch(() => props.audioState, (v) => {
   if (!mediaRecorder.value) return

+ 4 - 4
src/views/index/index.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { Socket, io } from 'socket.io-client'
 import {
-  onMounted, onUnmounted, watch, ref
+  onMounted, onUnmounted, ref
 } from 'vue'
 import Login from '@/components/login.vue'
 import Gauge from '@/components/gauge.vue'
@@ -19,10 +19,10 @@ const remoteVideo = ref()
 const showLoading = ref(true)
 const contrlState = ref(false)
 const audioState = ref(false)
-const mutedState = ref(true)
-const warnAudio = ref(false)// 鸣笛
+// const mutedState = ref(true)
+// const warnAudio = ref(false)// 鸣笛
 const speed = ref(1) // 1低速档 | 2 高速档
-const muted = ref(true)// 是否静音
+// const muted = ref(true)// 是否静音
 const SpeedValue = ref(0)
 const iceServers = ref([
   {

+ 1 - 2
tsconfig.json

@@ -18,8 +18,7 @@
     "strict": true,
     "noUnusedLocals": true,
     "noUnusedParameters": true,
-    "noFallthroughCasesInSwitch": true,
-    "types": ["vite-plugin-svg-icons/client"]
+    "noFallthroughCasesInSwitch": true
   },
   "include": [
     "*.d.ts",

+ 0 - 2
vite.config.ts

@@ -1,7 +1,6 @@
 import { defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import eslint from 'vite-plugin-eslint'
-import viteCompression from 'vite-plugin-compression'
 import { resolve } from 'path'
 import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
 import electron from 'vite-plugin-electron'
@@ -15,7 +14,6 @@ export default () => defineConfig({
   },
   plugins: [
     vue(),
-    viteCompression(),
     eslint({ fix: true, include: ['**/*.ts', '**/*.vue'] }),
     createSvgIconsPlugin({
       iconDirs: [resolve(__dirname, './src/assets/icons')],