From b1c966f69f4ff2657b923536441295a8da019012 Mon Sep 17 00:00:00 2001 From: chenqi Date: Tue, 10 Feb 2026 11:28:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(sidebar):=20=E8=A7=A3=E5=86=B3=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 try-catch 语句处理 JSON.parse 异常 - 当路由查询参数解析失败时返回默认路径 - 记录解析失败的错误信息到控制台 - 确保应用在无效查询参数情况下正常运行 --- .../src/layout/components/Sidebar/SidebarItem.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openhis-ui-vue3/src/layout/components/Sidebar/SidebarItem.vue b/openhis-ui-vue3/src/layout/components/Sidebar/SidebarItem.vue index b6a3f7e3..6637f67f 100644 --- a/openhis-ui-vue3/src/layout/components/Sidebar/SidebarItem.vue +++ b/openhis-ui-vue3/src/layout/components/Sidebar/SidebarItem.vue @@ -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) }