3.5
This commit is contained in:
parent
779a37ac2d
commit
35f325a468
@ -62,6 +62,11 @@ const routes = [
|
|||||||
name: 'TEST',
|
name: 'TEST',
|
||||||
component: () => import('../views/TEST.vue'),
|
component: () => import('../views/TEST.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/gateway-setting',
|
||||||
|
name: 'GatewaySetting',
|
||||||
|
component: () => import('../views/gateway/GatewaySetting.vue')
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="top-right-icons">
|
<div class="top-right-icons">
|
||||||
<img :src="connectionImage" alt="link" class="top-icon">
|
<img :src="connectionImage" alt="link" class="top-icon">
|
||||||
<img :src="batteryImage" alt="battery" class="top-icon">
|
<!-- 注释掉电池图标 -->
|
||||||
|
<!-- <img :src="batteryImage" alt="battery" class="top-icon"> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ export default {
|
|||||||
isControlPressed: false,
|
isControlPressed: false,
|
||||||
ws: null,
|
ws: null,
|
||||||
wsConnected: false,
|
wsConnected: false,
|
||||||
batteryLevel: 0,
|
// batteryLevel: 0, // 注释掉电池电量
|
||||||
lastResponseTime: 0,
|
lastResponseTime: 0,
|
||||||
connectionCheckInterval: null,
|
connectionCheckInterval: null,
|
||||||
sendInterval: null,
|
sendInterval: null,
|
||||||
@ -111,7 +112,9 @@ export default {
|
|||||||
button: "",
|
button: "",
|
||||||
audioConfig: audioTransmitter.data(),
|
audioConfig: audioTransmitter.data(),
|
||||||
isRecording: false,
|
isRecording: false,
|
||||||
audioHandler: null
|
audioHandler: null,
|
||||||
|
reconnectTimer: null, // 添加重连定时器引用
|
||||||
|
isComponentUnmounted: false // 添加组件卸载标志
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -126,11 +129,8 @@ export default {
|
|||||||
window.addEventListener("gamepadconnected", this.handleGamepadConnected);
|
window.addEventListener("gamepadconnected", this.handleGamepadConnected);
|
||||||
window.addEventListener("gamepaddisconnected", this.handleGamepadDisconnected);
|
window.addEventListener("gamepaddisconnected", this.handleGamepadDisconnected);
|
||||||
|
|
||||||
|
this.isComponentUnmounted = false; // 添加组件卸载标志
|
||||||
this.initWebSocket();
|
this.initWebSocket();
|
||||||
// 进入页面时发送数据
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.sendCarInfo();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 启动连接状态检查
|
// 启动连接状态检查
|
||||||
this.connectionCheckInterval = setInterval(() => {
|
this.connectionCheckInterval = setInterval(() => {
|
||||||
@ -149,6 +149,14 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
this.isComponentUnmounted = true; // 标记组件已卸载
|
||||||
|
|
||||||
|
// 清除重连定时器
|
||||||
|
if (this.reconnectTimer) {
|
||||||
|
clearTimeout(this.reconnectTimer);
|
||||||
|
this.reconnectTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
// 组件销毁前清理资源
|
// 组件销毁前清理资源
|
||||||
if (this.gamepadController) {
|
if (this.gamepadController) {
|
||||||
this.gamepadController.destroy();
|
this.gamepadController.destroy();
|
||||||
@ -159,6 +167,7 @@ export default {
|
|||||||
|
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
this.ws.close();
|
this.ws.close();
|
||||||
|
this.ws = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.connectionCheckInterval) {
|
if (this.connectionCheckInterval) {
|
||||||
@ -238,14 +247,14 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onclose = (event) => {
|
this.ws.onclose = () => {
|
||||||
console.log('WebSocket 已断开, code:', event.code, 'reason:', event.reason);
|
console.log('WebSocket连接关闭');
|
||||||
this.wsConnected = false;
|
// 只有在组件没有被卸载的情况下才重连
|
||||||
// 尝试重新连接
|
if (!this.isComponentUnmounted) {
|
||||||
setTimeout(() => {
|
this.reconnectTimer = setTimeout(() => {
|
||||||
console.log('尝试重新连接...');
|
this.initWebSocket();
|
||||||
this.initWebSocket();
|
}, 3000);
|
||||||
}, 3000);
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onerror = (error) => {
|
this.ws.onerror = (error) => {
|
||||||
@ -325,9 +334,8 @@ export default {
|
|||||||
|
|
||||||
updateCarStatus(data) {
|
updateCarStatus(data) {
|
||||||
if (data.attribute) {
|
if (data.attribute) {
|
||||||
// 更新电池状态
|
// 注释掉电池状态更新
|
||||||
this.batteryLevel = data.attribute.bat_quantity;
|
// this.batteryLevel = data.attribute.bat_quantity;
|
||||||
|
|
||||||
// 更新障碍物显示状态
|
// 更新障碍物显示状态
|
||||||
this.obstacleStatus = {
|
this.obstacleStatus = {
|
||||||
top: data.attribute.obstacle_sta === 0,
|
top: data.attribute.obstacle_sta === 0,
|
||||||
@ -382,19 +390,33 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// 注释掉电池图片计算属性
|
||||||
|
/*
|
||||||
batteryImage() {
|
batteryImage() {
|
||||||
// 使用 require 来正确引用图片
|
|
||||||
if (this.batteryLevel >= 80) return require('../assets/img/bat_full.png');
|
if (this.batteryLevel >= 80) return require('../assets/img/bat_full.png');
|
||||||
if (this.batteryLevel >= 60) return require('../assets/img/bat_high.png');
|
if (this.batteryLevel >= 60) return require('../assets/img/bat_high.png');
|
||||||
if (this.batteryLevel >= 40) return require('../assets/img/bat_medium.png');
|
if (this.batteryLevel >= 40) return require('../assets/img/bat_medium.png');
|
||||||
if (this.batteryLevel >= 20) return require('../assets/img/bat_low.png');
|
if (this.batteryLevel >= 20) return require('../assets/img/bat_low.png');
|
||||||
return require('../assets/img/bat_empty.png');
|
return require('../assets/img/bat_empty.png');
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
connectionImage() {
|
connectionImage() {
|
||||||
return this.wsConnected ?
|
return this.wsConnected ?
|
||||||
require('../assets/img/connect.png') :
|
require('../assets/img/connect.png') :
|
||||||
require('../assets/img/no_connect.png');
|
require('../assets/img/no_connect.png');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 添加返回按钮处理函数
|
||||||
|
const onClickLeft = () => {
|
||||||
|
router.back();
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
onClickLeft,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -610,4 +632,9 @@ export default {
|
|||||||
.voice-icon-img.show-voice {
|
.voice-icon-img.show-voice {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 确保标题栏在最上层 */
|
||||||
|
:deep(.van-nav-bar) {
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
<van-cell size="large" class="custom-cell" title="预警设置" icon="warning-o" is-link value="预警" @click="goto('warning')" />
|
<van-cell size="large" class="custom-cell" title="预警设置" icon="warning-o" is-link value="预警" @click="goto('warning')" />
|
||||||
<van-cell size="large" class="custom-cell" title="远程喊话" icon="bullhorn-o" is-link value="喊话" @click="navigateTo('web/voice_copy.html')" />
|
<van-cell size="large" class="custom-cell" title="远程喊话" icon="bullhorn-o" is-link value="喊话" @click="navigateTo('web/voice_copy.html')" />
|
||||||
<van-cell size="large" class="custom-cell" title="小车控制" icon="car" is-link value="控制" @click="goto('CarControl')" />
|
<van-cell size="large" class="custom-cell" title="小车控制" icon="car" is-link value="控制" @click="goto('CarControl')" />
|
||||||
<van-cell size="large" class="custom-cell" title="小车控制" icon="car" is-link value="控制" @click="goto('TEST')" />
|
<!-- <van-cell size="large" class="custom-cell" title="小车控制" icon="car" is-link value="控制" @click="goto('TEST')" /> -->
|
||||||
<van-cell size="large" class="custom-cell" title="小车控制" icon="car" is-link value="控制" @click="goto('AudioPlay')" />
|
<!-- <van-cell size="large" class="custom-cell" title="小车控制" icon="car" is-link value="控制" @click="goto('AudioPlay')" /> -->
|
||||||
|
<van-cell size="large" class="custom-cell" title="网关设置" icon="car" is-link value="控制" @click="goto('GatewaySetting')" />
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user