27
27
<div >
28
28
<div class =" mb-3" v-for =" option in itemCom.options" :key =" option._id" >
29
29
<div
30
- class =" flex justify-between items-center rounded-md border border-solid border-gray-300 dark:border-gray-600 hover:border-primary/80 dark:hover:border-primary/80 transition-colors cursor-pointer vote-item-option"
30
+ class =" flex justify-between items-center rounded-md border border-solid border-gray-300 dark:border-gray-600 transition-all cursor-pointer vote-item-option"
31
31
:class =" {
32
32
disabled: btnDisabled,
33
33
active: optionIdList.includes(option._id),
34
+ 'max-vote': maxVoteIdList.includes(option._id),
34
35
}"
35
36
@click =" handleSelect(option)"
36
37
>
@@ -121,6 +122,28 @@ const itemCom = computed(() => {
121
122
}
122
123
})
123
124
125
+ // 投票最多的选项list
126
+ const maxVoteIdList = computed (() => {
127
+ if (! itemCom .value ? .options || itemCom .value .options .length === 0 ) {
128
+ return []
129
+ }
130
+ if (! itemCom .value ? .votes || itemCom .value .votes <= 0 ) {
131
+ return []
132
+ }
133
+ let maxVoteCount = - 1
134
+ let ids = []
135
+ for (const option of itemCom .value .options ) {
136
+ const votes = option .votes || 0
137
+ if (votes > maxVoteCount) {
138
+ maxVoteCount = votes
139
+ ids = [option ._id ]
140
+ } else if (votes === maxVoteCount) {
141
+ ids .push (option ._id )
142
+ }
143
+ }
144
+ return ids
145
+ })
146
+
124
147
const voted = ref (false )
125
148
const isExpired = ref (false )
126
149
const bothIP = ref (false )
@@ -274,24 +297,39 @@ onUnmounted(() => {
274
297
line- height: 1 .25rem ;
275
298
padding: 0 .4rem 0 .5rem ;
276
299
}
300
+ .vote - item- option: not (.disabled ): hover {
301
+ @apply border- primary- 400 dark: border- primary- 400 ;
302
+ }
303
+ : deep (.vote - item- option: not (.disabled ): hover input[type= ' checkbox' ]) {
304
+ @apply border- primary- 400 dark: border- primary- 400 ;
305
+ }
277
306
.vote - item- option .active {
278
- @apply border - primary - 400 text- primary- 500 dark: text- primary- 400 ;
307
+ @apply text- primary- 500 dark: text- primary- 400 ;
279
308
}
280
309
.vote - item- option .disabled {
281
- @apply cursor- default hover : border - gray - 300 dark : hover : border - gray - 600 ;
310
+ @apply cursor- default;
282
311
}
283
- .vote - item- option .active .disabled {
312
+ .vote - item- option .disabled : hover {
313
+ @apply border- gray- 300 dark: border- gray- 600 ;
314
+ }
315
+ /* .vote-item-option.active.disabled {
284
316
@apply hover:border-primary-400 dark:hover:border-primary-400;
317
+ } */
318
+ .vote - item- option .max - vote {
319
+ @apply border- primary- 400 text- primary- 500 dark: text- primary- 400 ;
320
+ }
321
+ .vote - item- option .max - vote .disabled {
322
+ @apply border- primary- 400 dark: border- primary- 400 text- primary- 500 dark: text- primary- 400 ;
285
323
}
286
324
.vote - item- option- votes {
287
325
font- size: 0 .75rem ;
288
326
white- space: nowrap;
289
327
min- width: 6 .2rem ;
290
328
text- align: right;
291
329
}
292
- .vote - item- option .active .vote - item- option- votes {
330
+ /* .vote-item-option.active .vote-item-option-votes {
293
331
@apply text-primary-500 dark:text-primary-400;
294
- }
332
+ } */
295
333
.vote - item- option- votes {
296
334
text- align: right;
297
335
}
@@ -314,7 +352,10 @@ onUnmounted(() => {
314
352
border- radius: 0 .1rem ;
315
353
transition: width 0 .3s ;
316
354
}
317
- .vote - item- option .active .vote - item- option- bar- inner {
355
+ /* .vote-item-option.active .vote-item-option-bar-inner {
356
+ @apply bg-primary-400/20;
357
+ } */
358
+ .vote - item- option .max - vote .vote - item- option- bar- inner {
318
359
@apply bg- primary- 400 / 20 ;
319
360
}
320
361
.vote - item- option- title,
0 commit comments