Skip to content

Commit 608224d

Browse files
committed
fix tagsView menu
1 parent bfdf35a commit 608224d

File tree

3 files changed

+52
-35
lines changed

3 files changed

+52
-35
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "vu3-admin-ts",
2+
"name": "vue3-admin-ts",
33
"version": "2.2.0",
44
"license": "MIT",
55
"author": "kuanghua(869653722@qq.com)",

src/layout/app-main/TagsView.vue

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@
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

@@ -53,21 +58,21 @@ const state = reactive({
5358
const { visitedViews } = storeToRefs(useTagsViewStore())
5459
5560
watch(
56-
() => route.path,
57-
() => {
58-
addTags()
59-
}
61+
() => route.path,
62+
() => {
63+
addTags()
64+
}
6065
)
6166
6267
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+
}
6975
}
70-
}
7176
)
7277
onMounted(() => {
7378
initTags()
@@ -140,7 +145,7 @@ const openMenu = (tag, e) => {
140145
} else {
141146
state.left = left
142147
}
143-
state.top = e.clientY
148+
state.top =16
144149
state.visible = true
145150
state.selectedTag = tag
146151
}
@@ -160,7 +165,7 @@ const closeSelectedTag = (view) => {
160165
basicStore.delCachedView(view.name)
161166
}
162167
if (routerLevel === 3) {
163-
basicStore.setCacheViewDeep(view.name)
168+
basicStore.delCacheViewDeep(view.name)
164169
}
165170
}
166171
})
@@ -215,14 +220,24 @@ const { visible, top, left, selectedTag } = toRefs(state)
215220
</script>
216221

217222
<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+
}
218233
.tags-view-container {
219234
height: var(--tag-view-height);
220235
width: 100%;
236+
position: relative;
237+
z-index: 10;
221238
background: var(--tags-view-background);
222239
border-bottom: 1px solid var(--tags-view-border-bottom);
223240
box-shadow: var(--tags-view-box-shadow);
224-
position: relative;
225-
z-index: 0;
226241
.tags-view-wrapper {
227242
.tags-view-item {
228243
display: inline-block;
@@ -263,6 +278,7 @@ const { visible, top, left, selectedTag } = toRefs(state)
263278
.contextmenu {
264279
margin: 0;
265280
background: var(--tags-view-contextmenu-background);
281+
z-index: 3000;
266282
position: absolute;
267283
list-style-type: none;
268284
padding: 5px 0;
@@ -284,6 +300,8 @@ const { visible, top, left, selectedTag } = toRefs(state)
284300
</style>
285301

286302
<style lang="scss">
303+
304+
287305
//reset element css of el-icon-close
288306
.tags-view-wrapper {
289307
.tags-view-item {

vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ export default defineConfig(({ command, mode }) => {
111111
},
112112
resolve: {
113113
alias: {
114-
'@/': `${pathSrc}/`,
115-
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js' //remove i18n waring
114+
'@/': `${pathSrc}/`
116115
}
117116
},
118117
optimizeDeps: {

0 commit comments

Comments
 (0)