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[] = [ {