mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-18 05:44:46 +08:00
47 lines
982 B
Vue
47 lines
982 B
Vue
|
|
<template>
|
||
|
|
<div
|
||
|
|
:class="[
|
||
|
|
'animate-pulse bg-gray-200 dark:bg-dark-700',
|
||
|
|
variant === 'circle' ? 'rounded-full' : 'rounded-lg',
|
||
|
|
customClass
|
||
|
|
]"
|
||
|
|
:style="style"
|
||
|
|
></div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import { computed } from 'vue'
|
||
|
|
|
||
|
|
interface Props {
|
||
|
|
variant?: 'rect' | 'circle' | 'text'
|
||
|
|
width?: string | number
|
||
|
|
height?: string | number
|
||
|
|
class?: string
|
||
|
|
}
|
||
|
|
|
||
|
|
const props = withDefaults(defineProps<Props>(), {
|
||
|
|
variant: 'rect',
|
||
|
|
width: '100%'
|
||
|
|
})
|
||
|
|
|
||
|
|
const customClass = computed(() => props.class || '')
|
||
|
|
|
||
|
|
const style = computed(() => {
|
||
|
|
const s: Record<string, string> = {}
|
||
|
|
|
||
|
|
if (props.width) {
|
||
|
|
s.width = typeof props.width === 'number' ? `${props.width}px` : props.width
|
||
|
|
}
|
||
|
|
|
||
|
|
if (props.height) {
|
||
|
|
s.height = typeof props.height === 'number' ? `${props.height}px` : props.height
|
||
|
|
} else if (props.variant === 'text') {
|
||
|
|
s.height = '1em'
|
||
|
|
s.marginTop = '0.25em'
|
||
|
|
s.marginBottom = '0.25em'
|
||
|
|
}
|
||
|
|
|
||
|
|
return s
|
||
|
|
})
|
||
|
|
</script>
|