From b312b5a5bc827a8199d5a7b36418f0ad933be081 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 28 Oct 2025 14:24:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(design,=20element-plus-adapter,=20tdesign-?= =?UTF-8?q?vue-next-adapter):=20=E6=B7=BB=E5=8A=A0adapterType,=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84tdesign=20useZIndex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/design/src/types.ts | 1 + packages/element-plus-adapter/src/index.ts | 1 + .../tdesign-vue-next-adapter/src/index.ts | 27 ++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/design/src/types.ts b/packages/design/src/types.ts index f10f6d8d..e18a0ae0 100644 --- a/packages/design/src/types.ts +++ b/packages/design/src/types.ts @@ -712,6 +712,7 @@ export interface Components { } export interface DesignPluginOptions { + adapterType?: string; message?: TMagicMessage; messageBox?: TMagicMessageBox; components?: Components; diff --git a/packages/element-plus-adapter/src/index.ts b/packages/element-plus-adapter/src/index.ts index d98f1c65..fd5b3362 100644 --- a/packages/element-plus-adapter/src/index.ts +++ b/packages/element-plus-adapter/src/index.ts @@ -94,6 +94,7 @@ import FormItem from './FormItem.vue'; import Table from './Table.vue'; const adapter: DesignPluginOptions = { + adapterType: 'element-plus', useZIndex, message: ElMessage, messageBox: ElMessageBox, diff --git a/packages/tdesign-vue-next-adapter/src/index.ts b/packages/tdesign-vue-next-adapter/src/index.ts index ddc4ba61..075e2e36 100644 --- a/packages/tdesign-vue-next-adapter/src/index.ts +++ b/packages/tdesign-vue-next-adapter/src/index.ts @@ -1,4 +1,4 @@ -import { h } from 'vue'; +import { computed, h, Ref, ref, unref } from 'vue'; import { Badge as TBadge, Button as TButton, @@ -104,7 +104,31 @@ messageBox.error = MessagePlugin.error; messageBox.warning = MessagePlugin.warning; messageBox.info = MessagePlugin.info; +const zIndex = ref(0); +const DEFAULT_INITIAL_Z_INDEX = 2500; + +const useZIndex = (zIndexOverrides?: Ref) => { + const zIndexInjection = zIndexOverrides; + const initialZIndex = computed(() => { + const zIndexFromInjection = unref(zIndexInjection); + return zIndexFromInjection ?? DEFAULT_INITIAL_Z_INDEX; + }); + const currentZIndex = computed(() => initialZIndex.value + zIndex.value); + + const nextZIndex = () => { + zIndex.value += 1; + return currentZIndex.value; + }; + + return { + initialZIndex, + currentZIndex, + nextZIndex, + }; +}; + const adapter: any = { + adapterType: 'tdesign-vue-next', message: messageBox, messageBox: { alert: (msg: string, title?: string) => { @@ -502,6 +526,7 @@ const adapter: any = { }, }, loading: LoadingDirective, + useZIndex, }; export default adapter;