mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 02:22:25 +00:00
refactor:【antd】【iot】重构首页统计组件,优化图表配置和数据加载逻辑,移除未使用的比较卡片组件
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import type { ComparisonCardProps } from './types';
|
||||
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
VbenCountToAnimator,
|
||||
VbenIcon,
|
||||
VbenLoading,
|
||||
} from '@vben-core/shadcn-ui';
|
||||
|
||||
/** 对比卡片 */
|
||||
defineOptions({ name: 'ComparisonCard' });
|
||||
|
||||
const props = defineProps<ComparisonCardProps>();
|
||||
|
||||
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>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// add by 芋艿:对比卡片,目前 iot 模块在使用
|
||||
export { default as ComparisonCard } from './comparison-card.vue';
|
||||
export * from './types';
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface ComparisonCardProps {
|
||||
/** 图标名称 */
|
||||
icon: string;
|
||||
/** 图标颜色类名 */
|
||||
iconColor?: string;
|
||||
/** 加载状态 */
|
||||
loading?: boolean;
|
||||
/** 标题 */
|
||||
title: string;
|
||||
/** 今日新增数量 */
|
||||
todayCount: number;
|
||||
/** 数值 */
|
||||
value: number;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './api-component';
|
||||
export * from './captcha';
|
||||
export * from './card/comparison-card';
|
||||
export * from './card/statistic-card';
|
||||
export * from './card/summary-card';
|
||||
export * from './col-page';
|
||||
|
||||
Reference in New Issue
Block a user