统一甲屿云命名体系
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-bind="$attrs"
|
||||
:open="open"
|
||||
:title="title"
|
||||
:width="mergedWidth"
|
||||
:mask-closable="false"
|
||||
:centered="!isMobile"
|
||||
:wrap-class-name="mergedWrapClassName"
|
||||
:style="mergedStyle"
|
||||
:body-style="mergedBodyStyle"
|
||||
@update:open="handleOpenChange"
|
||||
@cancel="handleCancel"
|
||||
@ok="handleOk"
|
||||
>
|
||||
<slot />
|
||||
<template v-if="$slots.footer" #footer>
|
||||
<slot name="footer" />
|
||||
</template>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* AdminResponsiveModal page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import type { CSSProperties } from 'vue'
|
||||
import { computed, useAttrs } from 'vue'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import { CONFIRM_ENTER_DISABLED_CLASS } from '@/composables/useConfirmEnter'
|
||||
|
||||
/**
|
||||
* Purpose: modalInstanceSeed supports AdminResponsiveModal.vue by holding or executing the modal instance seed page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let modalInstanceSeed = 0
|
||||
|
||||
/**
|
||||
* Purpose: props supports AdminResponsiveModal.vue by holding or executing the props page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
open: boolean
|
||||
title?: string
|
||||
desktopWidth?: string | number
|
||||
mobileBodyPadding?: string
|
||||
confirmOnEnter?: boolean
|
||||
}>(), {
|
||||
title: '',
|
||||
desktopWidth: 720,
|
||||
mobileBodyPadding: '16px 16px 104px',
|
||||
confirmOnEnter: true
|
||||
})
|
||||
|
||||
/**
|
||||
* Purpose: emit supports AdminResponsiveModal.vue by holding or executing the emit page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:open', value: boolean): void
|
||||
(event: 'cancel', value?: unknown): void
|
||||
(event: 'ok', value?: unknown): void
|
||||
}>()
|
||||
|
||||
const { isMobile } = useAdminViewport()
|
||||
/**
|
||||
* Purpose: attrs supports AdminResponsiveModal.vue by holding or executing the attrs page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const attrs = useAttrs()
|
||||
/**
|
||||
* Purpose: modalInstanceClass supports AdminResponsiveModal.vue by holding or executing the modal instance class page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const modalInstanceClass = `admin-responsive-modal-${modalInstanceSeed++}`
|
||||
|
||||
/** mergedWidth is a reactive state variable used by the template and event handlers. */
|
||||
const mergedWidth = computed(() => (isMobile.value ? '100dvw' : props.desktopWidth))
|
||||
/** mergedStyle is a reactive state variable used by the template and event handlers. */
|
||||
const mergedStyle = computed(() => (
|
||||
isMobile.value
|
||||
? {
|
||||
top: '0px',
|
||||
maxWidth: '100dvw',
|
||||
paddingBottom: '0px'
|
||||
}
|
||||
: undefined
|
||||
))
|
||||
/**
|
||||
* Purpose: mergedWrapClassName supports AdminResponsiveModal.vue by holding or executing the merged wrap class name page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const mergedWrapClassName = computed(() => (
|
||||
[
|
||||
attrs.wrapClassName || attrs['wrap-class-name'],
|
||||
isMobile.value ? 'admin-mobile-modal' : '',
|
||||
props.confirmOnEnter ? '' : CONFIRM_ENTER_DISABLED_CLASS,
|
||||
modalInstanceClass
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
))
|
||||
/** mergedBodyStyle is a reactive state variable used by the template and event handlers. */
|
||||
const mergedBodyStyle = computed(() => (
|
||||
isMobile.value
|
||||
? ({
|
||||
maxHeight: 'calc(100vh - 124px)',
|
||||
overflowY: 'auto',
|
||||
padding: props.mobileBodyPadding
|
||||
} as CSSProperties)
|
||||
: undefined
|
||||
))
|
||||
|
||||
/** handleOpenChange is a local helper used by this page script. */
|
||||
const handleOpenChange = (value: boolean) => {
|
||||
emit('update:open', value)
|
||||
}
|
||||
|
||||
/** handleCancel is a local helper used by this page script. */
|
||||
const handleCancel = (event?: unknown) => {
|
||||
emit('update:open', false)
|
||||
emit('cancel', event)
|
||||
}
|
||||
|
||||
/** handleOk is a local helper used by this page script. */
|
||||
const handleOk = (event?: unknown) => {
|
||||
emit('ok', event)
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user