refactor: 重构标签栏右键菜单定位方式

This commit is contained in:
pany 2024-11-15 16:53:18 +08:00
parent 7748dc0fa4
commit 4f4b4892b9
2 changed files with 6 additions and 10 deletions

View File

@ -58,7 +58,6 @@ $transition-time: 0.35s;
}
.content {
flex: 1;
position: relative;
overflow: hidden;
}
}

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { getCurrentInstance, ref, watch } from "vue"
import { ref, watch } from "vue"
import { type RouteLocationNormalizedLoaded, type RouteRecordRaw, RouterLink, useRoute, useRouter } from "vue-router"
import { type TagView, useTagsViewStore } from "@/store/modules/tags-view"
import { usePermissionStore } from "@/store/modules/permission"
@ -8,7 +8,6 @@ import path from "path-browserify"
import ScrollPane from "./ScrollPane.vue"
import { Close } from "@element-plus/icons-vue"
const instance = getCurrentInstance()
const router = useRouter()
const route = useRoute()
const tagsViewStore = useTagsViewStore()
@ -127,15 +126,13 @@ const toLastView = (visitedViews: TagView[], view: TagView) => {
/** 打开右键菜单面板 */
const openMenu = (tag: TagView, e: MouseEvent) => {
const menuMinWidth = 105
//
const offsetLeft = instance!.proxy!.$el.getBoundingClientRect().left
//
const offsetWidth = instance!.proxy!.$el.offsetWidth
const menuMinWidth = 100
//
const offsetWidth = document.body.offsetWidth
//
const maxLeft = offsetWidth - menuMinWidth
//
const left15 = e.clientX - offsetLeft + 15
const left15 = e.clientX + 10
left.value = left15 > maxLeft ? maxLeft : left15
top.value = e.clientY
//
@ -234,7 +231,7 @@ listenerRouteChange((route) => {
.contextmenu {
margin: 0;
z-index: 3000;
position: absolute;
position: fixed;
list-style-type: none;
padding: 5px 0;
border-radius: 4px;