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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  | <template> 
 |    <div class="card-wrap"> 
 |      <a-card v-if="loading" :bordered="false" hoverable> 
 |        <slot name="skeleton"></slot> 
 |      </a-card> 
 |      <a-card v-else :bordered="false" hoverable> 
 |        <a-space align="start"> 
 |          <a-avatar 
 |            v-if="icon" 
 |            :size="24" 
 |            style="margin-right: 8px; background-color: #626aea" 
 |          > 
 |            <icon-filter /> 
 |          </a-avatar> 
 |          <a-card-meta> 
 |            <template #title> 
 |              <a-typography-text style="margin-right: 10px"> 
 |                {{ title }} 
 |              </a-typography-text> 
 |              <template v-if="showTag"> 
 |                <a-tag 
 |                  v-if="open && isExpires === false" 
 |                  size="small" 
 |                  color="green" 
 |                > 
 |                  <template #icon> 
 |                    <icon-check-circle-fill /> 
 |                  </template> 
 |                  <span>{{ tagText }}</span> 
 |                </a-tag> 
 |                <a-tag v-else-if="isExpires" size="small" color="red"> 
 |                  <template #icon> 
 |                    <icon-check-circle-fill /> 
 |                  </template> 
 |                  <span>{{ expiresTagText }}</span> 
 |                </a-tag> 
 |              </template> 
 |            </template> 
 |            <template #description> 
 |              {{ description }} 
 |              <slot></slot> 
 |            </template> 
 |          </a-card-meta> 
 |        </a-space> 
 |        <template #actions> 
 |          <a-switch v-if="actionType === 'switch'" v-model="open" /> 
 |          <a-space v-else-if="actionType === 'button'"> 
 |            <template v-if="isExpires"> 
 |              <a-button type="outline" @click="renew"> 
 |                {{ expiresText }} 
 |              </a-button> 
 |            </template> 
 |            <template v-else> 
 |              <a-button v-if="open" @click="handleToggle"> 
 |                {{ closeTxt }} 
 |              </a-button> 
 |              <a-button v-else-if="!open" type="outline" @click="handleToggle"> 
 |                {{ openTxt }} 
 |              </a-button> 
 |            </template> 
 |          </a-space> 
 |          <div v-else> 
 |            <a-space> 
 |              <a-button @click="toggle(false)"> 
 |                {{ closeTxt }} 
 |              </a-button> 
 |              <a-button type="primary" @click="toggle(true)"> 
 |                {{ openTxt }} 
 |              </a-button> 
 |            </a-space> 
 |          </div> 
 |        </template> 
 |      </a-card> 
 |    </div> 
 |  </template> 
 |    
 |  <script lang="ts" setup> 
 |    import { ref } from 'vue'; 
 |    import { useToggle } from '@vueuse/core'; 
 |    
 |    const props = defineProps({ 
 |      loading: { 
 |        type: Boolean, 
 |        default: false, 
 |      }, 
 |      title: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      description: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      actionType: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      defaultValue: { 
 |        type: Boolean, 
 |        default: false, 
 |      }, 
 |      openTxt: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      closeTxt: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      expiresText: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      icon: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      showTag: { 
 |        type: Boolean, 
 |        default: true, 
 |      }, 
 |      tagText: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |      expires: { 
 |        type: Boolean, 
 |        default: false, 
 |      }, 
 |      expiresTagText: { 
 |        type: String, 
 |        default: '', 
 |      }, 
 |    }); 
 |    const [open, toggle] = useToggle(props.defaultValue); 
 |    const handleToggle = () => { 
 |      toggle(); 
 |    }; 
 |    const isExpires = ref(props.expires); 
 |    const renew = () => { 
 |      isExpires.value = false; 
 |    }; 
 |  </script> 
 |    
 |  <style scoped lang="less"> 
 |    .card-wrap { 
 |      height: 100%; 
 |      transition: all 0.3s; 
 |      border: 1px solid var(--color-neutral-3); 
 |      border-radius: 4px; 
 |      &:hover { 
 |        transform: translateY(-4px); 
 |        // box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.1); 
 |      } 
 |      :deep(.arco-card) { 
 |        height: 100%; 
 |        border-radius: 4px; 
 |        .arco-card-body { 
 |          height: 100%; 
 |          .arco-space { 
 |            width: 100%; 
 |            height: 100%; 
 |            .arco-space-item { 
 |              height: 100%; 
 |              &:last-child { 
 |                flex: 1; 
 |              } 
 |              .arco-card-meta { 
 |                height: 100%; 
 |                display: flex; 
 |                flex-flow: column; 
 |                .arco-card-meta-content { 
 |                  flex: 1; 
 |                  .arco-card-meta-description { 
 |                    margin-top: 8px; 
 |                    color: rgb(var(--gray-6)); 
 |                    line-height: 20px; 
 |                    font-size: 12px; 
 |                  } 
 |                } 
 |                .arco-card-meta-footer { 
 |                  margin-top: 0; 
 |                } 
 |              } 
 |            } 
 |          } 
 |        } 
 |      } 
 |      :deep(.arco-card-meta-title) { 
 |        display: flex; 
 |        align-items: center; 
 |    
 |        // To prevent the shaking 
 |        line-height: 28px; 
 |      } 
 |      :deep(.arco-skeleton-line) { 
 |        &:last-child { 
 |          display: flex; 
 |          justify-content: flex-end; 
 |          margin-top: 20px; 
 |        } 
 |      } 
 |    } 
 |  </style> 
 |  
  |