xx
This commit is contained in:
@@ -100,10 +100,28 @@ export default function RobotTaskPage({ devices }) {
|
|||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('selectedPathWork changed:', selectedPathWork);
|
console.log('selectedPathWork changed:', selectedPathWork);
|
||||||
if (JSON.parse(selectedPathWork.jsonData)?.path?.length == 0) {
|
|
||||||
utils.message.warning('该路线暂无路径点数据');
|
try {
|
||||||
|
// 1. 没有数据直接清空
|
||||||
|
if (!selectedPathWork?.jsonData) {
|
||||||
|
setPoints([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 安全解析 JSON
|
||||||
|
const data = JSON.parse(selectedPathWork?.jsonData);
|
||||||
|
const path = data?.path || [];
|
||||||
|
|
||||||
|
// 3. 空路径提示
|
||||||
|
if (path.length === 0) {
|
||||||
|
utils.message.warning('该路线暂无路径点数据');
|
||||||
|
}
|
||||||
|
// 4. 设置点位
|
||||||
|
setPoints(path);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('解析路径 JSON 失败:', err);
|
||||||
|
setPoints([]); // 解析失败也不崩溃
|
||||||
}
|
}
|
||||||
setPoints(selectedPathWork ? JSON.parse(selectedPathWork.jsonData)?.path || [] : []);
|
|
||||||
}, [selectedPathWork]);
|
}, [selectedPathWork]);
|
||||||
|
|
||||||
// 获取路线列表
|
// 获取路线列表
|
||||||
|
|||||||
Reference in New Issue
Block a user