22 <div id =" tags-view-container" class =" tags-view-container" >
33 <div class =" tags-view-wrapper" >
44 <router-link
5- v-for =" tag in visitedViews"
6- ref =" refTag"
7- :key =" tag.path"
8- v-slot =" { navigate }"
9- :to =" { path: tag.path, query: tag.query, fullPath: tag.fullPath }"
10- custom
5+ v-for =" tag in visitedViews"
6+ ref =" refTag"
7+ :key =" tag.path"
8+ v-slot =" { navigate }"
9+ :to =" { path: tag.path, query: tag.query, fullPath: tag.fullPath }"
10+ custom
1111 >
1212 <div
13- class =" tags-view-item"
14- :class =" isActive(tag) ? 'active' : ''"
15- @click.middle =" !isAffix(tag) ? closeSelectedTag(tag) : ''"
16- @contextmenu.prevent =" openMenu(tag, $event)"
17- @click =" navigate"
13+ class =" tags-view-item"
14+ :class =" isActive(tag) ? 'active' : ''"
15+ @click.middle =" !isAffix(tag) ? closeSelectedTag(tag) : ''"
16+ @contextmenu.prevent =" openMenu(tag, $event)"
17+ @click =" navigate"
1818 >
1919 {{ langTitle(tag.title) }}
2020 <Close v-if =" !isAffix(tag)" class =" el-icon-close" @click.prevent.stop =" closeSelectedTag(tag)" />
2121 </div >
2222 </router-link >
2323 </div >
24- <ul v-show =" visible" :style =" { left: left + 'px', top: top + 'px' }" class =" contextmenu" >
25- <li @click =" refreshSelectedTag(selectedTag)" >{{ langTitle('Refresh') }}</li >
26- <li v-if =" !isAffix(selectedTag)" @click =" closeSelectedTag(selectedTag)" >{{ langTitle('Close') }}</li >
27- <li @click =" closeOthersTags" >{{ langTitle('Close Others') }}</li >
28- <li @click =" closeAllTags(selectedTag)" >{{ langTitle('Close All') }}</li >
29- </ul >
24+ <div style =" position :relative ;top :-6px " >
25+ <div v-show =" visible" class =" triangle" :style =" {left: left + 'px'}" />
26+ <ul v-show =" visible" :style =" { left: left + 'px', top: top + 'px' }" class =" contextmenu" >
27+
28+ <li @click =" refreshSelectedTag(selectedTag)" >{{ langTitle('Refresh') }}</li >
29+ <li v-if =" !isAffix(selectedTag)" @click =" closeSelectedTag(selectedTag)" >{{ langTitle('Close') }}</li >
30+ <li @click =" closeOthersTags" >{{ langTitle('Close Others') }}</li >
31+ <li @click =" closeAllTags(selectedTag)" >{{ langTitle('Close All') }}</li >
32+ </ul >
33+ </div >
34+
3035 </div >
3136</template >
3237
33- <script setup lang="ts" >
38+ <script setup>
3439import { getCurrentInstance , nextTick , onMounted , reactive , toRefs , watch } from ' vue'
3540import { Close } from ' @element-plus/icons-vue'
3641import { resolve } from ' path-browserify'
3742import { useRoute , useRouter } from ' vue-router'
3843import { storeToRefs } from ' pinia/dist/pinia'
39- import type { RouterTypes } from ' ~/basic'
4044import { useBasicStore } from ' @/store/basic'
4145import { useTagsViewStore } from ' @/store/tags-view'
4246import { langTitle } from ' @/hooks/use-common'
@@ -47,27 +51,27 @@ const state = reactive({
4751 top: 0 ,
4852 left: 0 ,
4953 selectedTag: {},
50- affixTags: [] as RouterTypes
54+ affixTags: []
5155})
5256
5357const { visitedViews } = storeToRefs (useTagsViewStore ())
5458
5559watch (
56- () => route .path ,
57- () => {
58- addTags ()
59- }
60+ () => route .path ,
61+ () => {
62+ addTags ()
63+ }
6064)
6165
6266watch (
63- () => state .visible ,
64- (value ) => {
65- if (value ) {
66- document .body .addEventListener (' click' , closeMenu )
67- } else {
68- document .body .removeEventListener (' click' , closeMenu )
67+ () => state .visible ,
68+ (value ) => {
69+ if (value) {
70+ document .body .addEventListener (' click' , closeMenu)
71+ } else {
72+ document .body .removeEventListener (' click' , closeMenu)
73+ }
6974 }
70- }
7175)
7276onMounted (() => {
7377 initTags ()
@@ -84,7 +88,7 @@ const isAffix = (tag) => {
8488}
8589
8690const filterAffixTags = (routes , basePath = ' /' ) => {
87- let tags: RouterTypes = []
91+ let tags = []
8892 routes .forEach ((route ) => {
8993 if (route .meta && route .meta .affix ) {
9094 const tagPath = resolve (basePath, route .path )
@@ -140,7 +144,7 @@ const openMenu = (tag, e) => {
140144 } else {
141145 state .left = left
142146 }
143- state .top = e . clientY
147+ state .top = 16
144148 state .visible = true
145149 state .selectedTag = tag
146150}
@@ -160,7 +164,7 @@ const closeSelectedTag = (view) => {
160164 basicStore .delCachedView (view .name )
161165 }
162166 if (routerLevel === 3 ) {
163- basicStore .setCacheViewDeep (view .name )
167+ basicStore .delCacheViewDeep (view .name )
164168 }
165169 }
166170 })
@@ -215,6 +219,16 @@ const { visible, top, left, selectedTag } = toRefs(state)
215219< / script>
216220
217221< style lang= " scss" scoped>
222+ // 三角形汽包
223+ .triangle {
224+ position: relative;
225+ width: 0 ;
226+ height: 0 ;
227+ left: 10px ;
228+ border: 8px solid transparent;
229+ border- bottom- color: #eee;
230+ opacity: 0.4 ;
231+ }
218232.tags - view- container {
219233 height: var (-- tag- view- height);
220234 width: 100 % ;
@@ -285,6 +299,8 @@ const { visible, top, left, selectedTag } = toRefs(state)
285299< / style>
286300
287301< style lang= " scss" >
302+
303+
288304// reset element css of el-icon-close
289305.tags - view- wrapper {
290306 .tags - view- item {
0 commit comments