From 2cd7b161e8058072a3e569d2c8a4265b6e291b91 Mon Sep 17 00:00:00 2001 From: ClariS <1457715339@qq.com> Date: Tue, 22 Aug 2023 16:06:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=90=9C=E7=B4=A2=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E9=A1=B9=E8=B7=AF=E5=BE=84=E4=B8=BA=E5=A4=96=E9=93=BE=E6=97=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=B7=B3=E8=BD=AC=20(#111)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SearchMenu/SearchModal.vue | 6 ++++++ src/router/index.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/SearchMenu/SearchModal.vue b/src/components/SearchMenu/SearchModal.vue index d6bed76..345ec4e 100644 --- a/src/components/SearchMenu/SearchModal.vue +++ b/src/components/SearchMenu/SearchModal.vue @@ -8,6 +8,7 @@ import SearchFooter from "./SearchFooter.vue" import { ElMessage, ElScrollbar } from "element-plus" import { cloneDeep, debounce } from "lodash-es" import { DeviceEnum } from "@/constants/app-key" +import { isExternal } from "@/utils/validate" interface Props { /** 控制 modal 显隐 */ @@ -139,6 +140,11 @@ const handleEnter = () => { const { length } = resultList.value if (length === 0) return const name = activeRouteName.value + const path = resultList.value.find((item) => item.name === name)?.path + if (path && isExternal(path)) { + window.open(path, "_blank", "noopener, noreferrer") + return + } if (!name) { ElMessage.warning("无法通过搜索进入该菜单,请为对应的路由设置唯一的 Name") return diff --git a/src/router/index.ts b/src/router/index.ts index 10d7e61..8203bff 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -6,7 +6,7 @@ const Layouts = () => import("@/layouts/index.vue") /** * 常驻路由 - * 除了 redirect/403/404/login 等隐藏页面,其他页面建议设置 Name 属性 + * 除了 redirect/403/404/login 等隐藏页面以及外链,其他页面建议设置 Name 属性 */ export const constantRoutes: RouteRecordRaw[] = [ {