fix(sidebar): 解决路由查询参数解析错误问题
- 添加 try-catch 语句处理 JSON.parse 异常 - 当路由查询参数解析失败时返回默认路径 - 记录解析失败的错误信息到控制台 - 确保应用在无效查询参数情况下正常运行
This commit is contained in:
@@ -86,8 +86,13 @@ function resolvePath(routePath, routeQuery) {
|
||||
return props.basePath
|
||||
}
|
||||
if (routeQuery) {
|
||||
let query = JSON.parse(routeQuery);
|
||||
return { path: getNormalPath(props.basePath + '/' + routePath), query: query }
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user