From e622c052a9ee51ddc8a2b012034fecb1c83b69cf Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 5 Jan 2026 19:35:01 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd/ele=E3=80=91?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=94=AF=E6=8C=81=E6=9F=A5=E8=AF=A2=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E3=80=81iframe=20=E5=86=85=E5=B5=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/utils/src/helpers/generate-menus.ts | 30 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/helpers/generate-menus.ts b/packages/utils/src/helpers/generate-menus.ts index de4e5c42b..6742b2fb7 100644 --- a/packages/utils/src/helpers/generate-menus.ts +++ b/packages/utils/src/helpers/generate-menus.ts @@ -110,17 +110,30 @@ function convertServerMenuToRouteRecordStringComponent( menuList.forEach((menu) => { // 处理顶级链接菜单 if (isHttpUrl(menu.path) && menu.parentId === 0) { + // add by 芋艿:如果有 ?_iframe 参数,则作为内嵌页面处理 + // 如果有 _iframe 参数,则使用 iframeSrc;如果没有,则使用 link + const url = new URL(menu.path); + let link: string | undefined; + let iframeSrc: string | undefined; + if (url.searchParams.has('_iframe')) { + url.searchParams.delete('_iframe'); + iframeSrc = url.toString(); + } else { + link = menu.path; + } + const urlMenu: RouteRecordStringComponent = { component: 'IFrameView', meta: { hideInMenu: !menu.visible, icon: menu.icon, - link: menu.path, + iframeSrc, + link, order: menu.sort, title: menu.name, }, name: menu.name, - path: `/${menu.path}/index`, + path: `${menu.id}`, }; menus.push(urlMenu); return; @@ -154,6 +167,18 @@ function convertServerMenuToRouteRecordStringComponent( } nameSet.add(finalName); + // add by 芋艿:处理 menu.component 中的 query 参数 + // https://doc.vben.pro/guide/essentials/route.html#query + let query: Record | undefined; + const queryIndex = menu.component.indexOf('?'); + if (queryIndex !== -1) { + // 提取 query 字符串并解析为对象 + const queryString = menu.component.slice(queryIndex + 1); + query = Object.fromEntries(new URLSearchParams(queryString).entries()); + // 移除 component 中的 query 部分 + menu.component = menu.component.slice(0, queryIndex); + } + const buildMenu: RouteRecordStringComponent = { component: menu.component, meta: { @@ -162,6 +187,7 @@ function convertServerMenuToRouteRecordStringComponent( keepAlive: menu.keepAlive, order: menu.sort, title: menu.name, + ...(query && { query }), }, name: finalName, path: menu.path,