gaoluyang
2026-06-29 27cd042df9aca0383a49f3514bc21958dd890912
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script setup lang="ts">
import type { ComparisonCardProps } from './types';
 
import { computed } from 'vue';
 
import {
  Card,
  CardContent,
  VbenCountToAnimator,
  VbenIcon,
  VbenLoading,
} from '../../../../../../@core/ui-kit/shadcn-ui/src';
 
/** 对比卡片 */
defineOptions({ name: 'ComparisonCard' });
 
const props = defineProps<ComparisonCardProps>();
 
// TODO @haohao:看看能不能用中立的 icon,类似 ADD、EDIT 那种。目的:方便后续迁移到 ele 版本里。
const iconMap: Record<string, string> = {
  menu: 'ant-design:appstore-outlined',
  box: 'ant-design:box-plot-outlined',
  cpu: 'ant-design:cluster-outlined',
  message: 'ant-design:message-outlined',
};
 
const iconName = computed(() => iconMap[props.icon] || iconMap.menu);
</script>
 
<template>
  <Card
    class="relative h-40 cursor-pointer transition-all duration-300 hover:-translate-y-1 hover:shadow-lg"
  >
    <VbenLoading :spinning="loading" />
    <CardContent class="flex h-full flex-col p-6">
      <div class="mb-4 flex items-start justify-between">
        <div class="flex flex-1 flex-col">
          <span class="mb-2 text-sm font-medium text-gray-500">
            {{ title }}
          </span>
          <span class="text-3xl font-bold text-gray-800">
            <span v-if="value === -1">--</span>
            <VbenCountToAnimator v-else :end-val="value" :duration="1000" />
          </span>
        </div>
        <div :class="`text-4xl ${iconColor || ''}`">
          <VbenIcon :icon="iconName" />
        </div>
      </div>
 
      <div class="mt-auto border-t border-gray-100 pt-3">
        <div class="flex items-center justify-between text-sm">
          <span class="text-gray-400">今日新增</span>
          <span v-if="todayCount === -1" class="text-gray-400">--</span>
          <span v-else class="font-medium text-green-500">
            +{{ todayCount }}
          </span>
        </div>
      </div>
    </CardContent>
  </Card>
</template>