|
| 1 | +<script setup lang="ts"> |
| 2 | +const value = ref(['focus', 'balanced']) |
| 3 | +
|
| 4 | +const options = [ |
| 5 | + { |
| 6 | + label: '专注模式', |
| 7 | + value: 'focus', |
| 8 | + description: '突出主任务,弱化辅助信息,适合录入和审批场景。', |
| 9 | + }, |
| 10 | + { |
| 11 | + label: '平衡模式', |
| 12 | + value: 'balanced', |
| 13 | + description: '信息密度与可读性保持平衡,适合作为默认配置。', |
| 14 | + }, |
| 15 | + { |
| 16 | + label: '高密度模式', |
| 17 | + value: 'dense', |
| 18 | + description: '在大屏中同时承载更多信息,适合运营与监控看板。', |
| 19 | + }, |
| 20 | +] |
| 21 | +
|
| 22 | +const currentText = computed(() => |
| 23 | + options |
| 24 | + .filter(option => value.value.includes(option.value)) |
| 25 | + .map(option => option.label) |
| 26 | + .join('、'), |
| 27 | +) |
| 28 | +</script> |
| 29 | + |
| 30 | +<template> |
| 31 | + <FaCheckboxGroup |
| 32 | + v-model="value" |
| 33 | + :options="options" |
| 34 | + class="gap-2 md:grid-cols-3" |
| 35 | + option-class="rounded-xl border border-transparent px-1 py-1" |
| 36 | + > |
| 37 | + <template #option="{ option, checked, disabled }"> |
| 38 | + <div |
| 39 | + class="px-4 py-3 border rounded-xl flex gap-3 w-full transition-colors items-start justify-between" :class="[ |
| 40 | + checked ? 'border-primary bg-primary/5' : 'border-border hover:border-primary/40', |
| 41 | + disabled && 'opacity-60', |
| 42 | + ]" |
| 43 | + > |
| 44 | + <div class="gap-1 grid min-w-0"> |
| 45 | + <div class="text-sm font-medium truncate"> |
| 46 | + {{ option.label }} |
| 47 | + </div> |
| 48 | + <div |
| 49 | + v-if="option.description" |
| 50 | + class="text-xs text-muted-foreground leading-5" |
| 51 | + > |
| 52 | + {{ option.description }} |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + <span |
| 56 | + class="text-xs font-medium shrink-0" :class="[ |
| 57 | + checked ? 'text-primary' : 'text-muted-foreground', |
| 58 | + ]" |
| 59 | + > |
| 60 | + {{ checked ? '已选中' : '可选择' }} |
| 61 | + </span> |
| 62 | + </div> |
| 63 | + </template> |
| 64 | + </FaCheckboxGroup> |
| 65 | + <div class="text-sm text-muted-foreground"> |
| 66 | + 当前模式:{{ currentText }} |
| 67 | + </div> |
| 68 | +</template> |
0 commit comments