From c3bc1e5ba2ad1eccf5233a9bbe95620c45d694d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=9E=E5=AE=9D=E5=B1=B1?= <1253070437@qq.com> Date: Thu, 6 Mar 2025 01:42:35 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E4=BC=98=E5=8C=96=E6=A0=B7=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B8=A6=E5=8F=82=E6=95=B0=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=8D=A1=E5=88=B7=E6=96=B0=E4=B8=A2=E5=A4=B1=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snowy-admin-web/src/layout/components/tags.vue | 12 +++++------- snowy-admin-web/src/layout/index.vue | 7 +++++-- snowy-admin-web/src/router/scrollBehavior.js | 2 +- snowy-admin-web/src/store/viewTags.js | 9 +++++---- snowy-admin-web/src/utils/useTabs.js | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/snowy-admin-web/src/layout/components/tags.vue b/snowy-admin-web/src/layout/components/tags.vue index 0770a507..88c9e4e1 100644 --- a/snowy-admin-web/src/layout/components/tags.vue +++ b/snowy-admin-web/src/layout/components/tags.vue @@ -69,7 +69,7 @@ import { globalStore, iframeStore, keepAliveStore, viewTagsStore } from '@/store' import routerUtil from '@/utils/routerUtil' import { useRoute, useRouter } from 'vue-router' - import { watch } from 'vue' + import { watch, ref, computed, nextTick, onMounted } from 'vue' const route = useRoute() const router = useRouter() @@ -261,7 +261,6 @@ const module = router.getMenu() const indexMenu = routerUtil.getIndexMenu(module).path - // eslint-disable-next-line eqeqeq const dashboardRoute = treeFind(module, (node) => node.path === indexMenu) if (dashboardRoute) { dashboardRoute.fullPath = dashboardRoute.path @@ -324,7 +323,6 @@ .ant-tabs-tab { background: none; height: 40px; - line-height: 40px; transition: background-color 0.3s, color 0.3s; @@ -334,7 +332,7 @@ margin: 0; .ant-tabs-tab-remove { margin: 0; - padding: 0 5px; + padding: 0 0 0 5px; } } .ant-tabs-tab-active { @@ -447,7 +445,7 @@ .snowy-radius .ant-tabs-tab-active { position: relative; z-index: 1; - border-radius: 10px 10px 0 0 !important; + border-radius: 6px 6px 0 0 !important; box-shadow: 12px 15px 0 0 var(--primary-1), -12px 15px 0 0 var(--primary-1); @@ -460,7 +458,7 @@ width: 13px; height: 40px; background: var(--primary-radius); - border-radius: 0 0 20px 0; + border-radius: 0 0 8px 0; } .snowy-radius .ant-tabs-tab-active::after { content: ''; @@ -470,7 +468,7 @@ width: 13px; height: 40px; background: var(--primary-radius); - border-radius: 0 0 0 20px; + border-radius: 0 0 0 8px; } .snowy-radius .ant-tabs-ink-bar { diff --git a/snowy-admin-web/src/layout/index.vue b/snowy-admin-web/src/layout/index.vue index e03c2706..24c01574 100644 --- a/snowy-admin-web/src/layout/index.vue +++ b/snowy-admin-web/src/layout/index.vue @@ -544,11 +544,14 @@ const getParentKeys = (data, val) => { const traverse = (array, val) => { // 递归父级key + if (!Array.isArray(array)) { + return undefined + } for (const element of array) { - if (element.path === val) { + if (element?.path === val) { return [element.path] } - if (element.children) { + if (element?.children) { const far = traverse(element.children, val) if (far) { return far.concat(element.path) diff --git a/snowy-admin-web/src/router/scrollBehavior.js b/snowy-admin-web/src/router/scrollBehavior.js index 040f60bb..a18bcb39 100644 --- a/snowy-admin-web/src/router/scrollBehavior.js +++ b/snowy-admin-web/src/router/scrollBehavior.js @@ -30,7 +30,7 @@ export function afterEach(to) { } nextTick(() => { const store = viewTagsStore() - const beforeRoute = store.viewTags.filter((v) => v.fullPath == to.fullPath)[0] + const beforeRoute = store.viewTags.filter((v) => v.path === to.path)[0] if (beforeRoute) { adminMain.scrollTop = beforeRoute.scrollTop || 0 } diff --git a/snowy-admin-web/src/store/viewTags.js b/snowy-admin-web/src/store/viewTags.js index 877a0b8d..1b2ea642 100644 --- a/snowy-admin-web/src/store/viewTags.js +++ b/snowy-admin-web/src/store/viewTags.js @@ -32,14 +32,14 @@ export const viewTagsStore = defineStore('viewTags', () => { } const removeViewTags = (route) => { viewTags.value.forEach((item, index) => { - if (item.fullPath === route.fullPath) { + if (item.path === route.path) { viewTags.value.splice(index, 1) } }) } const updateViewTags = (route) => { viewTags.value.forEach((item, index) => { - if (item.fullPath === route.fullPath) { + if (item.path === route.path) { viewTags.value[index] = { ...route, ...item } // Object.assign(item, route) } @@ -49,14 +49,15 @@ export const viewTagsStore = defineStore('viewTags', () => { const updateOrRemoveViewTags = (routes) => { if (routes && routes.length > 0) { viewTags.value.forEach((item, index) => { - const target = routes.find((route) => route.path === item.fullPath) + // 使用path进行比较,忽略参数部分 + const target = routes.find((route) => route.path === item.path) if (!target) { // 路由不存在,删除 viewTags.value.splice(index, 1) } else { // 路由存在,更新 viewTags.value = viewTags.value.map((item) => { - if (item.fullPath === target.path) { + if (item.path === target.path) { return { ...item, meta: target.meta } } return item diff --git a/snowy-admin-web/src/utils/useTabs.js b/snowy-admin-web/src/utils/useTabs.js index 5b8a926c..6ca79be7 100644 --- a/snowy-admin-web/src/utils/useTabs.js +++ b/snowy-admin-web/src/utils/useTabs.js @@ -61,7 +61,7 @@ export default { const tagList = [...store.viewTags] tagList.forEach((tag) => { // eslint-disable-next-line prettier/prettier - if ((tag.meta && tag.meta.affix) || route.fullPath == tag.fullPath) { + if ((tag.meta && tag.meta.affix) || route.path === tag.path) { return true } else { this.close(tag)