From 95a4a85c3ba8cdf88b752d8f2d1f0377cafd4103 Mon Sep 17 00:00:00 2001 From: invalid w Date: Tue, 3 Sep 2024 13:02:19 +0800 Subject: [PATCH] chore(@vben-core/tabs-ui): cancel drag and drop function on mobile devices (#4303) resolve #4301 --- packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts b/packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts index eb980360..acefbfea 100644 --- a/packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts +++ b/packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts @@ -4,7 +4,11 @@ import type { TabsProps } from './types'; import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'; -import { type Sortable, useSortable } from '@vben-core/composables'; +import { + type Sortable, + useIsMobile, + useSortable, +} from '@vben-core/composables'; // 可能会找到拖拽的子元素,这里需要确保拖拽的dom时tab元素 function findParentElement(element: HTMLElement) { @@ -90,6 +94,12 @@ export function useTabsDrag(props: TabsProps, emit: EmitType) { } async function init() { + const { isMobile } = useIsMobile(); + + // 移动端下tab不需要拖拽 + if (isMobile.value) { + return; + } await nextTick(); initTabsSortable(); }