2
2
<div id =" tags-view-container" class =" tags-view-container" >
3
3
<div class =" tags-view-wrapper" >
4
4
<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
11
11
>
12
12
<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"
18
18
>
19
19
{{ langTitle(tag.title) }}
20
20
<Close v-if =" !isAffix(tag)" class =" el-icon-close" @click.prevent.stop =" closeSelectedTag(tag)" />
21
21
</div >
22
22
</router-link >
23
23
</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
+
30
35
</div >
31
36
</template >
32
37
@@ -53,21 +58,21 @@ const state = reactive({
53
58
const { visitedViews } = storeToRefs (useTagsViewStore ())
54
59
55
60
watch (
56
- () => route .path ,
57
- () => {
58
- addTags ()
59
- }
61
+ () => route .path ,
62
+ () => {
63
+ addTags ()
64
+ }
60
65
)
61
66
62
67
watch (
63
- () => state .visible ,
64
- (value ) => {
65
- if (value ) {
66
- document .body .addEventListener (' click' , closeMenu )
67
- } else {
68
- document .body .removeEventListener (' click' , closeMenu )
68
+ () => state .visible ,
69
+ (value ) => {
70
+ if (value ) {
71
+ document .body .addEventListener (' click' , closeMenu )
72
+ } else {
73
+ document .body .removeEventListener (' click' , closeMenu )
74
+ }
69
75
}
70
- }
71
76
)
72
77
onMounted (() => {
73
78
initTags ()
@@ -140,7 +145,7 @@ const openMenu = (tag, e) => {
140
145
} else {
141
146
state .left = left
142
147
}
143
- state .top = e . clientY
148
+ state .top = 16
144
149
state .visible = true
145
150
state .selectedTag = tag
146
151
}
@@ -160,7 +165,7 @@ const closeSelectedTag = (view) => {
160
165
basicStore .delCachedView (view .name )
161
166
}
162
167
if (routerLevel === 3 ) {
163
- basicStore .setCacheViewDeep (view .name )
168
+ basicStore .delCacheViewDeep (view .name )
164
169
}
165
170
}
166
171
})
@@ -215,14 +220,24 @@ const { visible, top, left, selectedTag } = toRefs(state)
215
220
</script >
216
221
217
222
<style lang="scss" scoped>
223
+ // 三角形汽包
224
+ .triangle {
225
+ position : relative ;
226
+ width : 0 ;
227
+ height : 0 ;
228
+ left : 10px ;
229
+ border : 8px solid transparent ;
230
+ border-bottom-color : #eee ;
231
+ opacity :0.4 ;
232
+ }
218
233
.tags-view-container {
219
234
height : var (--tag-view-height );
220
235
width : 100% ;
236
+ position : relative ;
237
+ z-index : 10 ;
221
238
background : var (--tags-view-background );
222
239
border-bottom : 1px solid var (--tags-view-border-bottom );
223
240
box-shadow : var (--tags-view-box-shadow );
224
- position : relative ;
225
- z-index : 0 ;
226
241
.tags-view-wrapper {
227
242
.tags-view-item {
228
243
display : inline-block ;
@@ -263,6 +278,7 @@ const { visible, top, left, selectedTag } = toRefs(state)
263
278
.contextmenu {
264
279
margin : 0 ;
265
280
background : var (--tags-view-contextmenu-background );
281
+ z-index : 3000 ;
266
282
position : absolute ;
267
283
list-style-type : none ;
268
284
padding : 5px 0 ;
@@ -284,6 +300,8 @@ const { visible, top, left, selectedTag } = toRefs(state)
284
300
</style >
285
301
286
302
<style lang="scss">
303
+
304
+
287
305
// reset element css of el-icon-close
288
306
.tags-view-wrapper {
289
307
.tags-view-item {
0 commit comments