|
@@ -1,14 +1,8 @@
|
|
<template>
|
|
<template>
|
|
<div class="tags-container">
|
|
<div class="tags-container">
|
|
<el-scrollbar class="scroll-container" :vertical="false" @wheel.prevent="handleScroll">
|
|
<el-scrollbar class="scroll-container" :vertical="false" @wheel.prevent="handleScroll">
|
|
- <router-link
|
|
|
|
- ref="tagRef"
|
|
|
|
- v-for="tag in visitedViews"
|
|
|
|
- :key="tag.fullPath"
|
|
|
|
- :class="'tags-item ' + (isActive(tag) ? 'active' : '')"
|
|
|
|
- :to="{ path: tag.path, query: tag.query }"
|
|
|
|
- >
|
|
|
|
- <!-- @click.middle="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
|
|
|
|
|
+ <router-link ref="tagRef" v-for="tag in visitedViews" :key="tag.fullPath" :class="'tags-item ' + (isActive(tag) ? 'active' : '')" :to="{ path: tag.path, query: tag.query }">
|
|
|
|
+ <!-- @click.middle="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
|
@contextmenu.prevent="openContentMenu(tag, $event)" -->
|
|
@contextmenu.prevent="openContentMenu(tag, $event)" -->
|
|
{{ translateRouteTitle(tag.title) }}
|
|
{{ translateRouteTitle(tag.title) }}
|
|
<SvgIcon class="close-icon" icon-class="close" v-if="!isAffix(tag)" @click.prevent.stop="closeSelectedTag(tag)"></SvgIcon>
|
|
<SvgIcon class="close-icon" icon-class="close" v-if="!isAffix(tag)" @click.prevent.stop="closeSelectedTag(tag)"></SvgIcon>
|
|
@@ -45,6 +39,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
|
+import { get } from 'lodash-es'
|
|
import { ref, watch, onMounted, getCurrentInstance, computed } from 'vue'
|
|
import { ref, watch, onMounted, getCurrentInstance, computed } from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import defaultSettings from '@/settings'
|
|
import defaultSettings from '@/settings'
|
|
@@ -52,7 +47,9 @@ import { storeToRefs } from 'pinia'
|
|
import { resolve } from 'path-browserify'
|
|
import { resolve } from 'path-browserify'
|
|
import { translateRouteTitle } from '@/utils/i18n'
|
|
import { translateRouteTitle } from '@/utils/i18n'
|
|
import { useTagsViewStore } from '@/store'
|
|
import { useTagsViewStore } from '@/store'
|
|
-
|
|
|
|
|
|
+import { UserStore } from '@/store/user'
|
|
|
|
+const userStore = UserStore()
|
|
|
|
+const menus = computed(() => userStore.menus)
|
|
const { proxy } = getCurrentInstance()
|
|
const { proxy } = getCurrentInstance()
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
@@ -123,25 +120,27 @@ function filterAffixTags(routes, basePath = '/') {
|
|
}
|
|
}
|
|
|
|
|
|
function initTags() {
|
|
function initTags() {
|
|
- const tags = filterAffixTags([])
|
|
|
|
- affixTags.value = tags
|
|
|
|
- for (const tag of tags) {
|
|
|
|
- // Must have tag name
|
|
|
|
- if (tag.name) {
|
|
|
|
- tagsViewStore.addVisitedView(tag)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // const tags = filterAffixTags([])
|
|
|
|
+ // affixTags.value = tags
|
|
|
|
+ // for (const tag of tags) {
|
|
|
|
+ // // Must have tag name
|
|
|
|
+ // if (tag.name) {
|
|
|
|
+ // tagsViewStore.addVisitedView(tag)
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
function addTags() {
|
|
function addTags() {
|
|
- if (route.meta.title) {
|
|
|
|
|
|
+ const nowPath = route.path
|
|
|
|
+ const menu = menus.value.find((f) => f.path === nowPath)
|
|
|
|
+ if (menu) {
|
|
tagsViewStore.addView({
|
|
tagsViewStore.addView({
|
|
- name: route.name,
|
|
|
|
- title: t(route.meta.title),
|
|
|
|
- path: route.path,
|
|
|
|
- fullPath: route.fullPath,
|
|
|
|
- affix: route.meta?.affix,
|
|
|
|
- keepAlive: route.meta?.keepAlive
|
|
|
|
|
|
+ name: get(menu, 'route_name'),
|
|
|
|
+ title: get(menu, 'name'),
|
|
|
|
+ path: get(menu, 'path'),
|
|
|
|
+ fullPath: get(menu, 'path'),
|
|
|
|
+ affix: true,
|
|
|
|
+ keepAlive: true
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|