Skip to content

Commit

Permalink
feat: support custom z-index
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Dec 15, 2024
1 parent 6a46a24 commit 4e31cd8
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<script setup lang="ts">
import type { AuthenticationProps } from './types';
import { watch } from 'vue';
import { computed, watch } from 'vue';
import { useVbenModal } from '@vben-core/popup-ui';
import { Slot, VbenAvatar } from '@vben-core/shadcn-ui';
interface Props extends AuthenticationProps {
avatar?: string;
zIndex?: number;
}
defineOptions({
name: 'LoginExpiredModal',
});
withDefaults(defineProps<Props>(), {
const props = withDefaults(defineProps<Props>(), {
avatar: '',
zIndex: 0,
});
const open = defineModel<boolean>('open');
Expand All @@ -29,10 +31,14 @@ watch(
},
);
const getZIndex = computed(() => {
return props.zIndex || calcZIndex();
});
/**
* 获取最大的zIndex值
*/
function getMaxZIndex() {
function calcZIndex() {
let maxZ = 0;
const elements = document.querySelectorAll('*');
[...elements].forEach((element) => {
Expand All @@ -55,7 +61,7 @@ function getMaxZIndex() {
:footer="false"
:fullscreen-button="false"
:header="false"
:z-index="getMaxZIndex()"
:z-index="getZIndex"
class="border-none px-10 py-6 text-center shadow-xl sm:w-[600px] sm:rounded-2xl md:h-[unset]"
>
<VbenAvatar :src="avatar" class="mx-auto mb-6 size-20" />
Expand Down

0 comments on commit 4e31cd8

Please sign in to comment.