zhangxiao
2024-08-26 57b66478e7e335379435b31c20da4619bd1411f5
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
    <!-- 带icon首页 -->
    <div class="icon-card" :class="currentThemeMode === 'dark' ? 'card-dark' : ''">
        <a-card class="card-box">
            <div class="card-icon" :style="dynamicStyle">
                <Svg :name="icon" :width="26" :height="26"></Svg>
                <!-- <img src="../../../assets/images/icon-house.png" alt="" /> -->
            </div>
            <div class="card-content">
                <p>{{ title }}</p>
                <p>
                    <span class="metering" :style="{ color: colorBg }">{{ metering }}</span>
                    <span>{{ unit }}</span>
                </p>
            </div>
        </a-card>
    </div>
</template>
<script lang="ts" setup name="TheIconCard">
import { useTheme } from "@/hooks/useTheme";
import { Svg } from "@easyfe/admin-component";
 
const { themeModeOptions, currentThemeMode, handleThemeChange } = useTheme();
const props = withDefaults(
    defineProps<{
        icon?: string;
        title?: string;
        unit?: string;
        metering?: number;
        colorBg?: string;
    }>(),
    {
        icon: "",
        title: "",
        unit: "",
        metering: 0,
        colorBg: "#fff"
    }
);
 
const colorBg = computed(() => {
    return props.colorBg;
});
const dynamicStyle = {
    backgroundColor: colorBg.value // 动态背景色
};
</script>
<style lang="scss" scoped>
.card-dark {
    .card-box {
        border: 1px solid #0e9cff;
        display: flex;
        align-items: center;
        // justify-content: center;
    }
}
.icon-card {
    // min-width: 88px;
    // max-width: 208px;
    width: 100%;
    min-height: 77px;
    border-radius: 4px;
    box-sizing: border-box;
    margin-right: 10px;
    flex: 1;
    &:last-child {
        margin-right: 0;
    }
    .card-box {
        width: 100%;
        height: 100%;
    }
    .card-icon {
        width: 50px;
        height: 50px;
 
        border-radius: 10px;
        opacity: 1;
        // background: #2e85ff;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    :deep(.arco-card-body) {
        display: flex;
        align-items: center;
        // justify-content: center;
    }
    .card-content {
        margin-left: 20px;
        line-height: 22px;
        color: var(--color-text-1);
        font-size: 12px;
        .metering {
            font-size: 14px;
            margin-right: 4px;
        }
    }
}
</style>