This commit is contained in:
dap
2025-03-08 20:25:01 +08:00
22 changed files with 1006 additions and 9 deletions

View File

@@ -1,11 +1,12 @@
<script setup lang="ts">
import type { ClassType } from '@vben-core/typings';
import type {
AvatarFallbackProps,
AvatarImageProps,
AvatarRootProps,
} from 'radix-vue';
import type { ClassType } from '@vben-core/typings';
import { computed } from 'vue';
import { Avatar, AvatarFallback, AvatarImage } from '../../ui';
@@ -15,6 +16,7 @@ interface Props extends AvatarFallbackProps, AvatarImageProps, AvatarRootProps {
class?: ClassType;
dot?: boolean;
dotClass?: ClassType;
size?: number;
}
defineOptions({
@@ -31,10 +33,23 @@ const props = withDefaults(defineProps<Props>(), {
const text = computed(() => {
return props.alt.slice(-2).toUpperCase();
});
const rootStyle = computed(() => {
return props.size !== undefined && props.size > 0
? {
height: `${props.size}px`,
width: `${props.size}px`,
}
: {};
});
</script>
<template>
<div :class="props.class" class="relative flex flex-shrink-0 items-center">
<div
:class="props.class"
:style="rootStyle"
class="relative flex flex-shrink-0 items-center"
>
<Avatar :class="props.class" class="size-full">
<AvatarImage :alt="alt" :src="src" />
<AvatarFallback>{{ text }}</AvatarFallback>

View File

@@ -52,7 +52,8 @@ withDefaults(defineProps<Props>(), {
v-if="src"
:alt="text"
:src="src"
class="relative w-8 rounded-none bg-transparent"
:size="logoSize"
class="relative rounded-none bg-transparent"
/>
<span
v-if="!collapsed"