mirror of https://gitee.com/xiaonuobase/snowy
【更新】标签页优化样式,解决带参数标签卡刷新丢失选中问题
parent
0e44800b3a
commit
c3bc1e5ba2
|
@ -69,7 +69,7 @@
|
||||||
import { globalStore, iframeStore, keepAliveStore, viewTagsStore } from '@/store'
|
import { globalStore, iframeStore, keepAliveStore, viewTagsStore } from '@/store'
|
||||||
import routerUtil from '@/utils/routerUtil'
|
import routerUtil from '@/utils/routerUtil'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { watch } from 'vue'
|
import { watch, ref, computed, nextTick, onMounted } from 'vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
@ -261,7 +261,6 @@
|
||||||
|
|
||||||
const module = router.getMenu()
|
const module = router.getMenu()
|
||||||
const indexMenu = routerUtil.getIndexMenu(module).path
|
const indexMenu = routerUtil.getIndexMenu(module).path
|
||||||
// eslint-disable-next-line eqeqeq
|
|
||||||
const dashboardRoute = treeFind(module, (node) => node.path === indexMenu)
|
const dashboardRoute = treeFind(module, (node) => node.path === indexMenu)
|
||||||
if (dashboardRoute) {
|
if (dashboardRoute) {
|
||||||
dashboardRoute.fullPath = dashboardRoute.path
|
dashboardRoute.fullPath = dashboardRoute.path
|
||||||
|
@ -324,7 +323,6 @@
|
||||||
.ant-tabs-tab {
|
.ant-tabs-tab {
|
||||||
background: none;
|
background: none;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 40px;
|
|
||||||
transition:
|
transition:
|
||||||
background-color 0.3s,
|
background-color 0.3s,
|
||||||
color 0.3s;
|
color 0.3s;
|
||||||
|
@ -334,7 +332,7 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
.ant-tabs-tab-remove {
|
.ant-tabs-tab-remove {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 5px;
|
padding: 0 0 0 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ant-tabs-tab-active {
|
.ant-tabs-tab-active {
|
||||||
|
@ -447,7 +445,7 @@
|
||||||
.snowy-radius .ant-tabs-tab-active {
|
.snowy-radius .ant-tabs-tab-active {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
border-radius: 10px 10px 0 0 !important;
|
border-radius: 6px 6px 0 0 !important;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
12px 15px 0 0 var(--primary-1),
|
12px 15px 0 0 var(--primary-1),
|
||||||
-12px 15px 0 0 var(--primary-1);
|
-12px 15px 0 0 var(--primary-1);
|
||||||
|
@ -460,7 +458,7 @@
|
||||||
width: 13px;
|
width: 13px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background: var(--primary-radius);
|
background: var(--primary-radius);
|
||||||
border-radius: 0 0 20px 0;
|
border-radius: 0 0 8px 0;
|
||||||
}
|
}
|
||||||
.snowy-radius .ant-tabs-tab-active::after {
|
.snowy-radius .ant-tabs-tab-active::after {
|
||||||
content: '';
|
content: '';
|
||||||
|
@ -470,7 +468,7 @@
|
||||||
width: 13px;
|
width: 13px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background: var(--primary-radius);
|
background: var(--primary-radius);
|
||||||
border-radius: 0 0 0 20px;
|
border-radius: 0 0 0 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.snowy-radius .ant-tabs-ink-bar {
|
.snowy-radius .ant-tabs-ink-bar {
|
||||||
|
|
|
@ -544,11 +544,14 @@
|
||||||
const getParentKeys = (data, val) => {
|
const getParentKeys = (data, val) => {
|
||||||
const traverse = (array, val) => {
|
const traverse = (array, val) => {
|
||||||
// 递归父级key
|
// 递归父级key
|
||||||
|
if (!Array.isArray(array)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
for (const element of array) {
|
for (const element of array) {
|
||||||
if (element.path === val) {
|
if (element?.path === val) {
|
||||||
return [element.path]
|
return [element.path]
|
||||||
}
|
}
|
||||||
if (element.children) {
|
if (element?.children) {
|
||||||
const far = traverse(element.children, val)
|
const far = traverse(element.children, val)
|
||||||
if (far) {
|
if (far) {
|
||||||
return far.concat(element.path)
|
return far.concat(element.path)
|
||||||
|
|
|
@ -30,7 +30,7 @@ export function afterEach(to) {
|
||||||
}
|
}
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const store = viewTagsStore()
|
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) {
|
if (beforeRoute) {
|
||||||
adminMain.scrollTop = beforeRoute.scrollTop || 0
|
adminMain.scrollTop = beforeRoute.scrollTop || 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ export const viewTagsStore = defineStore('viewTags', () => {
|
||||||
}
|
}
|
||||||
const removeViewTags = (route) => {
|
const removeViewTags = (route) => {
|
||||||
viewTags.value.forEach((item, index) => {
|
viewTags.value.forEach((item, index) => {
|
||||||
if (item.fullPath === route.fullPath) {
|
if (item.path === route.path) {
|
||||||
viewTags.value.splice(index, 1)
|
viewTags.value.splice(index, 1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const updateViewTags = (route) => {
|
const updateViewTags = (route) => {
|
||||||
viewTags.value.forEach((item, index) => {
|
viewTags.value.forEach((item, index) => {
|
||||||
if (item.fullPath === route.fullPath) {
|
if (item.path === route.path) {
|
||||||
viewTags.value[index] = { ...route, ...item }
|
viewTags.value[index] = { ...route, ...item }
|
||||||
// Object.assign(item, route)
|
// Object.assign(item, route)
|
||||||
}
|
}
|
||||||
|
@ -49,14 +49,15 @@ export const viewTagsStore = defineStore('viewTags', () => {
|
||||||
const updateOrRemoveViewTags = (routes) => {
|
const updateOrRemoveViewTags = (routes) => {
|
||||||
if (routes && routes.length > 0) {
|
if (routes && routes.length > 0) {
|
||||||
viewTags.value.forEach((item, index) => {
|
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) {
|
if (!target) {
|
||||||
// 路由不存在,删除
|
// 路由不存在,删除
|
||||||
viewTags.value.splice(index, 1)
|
viewTags.value.splice(index, 1)
|
||||||
} else {
|
} else {
|
||||||
// 路由存在,更新
|
// 路由存在,更新
|
||||||
viewTags.value = viewTags.value.map((item) => {
|
viewTags.value = viewTags.value.map((item) => {
|
||||||
if (item.fullPath === target.path) {
|
if (item.path === target.path) {
|
||||||
return { ...item, meta: target.meta }
|
return { ...item, meta: target.meta }
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
|
|
|
@ -61,7 +61,7 @@ export default {
|
||||||
const tagList = [...store.viewTags]
|
const tagList = [...store.viewTags]
|
||||||
tagList.forEach((tag) => {
|
tagList.forEach((tag) => {
|
||||||
// eslint-disable-next-line prettier/prettier
|
// 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
|
return true
|
||||||
} else {
|
} else {
|
||||||
this.close(tag)
|
this.close(tag)
|
||||||
|
|
Loading…
Reference in New Issue