|
|
@@ -30,6 +30,7 @@ import { ref, computed, getCurrentInstance, onUnmounted, nextTick } from 'vue'
|
|
|
|
|
|
// 导入 cwg-droplist-item 以便在组件内部直接使用
|
|
|
import CwgDroplistItem from './cwg-droplist-item.vue'
|
|
|
+import { useWindowWidth } from '@/composables/useWindowWidth'
|
|
|
|
|
|
const props = defineProps({
|
|
|
// 传入的菜单列表,支持简单数组 ['A', 'B'] 或对象数组 [{ label: 'A', command: 'a', disabled: true, row: row }]
|
|
|
@@ -62,6 +63,8 @@ const props = defineProps({
|
|
|
const emit = defineEmits(['visible-change', 'command', 'menuClick'])
|
|
|
|
|
|
const instance = getCurrentInstance()
|
|
|
+const windowWidth = useWindowWidth(300)
|
|
|
+const isMobile = computed(() => windowWidth.value <= 990)
|
|
|
const isShow = ref(false)
|
|
|
const menuStyle = ref({})
|
|
|
|
|
|
@@ -142,7 +145,7 @@ const openMenu = async () => {
|
|
|
finalTop = bottom + props.offset
|
|
|
}
|
|
|
} else { // bottom
|
|
|
- finalTop = bottom + props.offset
|
|
|
+ finalTop = bottom + (isMobile.value ? 4 : props.offset)
|
|
|
// 防溢出检测:如果下方空间不够,且上方空间足够,向上翻转
|
|
|
if (finalTop + menuHeight > windowHeight && top - menuHeight - props.offset > 0) {
|
|
|
finalTop = top - menuHeight - props.offset
|