From 96058a3359041db820e7f613e47b485cd97e25b0 Mon Sep 17 00:00:00 2001 From: winixt Date: Fri, 15 Nov 2024 17:35:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20menu=20=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20=5Fblank=20=E5=9C=A8=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/reference/plugin/plugins/layout.md | 1 + packages/fes-plugin-layout/src/runtime/views/Menu.vue | 11 +++++++++-- .../src/runtime/views/MultiTabProvider.vue | 3 +++ packages/fes-template/.fes.js | 2 ++ packages/fes-template/src/pages/pinia.vue | 6 +++++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/reference/plugin/plugins/layout.md b/docs/reference/plugin/plugins/layout.md index 404539e44..b03a09078 100644 --- a/docs/reference/plugin/plugins/layout.md +++ b/docs/reference/plugin/plugins/layout.md @@ -300,6 +300,7 @@ export const layout = { ``` - **children**:子菜单配置。 + - **_blank**:是否在新的窗口打开页面,默认 http 开头的链接在新窗口打开 :::tip 函数类型仅在运行时可用,可以实现动态变更菜单。 diff --git a/packages/fes-plugin-layout/src/runtime/views/Menu.vue b/packages/fes-plugin-layout/src/runtime/views/Menu.vue index f6ec81846..8fb3c795e 100644 --- a/packages/fes-plugin-layout/src/runtime/views/Menu.vue +++ b/packages/fes-plugin-layout/src/runtime/views/Menu.vue @@ -126,8 +126,15 @@ export default { const onMenuClick = (e) => { const path = e.value; const currentMenu = menuArray.value.find(item => item.value === path); - - if (/^https?:\/\//.test(path)) { + if (currentMenu._blank) { + const resolved = router.resolve({ + path, + query: currentMenu?.query || {}, + params: currentMenu?.params || {}, + }); + window.open(resolved.href, '_blank'); + } + else if (/^https?:\/\//.test(path)) { window.open(path, '_blank'); } else if (/^\//.test(path)) { diff --git a/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue b/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue index 4bbe33595..77456dcb6 100644 --- a/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue +++ b/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue @@ -134,6 +134,9 @@ export default { const handleCloseTab = async (targetKey) => { targetKey = targetKey || route.path; const selectedPage = findPage(targetKey); + if (!selectedPage) { + return; + } const list = [...pageList.value]; const index = list.indexOf(selectedPage); if (route.path === selectedPage.path) { diff --git a/packages/fes-template/.fes.js b/packages/fes-template/.fes.js index bb4b6001e..43ef8db8e 100644 --- a/packages/fes-template/.fes.js +++ b/packages/fes-template/.fes.js @@ -47,6 +47,7 @@ export default defineBuildConfig({ { name: 'editor', icon: '/wine-outline.svg', + _blank: true, }, { title: '$externalLink', @@ -70,6 +71,7 @@ export default defineBuildConfig({ }, { name: 'pinia', + _blank: true, }, ], menuProps: { diff --git a/packages/fes-template/src/pages/pinia.vue b/packages/fes-template/src/pages/pinia.vue index 8b22688c6..7047b46f9 100644 --- a/packages/fes-template/src/pages/pinia.vue +++ b/packages/fes-template/src/pages/pinia.vue @@ -1,7 +1,10 @@ + { "name": "pinia", @@ -11,6 +14,7 @@ } } +