caner 2 years ago
parent
commit
21190f9e51
5 changed files with 24 additions and 28 deletions
  1. 2 1
      README.md
  2. 10 11
      src/App.vue
  3. 1 1
      src/services/axios.ts
  4. 0 0
      src/vite-env.d.ts
  5. 11 15
      vite.config.ts

+ 2 - 1
README.md

@@ -1,3 +1,4 @@
 # livekit-meeting-demo
 
-livekit 视频会议
+livekit 视频会议 需要配合 livekit后端 使用
+

+ 10 - 11
src/App.vue

@@ -13,15 +13,14 @@ const live_url = computed(() => localStorage.getItem('live_url'))
 const live_token = computed(() => localStorage.getItem('live_token'))
 const live_yhid = computed(() => localStorage.getItem('live_yhid'))
 const live_hyid = computed(() => localStorage.getItem('live_hyid'))
-const isClient = window.electron
 const inviteShow = ref(false)
 const expanded = ref([1])
 const chatShow = ref(false)
 const localVideoDom = ref()
-const VideoDomList = ref([] as Any)
+const VideoDomList = ref([] as any)
 const encoder = new TextEncoder()
 const decoder = new TextDecoder()
-const msgData = ref([])
+const msgData = ref([] as any)
 const currentClick = ref(0)
 
 apiService.getMettingPep({ yhid: live_yhid.value, hyid: live_hyid.value }).then(({ data }) => {
@@ -41,11 +40,11 @@ const videoCallRoom: Room | null = new Room()
   .on(RoomEvent.ParticipantConnected, onRemoteJoin)
   .on(RoomEvent.ParticipantDisconnected, onRemoteLeave)
   .on(RoomEvent.LocalTrackPublished, onLocalTrack)
-  .on(RoomEvent.DataReceived, onDataReceived)
+  .on(RoomEvent.DataReceived, onDataReceived as any)
 
 function onConnect() {
-  console.log('房间已连接', videoCallRoom.participants);
-  videoCallRoom.participants.forEach(el => {
+  console.log('房间已连接', videoCallRoom?.participants);
+  videoCallRoom?.participants.forEach(el => {
     const _index = VideoDomList.value.findIndex(es => es.id == el.identity)
     if (_index >= 0) {
       VideoDomList.value[_index].isJoin = true
@@ -61,7 +60,7 @@ function onLocalTrack(localTrackPublication: LocalTrackPublication, localPartici
   VideoDomList.value[0].audio = true
   VideoDomList.value[0].tracks.push(localTrackPublication.track)
   const dom = document.getElementById('remote_' + VideoDomList.value[0].id) as HTMLVideoElement
-  if (localTrackPublication.kind === 'video') localTrackPublication.track.attach(dom)
+  if (localTrackPublication.kind === 'video') localTrackPublication.track?.attach(dom)
 }
 
 // 监听远程流
@@ -141,7 +140,7 @@ async function roomConnect(url: string, token: string) {
 }
 
 // 切换
-function fnEvent(type: number, item?: Any) {
+function fnEvent(type: number, item?: any) {
   if (type === 3) {
     inviteShow.value = true
   } else if (type === 4 || type === 5) {
@@ -164,7 +163,7 @@ function fnEvent(type: number, item?: Any) {
     item.audio = !item.audio
   } else if (type === 2) {
     const data = encoder.encode(item)
-    if (videoCallRoom.state === 'connected') {
+    if (videoCallRoom?.state === 'connected') {
       videoCallRoom.localParticipant.publishData(data, DataPacket_Kind.RELIABLE)
       const { yhtx } = VideoDomList.value.find(el => el.yhid == live_yhid.value) || { yhtx: '' }
       const obj = {
@@ -184,13 +183,13 @@ function close() {
   videoCallRoom!.localParticipant.setMicrophoneEnabled(false)
   videoCallRoom!.disconnect()
   localVideoDom.value = null
-  window.electron?.send('closeMetting')
   console.log('断开连接')
 }
 
 // 最小化
 function minus() {
-  window.electron?.send('minusMetting')
+  console.log('最小化');
+  
 }
 
 // init

+ 1 - 1
src/services/axios.ts

@@ -3,7 +3,7 @@ import axios from 'axios'
 class AxiosService {
 
     constructor() {
-        const url = window.electron ? window.electron.envs.VITE_PROXY_URL : '/api'
+        const url = '/api'
         // http request 拦截
         axios.interceptors.request.use(
             (config) => {

+ 0 - 0
src/env.d.ts → src/vite-env.d.ts


+ 11 - 15
vite.config.ts

@@ -6,25 +6,21 @@ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
 export default ({ mode }) => {
   return defineConfig({
     base: './',
-    build: {
-      emptyOutDir: true,
-      outDir: '../../build/dist/metting'
-    },
     server: {
       host: '0.0.0.0',
       port: 15438,
       strictPort: true,
-      proxy: {
-        '/api': {
-          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
-          changeOrigin: true,
-          rewrite: path => path.replace(/^\/api/, ''),
-          secure: false,
-          headers: {
-            Referer: 'https://example.com'
-          }
-        }
-      }
+      // proxy: {
+      //   '/api': {
+      //     target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
+      //     changeOrigin: true,
+      //     rewrite: path => path.replace(/^\/api/, ''),
+      //     secure: false,
+      //     headers: {
+      //       Referer: 'https://example.com'
+      //     }
+      //   }
+      // }
     },
     resolve: {
       alias: {