parent
8ba7bdf2bd
commit
c0962fec18
@ -1,7 +1,15 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { DrawerProps, ExtendedDrawerApi } from './drawer';
|
import type { DrawerProps, ExtendedDrawerApi } from './drawer';
|
||||||
|
|
||||||
import { computed, provide, ref, unref, useId, watch } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
onDeactivated,
|
||||||
|
provide,
|
||||||
|
ref,
|
||||||
|
unref,
|
||||||
|
useId,
|
||||||
|
watch,
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useIsMobile,
|
useIsMobile,
|
||||||
@ -94,6 +102,16 @@ const {
|
|||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
||||||
|
*/
|
||||||
|
onDeactivated(() => {
|
||||||
|
// 如果弹窗没有被挂载到内容区域,则关闭弹窗
|
||||||
|
if (!appendToMain.value) {
|
||||||
|
props.drawerApi?.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function interactOutside(e: Event) {
|
function interactOutside(e: Event) {
|
||||||
if (!closeOnClickModal.value || submitting.value) {
|
if (!closeOnClickModal.value || submitting.value) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -9,7 +9,6 @@ import {
|
|||||||
h,
|
h,
|
||||||
inject,
|
inject,
|
||||||
nextTick,
|
nextTick,
|
||||||
onDeactivated,
|
|
||||||
provide,
|
provide,
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
@ -72,13 +71,6 @@ export function useVbenDrawer<
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
|
||||||
*/
|
|
||||||
onDeactivated(() => {
|
|
||||||
(extendedApi as ExtendedDrawerApi)?.close?.();
|
|
||||||
});
|
|
||||||
|
|
||||||
return [Drawer, extendedApi as ExtendedDrawerApi] as const;
|
return [Drawer, extendedApi as ExtendedDrawerApi] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExtendedModalApi, ModalProps } from './modal';
|
import type { ExtendedModalApi, ModalProps } from './modal';
|
||||||
|
|
||||||
import { computed, nextTick, provide, ref, unref, useId, watch } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
nextTick,
|
||||||
|
onDeactivated,
|
||||||
|
provide,
|
||||||
|
ref,
|
||||||
|
unref,
|
||||||
|
useId,
|
||||||
|
watch,
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useIsMobile,
|
useIsMobile,
|
||||||
@ -135,6 +144,16 @@ watch(
|
|||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
||||||
|
*/
|
||||||
|
onDeactivated(() => {
|
||||||
|
// 如果弹窗没有被挂载到内容区域,则关闭弹窗
|
||||||
|
if (!appendToMain.value) {
|
||||||
|
props.modalApi?.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function handleFullscreen() {
|
function handleFullscreen() {
|
||||||
props.modalApi?.setState((prev) => {
|
props.modalApi?.setState((prev) => {
|
||||||
// if (prev.fullscreen) {
|
// if (prev.fullscreen) {
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
h,
|
h,
|
||||||
inject,
|
inject,
|
||||||
nextTick,
|
nextTick,
|
||||||
onDeactivated,
|
|
||||||
provide,
|
provide,
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
@ -71,13 +70,6 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
|
||||||
*/
|
|
||||||
onDeactivated(() => {
|
|
||||||
(extendedApi as ExtendedModalApi)?.close?.();
|
|
||||||
});
|
|
||||||
|
|
||||||
return [Modal, extendedApi as ExtendedModalApi] as const;
|
return [Modal, extendedApi as ExtendedModalApi] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +122,7 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
injectData.extendApi?.(extendedApi);
|
injectData.extendApi?.(extendedApi);
|
||||||
|
|
||||||
return [Modal, extendedApi] as const;
|
return [Modal, extendedApi] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user