80 lines
1.6 KiB
Vue
80 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
Switch,
|
|
SwitchContent,
|
|
SwitchControl,
|
|
SwitchThumb,
|
|
SwitchIcon,
|
|
} from "@heroui-vue/components";
|
|
import {
|
|
IconCheck,
|
|
IconPower,
|
|
IconSun,
|
|
IconMoon,
|
|
IconMicrophone,
|
|
IconMicrophoneOff,
|
|
IconBellFilled,
|
|
IconBellOff,
|
|
IconVolume,
|
|
IconVolumeOff,
|
|
} from "@tabler/icons-vue";
|
|
const icons = [
|
|
{
|
|
key: "check",
|
|
label: "电源",
|
|
color: "bg-green-500/80",
|
|
on: IconCheck,
|
|
off: IconPower,
|
|
},
|
|
{ key: "darkMode", label: "深色模式", color: "", on: IconSun, off: IconMoon },
|
|
{
|
|
key: "microphone",
|
|
label: "静音麦克风",
|
|
color: "bg-red-500/80",
|
|
on: IconMicrophoneOff,
|
|
off: IconMicrophone,
|
|
},
|
|
{
|
|
key: "notification",
|
|
label: "通知",
|
|
color: "bg-purple-500/80",
|
|
on: IconBellFilled,
|
|
off: IconBellOff,
|
|
},
|
|
{
|
|
key: "volume",
|
|
label: "静音音量",
|
|
color: "bg-blue-500/80",
|
|
on: IconVolumeOff,
|
|
off: IconVolume,
|
|
},
|
|
];
|
|
</script>
|
|
<template>
|
|
<div class="flex flex-wrap gap-3">
|
|
<Switch
|
|
v-for="item in icons"
|
|
:key="item.key"
|
|
default-selected
|
|
size="lg"
|
|
:aria-label="item.label"
|
|
v-slot="{ isSelected }"
|
|
>
|
|
<SwitchContent>
|
|
<SwitchControl :class="isSelected ? item.color : ''">
|
|
<SwitchThumb>
|
|
<SwitchIcon>
|
|
<component
|
|
:is="isSelected ? item.on : item.off"
|
|
class="size-3 text-inherit"
|
|
:class="isSelected ? 'opacity-100' : 'opacity-70'"
|
|
aria-hidden="true"
|
|
/>
|
|
</SwitchIcon>
|
|
</SwitchThumb>
|
|
</SwitchControl>
|
|
</SwitchContent>
|
|
</Switch>
|
|
</div>
|
|
</template>
|