diff --git a/docs/reference/plugin/plugins/layout.md b/docs/reference/plugin/plugins/layout.md
index f01bce3b..d4e95552 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 f6ec8184..8fb3c795 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 f4ec44dd..3e1e23b3 100644
--- a/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue
+++ b/packages/fes-plugin-layout/src/runtime/views/MultiTabProvider.vue
@@ -135,6 +135,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 bb4b6001..43ef8db8 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 8b22688c..7047b46f 100644
--- a/packages/fes-template/src/pages/pinia.vue
+++ b/packages/fes-template/src/pages/pinia.vue
@@ -1,7 +1,10 @@
{{ store.counter }}
- Button
+
+ Button
+
+
{
"name": "pinia",
@@ -11,6 +14,7 @@
}
}
+