fix: 搜索菜单项路径为外链时无法跳转 (#111)
This commit is contained in:
parent
ab6aa20695
commit
2cd7b161e8
@ -8,6 +8,7 @@ import SearchFooter from "./SearchFooter.vue"
|
|||||||
import { ElMessage, ElScrollbar } from "element-plus"
|
import { ElMessage, ElScrollbar } from "element-plus"
|
||||||
import { cloneDeep, debounce } from "lodash-es"
|
import { cloneDeep, debounce } from "lodash-es"
|
||||||
import { DeviceEnum } from "@/constants/app-key"
|
import { DeviceEnum } from "@/constants/app-key"
|
||||||
|
import { isExternal } from "@/utils/validate"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/** 控制 modal 显隐 */
|
/** 控制 modal 显隐 */
|
||||||
@ -139,6 +140,11 @@ const handleEnter = () => {
|
|||||||
const { length } = resultList.value
|
const { length } = resultList.value
|
||||||
if (length === 0) return
|
if (length === 0) return
|
||||||
const name = activeRouteName.value
|
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) {
|
if (!name) {
|
||||||
ElMessage.warning("无法通过搜索进入该菜单,请为对应的路由设置唯一的 Name")
|
ElMessage.warning("无法通过搜索进入该菜单,请为对应的路由设置唯一的 Name")
|
||||||
return
|
return
|
||||||
|
@ -6,7 +6,7 @@ const Layouts = () => import("@/layouts/index.vue")
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 常驻路由
|
* 常驻路由
|
||||||
* 除了 redirect/403/404/login 等隐藏页面,其他页面建议设置 Name 属性
|
* 除了 redirect/403/404/login 等隐藏页面以及外链,其他页面建议设置 Name 属性
|
||||||
*/
|
*/
|
||||||
export const constantRoutes: RouteRecordRaw[] = [
|
export const constantRoutes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user