* 新增自适应数值与窗口分析工具,提升交互体验 * 优化回收站模块逻辑,增加展示与选择功能 * 引入 Macaron 主题配置文件并更新 Tailwind 配置 * 精简基础组件代码,移除冗余样式与设置项 * 完善测试用例,覆盖 UI 系统与回收站工作流 * 更新多语言配置,支持功能变更后的文案需求
41 lines
1.6 KiB
Vue
41 lines
1.6 KiB
Vue
<template>
|
|
<div class="space-y-2">
|
|
<span :id="labelId" class="block text-sm font-medium" :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']">
|
|
{{ label }}
|
|
</span>
|
|
<div class="flex min-h-11 items-center gap-3">
|
|
<button
|
|
type="button"
|
|
class="flex h-11 w-14 shrink-0 items-center justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-[#8fb2bf] focus:ring-offset-2"
|
|
role="switch"
|
|
:aria-checked="modelValue === 1"
|
|
:aria-labelledby="labelId"
|
|
@click="$emit('toggle')"
|
|
>
|
|
<span
|
|
class="relative inline-flex h-6 w-11 rounded-full border-2 border-transparent shadow-sm transition-colors duration-200"
|
|
:class="modelValue === 1 ? 'bg-[#6f9688]' : isDarkMode ? 'bg-[#495765]' : 'bg-[#cfdadc]'"
|
|
aria-hidden="true"
|
|
>
|
|
<span
|
|
class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200"
|
|
:class="modelValue === 1 ? 'translate-x-5' : 'translate-x-0'"
|
|
></span>
|
|
</span>
|
|
</button>
|
|
<span class="text-sm" :class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']">
|
|
{{ modelValue === 1 ? enabledText : disabledText }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, inject } from 'vue'
|
|
|
|
const props = defineProps<{ label: string; modelValue: number; enabledText: string; disabledText: string }>()
|
|
defineEmits<{ toggle: [] }>()
|
|
const isDarkMode = inject('isDarkMode')
|
|
const labelId = computed(() => `setting-switch-${props.label.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/gi, '-')}`)
|
|
</script>
|