|
@@ -36,11 +36,11 @@ const conctrlGrears = ref(false)
|
|
|
const conctrlNum = ref(0)
|
|
const conctrlNum = ref(0)
|
|
|
const SpeedValue = ref(0)
|
|
const SpeedValue = ref(0)
|
|
|
|
|
|
|
|
-// 方向盘数据
|
|
|
|
|
-function onContrlData() {
|
|
|
|
|
|
|
+// 发送控制数据
|
|
|
|
|
+function sendContrlData() {
|
|
|
if (showLoading.value) return
|
|
if (showLoading.value) return
|
|
|
window.$electron.send('sendMqtt', { type: 'conctrl', conctrl: { ...conctrlData.value } })
|
|
window.$electron.send('sendMqtt', { type: 'conctrl', conctrl: { ...conctrlData.value } })
|
|
|
- conctrlAnimation.value = requestAnimationFrame(onContrlData)
|
|
|
|
|
|
|
+ conctrlAnimation.value = requestAnimationFrame(sendContrlData)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 关闭
|
|
// 关闭
|
|
@@ -54,7 +54,6 @@ function close(err?: string) {
|
|
|
audioStateNum.value = 0
|
|
audioStateNum.value = 0
|
|
|
quantity.value = 0
|
|
quantity.value = 0
|
|
|
cancelAnimationFrame(conctrlAnimation.value)
|
|
cancelAnimationFrame(conctrlAnimation.value)
|
|
|
- console.log('退出')
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化rtc
|
|
// 初始化rtc
|
|
@@ -96,7 +95,7 @@ function initRTC() {
|
|
|
if (state === 'connected') {
|
|
if (state === 'connected') {
|
|
|
await sleep(3000)
|
|
await sleep(3000)
|
|
|
showLoading.value = false
|
|
showLoading.value = false
|
|
|
- onContrlData()
|
|
|
|
|
|
|
+ sendContrlData()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
console.log('rtc 初始化成功')
|
|
console.log('rtc 初始化成功')
|
|
@@ -106,8 +105,8 @@ function initRTC() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 登录
|
|
// 登录
|
|
|
-async function login(data: { name: string, roomID: string }) {
|
|
|
|
|
- window.$electron.send('loginMqtt', { room: data.roomID, name: data.name })
|
|
|
|
|
|
|
+function login(data: { name: string, room: string, url: string }) {
|
|
|
|
|
+ window.$electron.send('loginMqtt', { room: data.room, name: data.name, url: data.url })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 档位计算
|
|
// 档位计算
|
|
@@ -127,6 +126,17 @@ function sendAudio(blob: Blob) {
|
|
|
window.$electron.send('sendMqtt', { type: 'Meadia', Meadia: blob })
|
|
window.$electron.send('sendMqtt', { type: 'Meadia', Meadia: blob })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 窗口事件
|
|
|
|
|
+function titleEvent(type: string) {
|
|
|
|
|
+ if (type === 'maxWin') winMaxOrMin.value = !winMaxOrMin.value
|
|
|
|
|
+ if (type === 'loginOut') {
|
|
|
|
|
+ close('手动退出')
|
|
|
|
|
+ window.$electron.send('closeMqtt')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window.$electron?.send(type, winMaxOrMin.value)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// mqtt
|
|
// mqtt
|
|
|
window.$electron.on('message', async (msg: any) => {
|
|
window.$electron.on('message', async (msg: any) => {
|
|
|
switch (msg.type) {
|
|
switch (msg.type) {
|
|
@@ -140,13 +150,10 @@ window.$electron.on('message', async (msg: any) => {
|
|
|
break
|
|
break
|
|
|
case 'join':
|
|
case 'join':
|
|
|
window.$electron.send('sendMqtt', { type: 'startRTC' })
|
|
window.$electron.send('sendMqtt', { type: 'startRTC' })
|
|
|
- console.log('开始rtc')
|
|
|
|
|
-
|
|
|
|
|
initRTC()
|
|
initRTC()
|
|
|
break
|
|
break
|
|
|
case 'leave':
|
|
case 'leave':
|
|
|
close('对方断开连接')
|
|
close('对方断开连接')
|
|
|
-
|
|
|
|
|
break
|
|
break
|
|
|
case 'offer':
|
|
case 'offer':
|
|
|
{
|
|
{
|
|
@@ -158,12 +165,10 @@ window.$electron.on('message', async (msg: any) => {
|
|
|
case 'power':
|
|
case 'power':
|
|
|
quantity.value = msg.power
|
|
quantity.value = msg.power
|
|
|
console.log('电量')
|
|
console.log('电量')
|
|
|
-
|
|
|
|
|
break
|
|
break
|
|
|
case 'speed':
|
|
case 'speed':
|
|
|
SpeedValue.value = Math.floor(msg.data)
|
|
SpeedValue.value = Math.floor(msg.data)
|
|
|
console.log('速度')
|
|
console.log('速度')
|
|
|
-
|
|
|
|
|
break
|
|
break
|
|
|
case 'contrl':
|
|
case 'contrl':
|
|
|
{
|
|
{
|
|
@@ -191,16 +196,8 @@ window.$electron.on('message', async (msg: any) => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 窗口事件
|
|
|
|
|
-function titleEvent(type: string) {
|
|
|
|
|
- if (type === 'maxWin') winMaxOrMin.value = !winMaxOrMin.value
|
|
|
|
|
- if (type === 'loginOut') {
|
|
|
|
|
- close()
|
|
|
|
|
- window.$electron.send('closeMqtt')
|
|
|
|
|
- } else {
|
|
|
|
|
- window.$electron?.send(type, winMaxOrMin.value)
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// 关闭loadingwin
|
|
|
|
|
+window.$electron.send('close-loading')
|
|
|
|
|
|
|
|
// 监听按钮状态
|
|
// 监听按钮状态
|
|
|
watch([ audioState, warnAudio, conctrlGrears ], () => {
|
|
watch([ audioState, warnAudio, conctrlGrears ], () => {
|
|
@@ -216,9 +213,6 @@ watch([ audioState, warnAudio, conctrlGrears ], () => {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
onUnmounted(() => close())
|
|
onUnmounted(() => close())
|
|
|
-
|
|
|
|
|
-// 关闭loadingwin
|
|
|
|
|
-window.$electron.send('close-loading')
|
|
|
|
|
</script>
|
|
</script>
|
|
|
<template>
|
|
<template>
|
|
|
<template v-if="isLogin">
|
|
<template v-if="isLogin">
|