Skip to content

Commit

Permalink
refactor: 重构标签栏右键菜单定位方式
Browse files Browse the repository at this point in the history
  • Loading branch information
pany-ang committed Nov 15, 2024
1 parent 7748dc0 commit 4f4b489
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/layouts/LeftTopMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ $transition-time: 0.35s;
}
.content {
flex: 1;
position: relative;
overflow: hidden;
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/layouts/components/TagsView/index.vue
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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
// 显示面板
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4f4b489

Please sign in to comment.