From 0c43078d321dfef8e5be98bc78e29739d519940a Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Thu, 1 Dec 2022 20:12:53 +0800 Subject: [PATCH] =?UTF-8?q?feat!:=20=E5=A2=9E=E5=8A=A0=E5=A4=96=E9=93=BE?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E8=B7=B3=E8=BD=AC=E6=8F=90=E7=A4=BA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E9=87=8D=E6=9E=84=E5=A4=96=E9=93=BE=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING CHANGE: 原先在路由`path`上设置外链,现在在路由`meta.link`上设置外链 --- src/global.d.ts | 2 + src/layouts/components/Search/index.vue | 24 ++--- src/layouts/components/SidebarItem/index.vue | 10 +- src/layouts/components/Tools/index.vue | 2 +- src/layouts/components/views/link.vue | 97 ++++++++++++++++++++ src/layouts/index.vue | 6 +- src/store/modules/menu.ts | 24 ++--- src/utils/composables/useMenu.ts | 8 +- src/utils/index.ts | 14 +-- src/views/index.vue | 2 +- 10 files changed, 132 insertions(+), 57 deletions(-) create mode 100644 src/layouts/components/views/link.vue diff --git a/src/global.d.ts b/src/global.d.ts index 4a0193a9..5416348a 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -220,6 +220,7 @@ declare module 'vue-router' { breadcrumb?: boolean activeMenu?: string cache?: boolean | string | string[] + link?: string breadcrumbNeste?: Route.breadcrumb[] } } @@ -250,6 +251,7 @@ declare namespace Menu { defaultOpened?: boolean auth?: string | string[] sidebar?: boolean + link?: string } children?: recordRaw[] } diff --git a/src/layouts/components/Search/index.vue b/src/layouts/components/Search/index.vue index 1077250c..18acdad5 100644 --- a/src/layouts/components/Search/index.vue +++ b/src/layouts/components/Search/index.vue @@ -2,7 +2,6 @@ import { cloneDeep } from 'lodash-es' import hotkeys from 'hotkeys-js' import type { RouteRecordRaw } from 'vue-router' -import { isExternalLink } from '@/utils' import eventBus from '@/utils/eventBus' import useSettingsStore from '@/store/modules/settings' import useRouteStore from '@/store/modules/route' @@ -16,10 +15,11 @@ const routeStore = useRouteStore() const menuStore = useMenuStore() interface listTypes { + path: string icon?: string title?: string | Function + link?: string breadcrumb: (string | Function | undefined)[] - path: string } const isShow = ref(false) @@ -151,18 +151,12 @@ function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string, } else { breadcrumbTemp.push(item.meta?.title) - let path = '' - if (isExternalLink(item.path)) { - path = item.path - } - else { - path = basePath ? [basePath, item.path].join('/') : item.path - } sourceList.value.push({ + path: basePath ? [basePath, item.path].join('/') : item.path, icon: item.meta?.icon ?? icon, title: item.meta?.title, + link: item.meta?.link, breadcrumb: breadcrumbTemp, - path, }) } } @@ -230,12 +224,12 @@ function handleScroll() { }) } -function pageJump(url: string) { - if (isExternalLink(url)) { - window.open(url, 'top') +function pageJump(path: listTypes['path'], link: listTypes['link']) { + if (link) { + window.open(link, '_blank') } else { - router.push(url) + router.push(path) } } @@ -284,7 +278,7 @@ function pageJump(url: string) {
- + diff --git a/src/layouts/components/SidebarItem/index.vue b/src/layouts/components/SidebarItem/index.vue index d02bee09..a220d250 100644 --- a/src/layouts/components/SidebarItem/index.vue +++ b/src/layouts/components/SidebarItem/index.vue @@ -1,6 +1,6 @@ diff --git a/src/layouts/components/views/link.vue b/src/layouts/components/views/link.vue new file mode 100644 index 00000000..61c3be63 --- /dev/null +++ b/src/layouts/components/views/link.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/layouts/index.vue b/src/layouts/index.vue index 5364a1fc..2f40b326 100644 --- a/src/layouts/index.vue +++ b/src/layouts/index.vue @@ -1,5 +1,6 @@