From 13087a10b70e72f3aa74afbb023fb19a993d1696 Mon Sep 17 00:00:00 2001 From: Netfan Date: Wed, 15 Jan 2025 12:32:03 +0800 Subject: [PATCH] refactor: fix popup component zIndex (#5397) --- apps/web-antd/src/bootstrap.ts | 23 ++++++++----------- apps/web-ele/src/bootstrap.ts | 23 ++++++++----------- apps/web-naive/src/bootstrap.ts | 23 ++++++++----------- packages/@core/base/design/src/css/ui.css | 4 ++++ .../base/design/src/design-tokens/default.css | 2 ++ .../src/components/back-top/back-top.vue | 2 +- .../components/context-menu/context-menu.vue | 2 +- .../src/components/hover-card/hover-card.vue | 2 +- .../src/components/popover/popover.vue | 2 +- .../ui/context-menu/ContextMenuContent.vue | 2 +- .../shadcn-ui/src/ui/dialog/DialogContent.vue | 8 +++---- .../shadcn-ui/src/ui/dialog/DialogOverlay.vue | 2 +- .../ui/dropdown-menu/DropdownMenuContent.vue | 2 +- .../src/ui/hover-card/HoverCardContent.vue | 2 +- .../shadcn-ui/src/ui/select/SelectContent.vue | 2 +- .../shadcn-ui/src/ui/sheet/SheetContent.vue | 7 +++--- .../shadcn-ui/src/ui/sheet/SheetOverlay.vue | 2 +- .../src/ui/tooltip/TooltipContent.vue | 2 +- .../effects/hooks/src/use-design-tokens.ts | 1 + packages/styles/src/antd/index.css | 2 +- playground/src/bootstrap.ts | 23 ++++++++----------- 21 files changed, 62 insertions(+), 76 deletions(-) diff --git a/apps/web-antd/src/bootstrap.ts b/apps/web-antd/src/bootstrap.ts index 780363c29..b46bfbcf2 100644 --- a/apps/web-antd/src/bootstrap.ts +++ b/apps/web-antd/src/bootstrap.ts @@ -1,11 +1,7 @@ import { createApp, watchEffect } from 'vue'; import { registerAccessDirective } from '@vben/access'; -import { - initTippy, - setDefaultDrawerProps, - setDefaultModalProps, -} from '@vben/common-ui'; +import { initTippy } from '@vben/common-ui'; import { preferences } from '@vben/preferences'; import { initStores } from '@vben/stores'; import '@vben/styles'; @@ -23,15 +19,14 @@ async function bootstrap(namespace: string) { // 初始化组件适配器 await initComponentAdapter(); - // 设置弹窗的默认配置 - setDefaultModalProps({ - fullscreenButton: false, - zIndex: 1020, - }); - // 设置抽屉的默认配置 - setDefaultDrawerProps({ - zIndex: 1020, - }); + // // 设置弹窗的默认配置 + // setDefaultModalProps({ + // fullscreenButton: false, + // }); + // // 设置抽屉的默认配置 + // setDefaultDrawerProps({ + // zIndex: 1020, + // }); const app = createApp(App); diff --git a/apps/web-ele/src/bootstrap.ts b/apps/web-ele/src/bootstrap.ts index 7edc070b7..b62094f28 100644 --- a/apps/web-ele/src/bootstrap.ts +++ b/apps/web-ele/src/bootstrap.ts @@ -1,11 +1,7 @@ import { createApp, watchEffect } from 'vue'; import { registerAccessDirective } from '@vben/access'; -import { - initTippy, - setDefaultDrawerProps, - setDefaultModalProps, -} from '@vben/common-ui'; +import { initTippy } from '@vben/common-ui'; import { preferences } from '@vben/preferences'; import { initStores } from '@vben/stores'; import '@vben/styles'; @@ -23,15 +19,14 @@ import { router } from './router'; async function bootstrap(namespace: string) { // 初始化组件适配器 await initComponentAdapter(); - // 设置弹窗的默认配置 - setDefaultModalProps({ - fullscreenButton: false, - zIndex: 2000, - }); - // 设置抽屉的默认配置 - setDefaultDrawerProps({ - zIndex: 2000, - }); + // // 设置弹窗的默认配置 + // setDefaultModalProps({ + // fullscreenButton: false, + // }); + // // 设置抽屉的默认配置 + // setDefaultDrawerProps({ + // zIndex: 2000, + // }); const app = createApp(App); // 注册Element Plus提供的v-loading指令 diff --git a/apps/web-naive/src/bootstrap.ts b/apps/web-naive/src/bootstrap.ts index 9e9ac2530..a423bff4d 100644 --- a/apps/web-naive/src/bootstrap.ts +++ b/apps/web-naive/src/bootstrap.ts @@ -1,11 +1,7 @@ import { createApp, watchEffect } from 'vue'; import { registerAccessDirective } from '@vben/access'; -import { - initTippy, - setDefaultDrawerProps, - setDefaultModalProps, -} from '@vben/common-ui'; +import { initTippy } from '@vben/common-ui'; import { preferences } from '@vben/preferences'; import { initStores } from '@vben/stores'; import '@vben/styles'; @@ -23,15 +19,14 @@ async function bootstrap(namespace: string) { // 初始化组件适配器 initComponentAdapter(); - // 设置弹窗的默认配置 - setDefaultModalProps({ - fullscreenButton: false, - zIndex: 2000, - }); - // 设置抽屉的默认配置 - setDefaultDrawerProps({ - zIndex: 2000, - }); + // // 设置弹窗的默认配置 + // setDefaultModalProps({ + // fullscreenButton: false, + // }); + // // 设置抽屉的默认配置 + // setDefaultDrawerProps({ + // // zIndex: 2000, + // }); const app = createApp(App); diff --git a/packages/@core/base/design/src/css/ui.css b/packages/@core/base/design/src/css/ui.css index 3a002f2af..f7119c8ba 100644 --- a/packages/@core/base/design/src/css/ui.css +++ b/packages/@core/base/design/src/css/ui.css @@ -81,3 +81,7 @@ transform: translateY(0); } } + +.z-popup { + z-index: var(--popup-z-index); +} diff --git a/packages/@core/base/design/src/design-tokens/default.css b/packages/@core/base/design/src/design-tokens/default.css index c81ace7ea..6fb71f176 100644 --- a/packages/@core/base/design/src/design-tokens/default.css +++ b/packages/@core/base/design/src/design-tokens/default.css @@ -1,4 +1,6 @@ :root { + /** 弹出层的基础层级 **/ + --popup-z-index: 2000; --font-family: -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue', arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue b/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue index 115b5b3af..1f8b0bc77 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue @@ -32,7 +32,7 @@ const { handleClick, visible } = useBackTop(props);