This commit is contained in:
ywb
2026-06-16 14:17:05 +08:00
parent 62292edc70
commit 916b44bc3c
10 changed files with 725 additions and 133 deletions
+35 -2
View File
@@ -20,7 +20,9 @@ createApp({
agvCameraError: false,
hasAgvCamera: false, // AGV 车体是否有可用相机
armCameraError: false,
reconnectingDevice: null
reconnectingDevice: null,
// 环境切换
testMode: true,
}
},
computed: {
@@ -38,6 +40,7 @@ createApp({
mounted() {
this.refresh()
this.refreshCameraCapabilities()
this.loadEnvMode()
setInterval(this.refreshStatus, 3000)
this.refreshCams()
setInterval(() => this.refreshCams(), 2000)
@@ -133,6 +136,36 @@ createApp({
} else {
window.location.href = '/running'
}
}
},
async loadEnvMode() {
try {
const res = await fetch(API + '/api/config/mode')
const data = await res.json()
if (data.ok) {
this.testMode = data.test_mode
}
} catch (e) {
console.error('加载环境配置失败:', e)
}
},
async toggleEnvMode() {
const newMode = !this.testMode
try {
const res = await fetch(API + '/api/config/mode', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({test_mode: newMode})
})
const data = await res.json()
if (data.ok) {
this.testMode = data.test_mode
alert('已切换至: ' + data.label)
} else {
alert('切换失败: ' + (data.error || '未知错误'))
}
} catch (e) {
alert('切换请求失败: ' + e.message)
}
},
}
}).mount('#app')