fix(sidebar): 解决路由查询参数解析错误问题

- 添加 try-catch 语句处理 JSON.parse 异常
- 当路由查询参数解析失败时返回默认路径
- 记录解析失败的错误信息到控制台
- 确保应用在无效查询参数情况下正常运行
This commit is contained in:
2026-02-10 11:28:07 +08:00
parent dba6350493
commit b1c966f69f

View File

@@ -86,8 +86,13 @@ function resolvePath(routePath, routeQuery) {
return props.basePath
}
if (routeQuery) {
try {
let query = JSON.parse(routeQuery);
return { path: getNormalPath(props.basePath + '/' + routePath), query: query }
} catch (e) {
console.error('Failed to parse routeQuery:', routeQuery, e);
return getNormalPath(props.basePath + '/' + routePath)
}
}
return getNormalPath(props.basePath + '/' + routePath)
}