Skip to content

Commit 6fe7349

Browse files
committed
fix the tagsview menu top issue
1 parent dd2d8c4 commit 6fe7349

File tree

4 files changed

+60
-57
lines changed

4 files changed

+60
-57
lines changed

src/layout/app-main/TagsView.vue

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,45 @@
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>
3439
import { getCurrentInstance, nextTick, onMounted, reactive, toRefs, watch } from 'vue'
3540
import { Close } from '@element-plus/icons-vue'
3641
import { resolve } from 'path-browserify'
3742
import { useRoute, useRouter } from 'vue-router'
3843
import { storeToRefs } from 'pinia/dist/pinia'
39-
import type { RouterTypes } from '~/basic'
4044
import { useBasicStore } from '@/store/basic'
4145
import { useTagsViewStore } from '@/store/tags-view'
4246
import { 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
5357
const { visitedViews } = storeToRefs(useTagsViewStore())
5458
5559
watch(
56-
() => route.path,
57-
() => {
58-
addTags()
59-
}
60+
() => route.path,
61+
() => {
62+
addTags()
63+
}
6064
)
6165
6266
watch(
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
)
7276
onMounted(() => {
7377
initTags()
@@ -84,7 +88,7 @@ const isAffix = (tag) => {
8488
}
8589
8690
const 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 {

src/views/dashboard/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242
</div>
4343
</template>
44-
<script setup lang="ts">
44+
<script setup>
4545
import { ref } from 'vue'
4646
import { useRoute } from 'vue-router'
4747
import { useConfigStore } from '@/store/config'

tsconfig.json

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
{
2-
"extends": "./tsconfig.base.json",
3-
"compilerOptions": {
4-
"baseUrl": ".",
5-
"paths": {
6-
"@/*": [
7-
"src/*"
8-
],
9-
"~/*": [
10-
"typings/*"
11-
]
12-
}
13-
},
14-
"include": [
15-
"src",
16-
"typings"
17-
],
18-
"exclude": [
19-
"node_modules",
20-
"**/dist"
21-
]
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"paths": {
5+
"@/*": ["src/*"],
6+
"~/*": ["typings/*"]
7+
}
8+
},
9+
"include": ["src", "typings"],
10+
"exclude": ["node_modules", "**/dist"]
2211
}

typings/env.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ declare global {
33
readonly VITE_APP_BASE_URL: string
44
readonly VITE_APP_IMAGE_URL: string
55
readonly VITE_APP_ENV: string
6-
readonly VITE_PROXY_BASE_URL: string
7-
readonly VITE_PROXY_URL: string
86
// 更多环境变量...
97
}
108
interface ImportMeta {

0 commit comments

Comments
 (0)