feat: 全面升级——后台优化 / 动态配置 / 个人中心 / OSS 存储
- OSS 文件存储(RustFS / S3 v4 兼容,零依赖手写 SigV4): 上传/列表/删除走桶 arcticnewone,/uploads 代理服务 + 本地回退; server/utils/sigv4.ts 纯函数 + AWS 测试向量验证 - 业务动态配置:settings 表 + /api/settings(公开) + /api/admin/settings(PATCH), useSiteSettings 组合式,footer/contact/tools/app.vue/侧边栏/工具页全部接入, 后台 /admin/settings 修改前台即时生效(站点/联系/社交/工具箱/页脚/SEO) - 后台全面优化:Admin* 设计系统(按钮/输入/表单/卡片/徽标/弹窗/确认/空态/骨架/ 分页/页头/Toast)14 组件;Dashboard 增强;各列表页搜索/筛选/批量删除/分页; 布局与侧边栏分组;统一 toast/确认反馈 - 个人中心全新重设计:顶部资料卡 + 统计、精致化改密/删号(二次确认)、 收藏封面网格、评论卡片、移动端适配 - deploy.sh 支持 OSS 凭据注入(NUXT_OSS_*);.env.example 更新 - 测试 17 例全过(含 SigV4 AWS 向量、settings 默认结构)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<span
|
||||
class="inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-semibold"
|
||||
:class="toneClass"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(defineProps<{ tone?: 'gray' | 'green' | 'red' | 'amber' | 'black' | 'blue' }>(), {
|
||||
tone: 'gray',
|
||||
})
|
||||
const toneClass = {
|
||||
gray: 'bg-gray-100 text-gray-600',
|
||||
green: 'bg-green-50 text-green-700',
|
||||
red: 'bg-red-50 text-red-700',
|
||||
amber: 'bg-amber-50 text-amber-700',
|
||||
black: 'bg-black text-white',
|
||||
blue: 'bg-blue-50 text-blue-700',
|
||||
}[props.tone]
|
||||
</script>
|
||||
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<button
|
||||
:type="type"
|
||||
:disabled="disabled || loading"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl font-semibold transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-black/10 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:class="[sizeClass, variantClass, block ? 'w-full' : '']"
|
||||
@click="emit('click', $event)"
|
||||
>
|
||||
<Icon v-if="loading" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
type?: 'button' | 'submit'
|
||||
variant?: 'primary' | 'secondary' | 'danger' | 'ghost'
|
||||
size?: 'sm' | 'md' | 'lg'
|
||||
loading?: boolean
|
||||
disabled?: boolean
|
||||
block?: boolean
|
||||
}>(),
|
||||
{ type: 'button', variant: 'primary', size: 'md', loading: false, disabled: false, block: false },
|
||||
)
|
||||
const emit = defineEmits<{ click: [e: MouseEvent] }>()
|
||||
|
||||
const sizeClass = {
|
||||
sm: 'px-3 py-1.5 text-xs',
|
||||
md: 'px-4 py-2 text-sm',
|
||||
lg: 'px-6 py-3 text-base',
|
||||
}[props.size]
|
||||
|
||||
const variantClass = {
|
||||
primary: 'bg-black text-white hover:bg-gray-800 shadow-sm',
|
||||
secondary: 'bg-gray-100 text-gray-800 hover:bg-gray-200',
|
||||
danger: 'bg-red-600 text-white hover:bg-red-700 shadow-sm',
|
||||
ghost: 'text-gray-600 hover:bg-gray-100',
|
||||
}[props.variant]
|
||||
</script>
|
||||
@@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm">
|
||||
<div v-if="title || $slots.actions" class="flex items-center justify-between gap-3 border-b border-gray-100 px-5 py-4">
|
||||
<div>
|
||||
<h3 v-if="title" class="text-base font-bold text-black">{{ title }}</h3>
|
||||
<p v-if="subtitle" class="mt-0.5 text-sm text-gray-500">{{ subtitle }}</p>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="flex items-center gap-2"><slot name="actions" /></div>
|
||||
</div>
|
||||
<div class="p-5"><slot /></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ title?: string; subtitle?: string }>(), { title: '', subtitle: '' })
|
||||
</script>
|
||||
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<AdminModal :open="open" title="确认操作" @update:open="emit('update:open', $event)">
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full"
|
||||
:class="danger ? 'bg-red-50 text-red-600' : 'bg-gray-100 text-gray-600'"
|
||||
>
|
||||
<Icon :name="danger ? 'ph:warning-fill' : 'ph:question-fill'" class="w-5 h-5" />
|
||||
</div>
|
||||
<p class="text-sm text-gray-700 leading-relaxed">{{ message }}</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
<AdminButton variant="secondary" size="sm" :disabled="loading" @click="emit('update:open', false)">取消</AdminButton>
|
||||
<AdminButton :variant="danger ? 'danger' : 'primary'" size="sm" :loading="loading" @click="emit('confirm')">
|
||||
确认
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ open: boolean; message: string; danger?: boolean; loading?: boolean }>(), {
|
||||
danger: false,
|
||||
loading: false,
|
||||
})
|
||||
const emit = defineEmits<{ 'update:open': [v: boolean]; confirm: [] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div class="flex flex-col items-center justify-center gap-3 py-14 text-center">
|
||||
<div class="flex h-14 w-14 items-center justify-center rounded-full bg-gray-100 text-gray-400">
|
||||
<Icon :name="icon" class="w-7 h-7" />
|
||||
</div>
|
||||
<p class="text-sm font-semibold text-gray-700">{{ title }}</p>
|
||||
<p v-if="description" class="text-sm text-gray-500 max-w-sm">{{ description }}</p>
|
||||
<div v-if="$slots.action" class="mt-1"><slot name="action" /></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ icon?: string; title: string; description?: string }>(), {
|
||||
icon: 'ph:tray',
|
||||
description: '',
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div>
|
||||
<label v-if="label" class="block text-sm font-semibold text-gray-800 mb-1.5">{{ label }}<span v-if="required" class="text-red-500 ml-0.5">*</span></label>
|
||||
<input
|
||||
:type="type"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:required="required"
|
||||
class="w-full rounded-xl border bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:ring-2"
|
||||
:class="error ? 'border-red-300 focus:border-red-500 focus:ring-red-500/10' : 'border-gray-200 focus:border-black focus:ring-black/10'"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
<p v-if="error" class="mt-1 text-xs text-red-600">{{ error }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
label?: string
|
||||
type?: string
|
||||
placeholder?: string
|
||||
error?: string
|
||||
disabled?: boolean
|
||||
required?: boolean
|
||||
}>(),
|
||||
{ label: '', type: 'text', placeholder: '', error: '', disabled: false, required: false },
|
||||
)
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-[150] flex items-center justify-center bg-black/40 p-4"
|
||||
@click.self="emit('update:open', false)"
|
||||
>
|
||||
<div class="w-full max-w-lg rounded-2xl bg-white shadow-2xl">
|
||||
<div class="flex items-center justify-between border-b border-gray-100 px-6 py-4">
|
||||
<h3 class="text-lg font-bold text-black">{{ title }}</h3>
|
||||
<button @click="emit('update:open', false)" class="text-gray-400 hover:text-gray-600" aria-label="close">
|
||||
<Icon name="ph:x" class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="px-6 py-5 max-h-[70vh] overflow-y-auto"><slot /></div>
|
||||
<div v-if="$slots.footer" class="flex justify-end gap-2 border-t border-gray-100 px-6 py-4">
|
||||
<slot name="footer" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ open: boolean; title?: string }>(), { title: '' })
|
||||
const emit = defineEmits<{ 'update:open': [v: boolean] }>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
.modal-enter-from,
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
.modal-enter-active > div,
|
||||
.modal-leave-active > div {
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
.modal-enter-from > div,
|
||||
.modal-leave-to > div {
|
||||
transform: scale(0.97) translateY(8px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-black">{{ title }}</h1>
|
||||
<p v-if="subtitle" class="mt-1 text-sm text-gray-500">{{ subtitle }}</p>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="flex items-center gap-2"><slot name="actions" /></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ title: string; subtitle?: string }>(), { subtitle: '' })
|
||||
</script>
|
||||
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div v-if="total > 0" class="flex items-center justify-between gap-4 text-sm">
|
||||
<p class="text-gray-500">共 {{ total }} 条</p>
|
||||
<div class="flex items-center gap-2">
|
||||
<AdminButton variant="secondary" size="sm" :disabled="page <= 1" @click="emit('page', page - 1)">上一页</AdminButton>
|
||||
<span class="text-gray-600 px-1">{{ page }} / {{ totalPages }}</span>
|
||||
<AdminButton variant="secondary" size="sm" :disabled="page >= totalPages" @click="emit('page', page + 1)">下一页</AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
const props = withDefaults(
|
||||
defineProps<{ total: number; page: number; pageSize?: number }>(),
|
||||
{ pageSize: 20 },
|
||||
)
|
||||
const emit = defineEmits<{ page: [p: number] }>()
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))
|
||||
</script>
|
||||
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<label v-if="label" class="block text-sm font-semibold text-gray-800 mb-1.5">{{ label }}</label>
|
||||
<select
|
||||
:value="modelValue"
|
||||
:disabled="disabled"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10 disabled:opacity-50"
|
||||
@change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"
|
||||
>
|
||||
<option v-for="o in options" :key="o.value" :value="o.value">{{ o.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Option {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
withDefaults(defineProps<{ modelValue: string; options: Option[]; label?: string; disabled?: boolean }>(), {
|
||||
label: '',
|
||||
disabled: false,
|
||||
})
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
@@ -1,24 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台左侧导航栏(Dashboard / 动态 / 作品 / 用户 / 评论 / 联系 / 订阅 / 图片 / 日志 / 返回前台)。
|
||||
* 后台左侧导航栏:按「内容 / 数据 / 系统」分组,底部返回前台。
|
||||
* 高亮当前路由;点击任意导航项时向父级发出 navigate 事件(移动端关闭侧栏)。
|
||||
*/
|
||||
import { useRoute } from '#app'
|
||||
import { siteConfig } from '~/config/site'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const route = useRoute()
|
||||
const emit = defineEmits<{ navigate: [] }>()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const items = [
|
||||
{ to: '/admin', label: 'Dashboard', icon: 'ph:gauge' },
|
||||
{ to: '/admin/news', label: '动态管理', icon: 'ph:newspaper' },
|
||||
{ to: '/admin/work', label: '作品管理', icon: 'ph:image-square' },
|
||||
{ to: '/admin/users', label: '用户管理', icon: 'ph:users-three' },
|
||||
{ to: '/admin/comments', label: '评论管理', icon: 'ph:chat-circle-text' },
|
||||
{ to: '/admin/contacts', label: '联系留言', icon: 'ph:envelope-simple' },
|
||||
{ to: '/admin/subscribers', label: '订阅管理', icon: 'ph:paper-plane-tilt' },
|
||||
{ to: '/admin/uploads', label: '图片管理', icon: 'ph:image' },
|
||||
{ to: '/admin/audit', label: '操作日志', icon: 'ph:list-checks' },
|
||||
interface SidebarItem {
|
||||
to: string
|
||||
label: string
|
||||
icon: string
|
||||
}
|
||||
|
||||
interface SidebarGroup {
|
||||
label: string
|
||||
items: SidebarItem[]
|
||||
}
|
||||
|
||||
const groups: SidebarGroup[] = [
|
||||
{
|
||||
label: '内容',
|
||||
items: [
|
||||
{ to: '/admin', label: 'Dashboard', icon: 'ph:gauge' },
|
||||
{ to: '/admin/news', label: '动态管理', icon: 'ph:newspaper' },
|
||||
{ to: '/admin/work', label: '作品管理', icon: 'ph:image-square' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '数据',
|
||||
items: [
|
||||
{ to: '/admin/users', label: '用户管理', icon: 'ph:users-three' },
|
||||
{ to: '/admin/comments', label: '评论管理', icon: 'ph:chat-circle-text' },
|
||||
{ to: '/admin/contacts', label: '联系留言', icon: 'ph:envelope-simple' },
|
||||
{ to: '/admin/subscribers', label: '订阅管理', icon: 'ph:paper-plane-tilt' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '系统',
|
||||
items: [
|
||||
{ to: '/admin/uploads', label: '图片管理', icon: 'ph:image' },
|
||||
{ to: '/admin/audit', label: '操作日志', icon: 'ph:list-checks' },
|
||||
{ to: '/admin/settings', label: '站点设置', icon: 'ph:gear-six' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const isActive = (to: string) => route.path === to
|
||||
@@ -37,23 +65,32 @@ const isActive = (to: string) => route.path === to
|
||||
A
|
||||
</div>
|
||||
<div class="leading-tight">
|
||||
<p class="text-sm font-bold">{{ siteConfig.brandZh }}</p>
|
||||
<p class="text-sm font-bold">{{ settings?.site.brand }}</p>
|
||||
<p class="text-[11px] text-white/50">后台管理</p>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
|
||||
<nav class="flex-1 py-4 px-3 space-y-1 overflow-y-auto">
|
||||
<NuxtLink
|
||||
v-for="item in items"
|
||||
:key="item.to"
|
||||
:to="item.to"
|
||||
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors"
|
||||
:class="isActive(item.to) ? 'bg-white text-black' : 'text-white/70 hover:bg-white/10 hover:text-white'"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
<Icon :name="item.icon" class="w-[18px] h-[18px]" />
|
||||
{{ item.label }}
|
||||
</NuxtLink>
|
||||
<nav class="flex-1 py-5 px-3 overflow-y-auto space-y-6">
|
||||
<div v-for="group in groups" :key="group.label">
|
||||
<p
|
||||
class="px-3 mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-white/40"
|
||||
>
|
||||
{{ group.label }}
|
||||
</p>
|
||||
<div class="space-y-1">
|
||||
<NuxtLink
|
||||
v-for="item in group.items"
|
||||
:key="item.to"
|
||||
:to="item.to"
|
||||
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors"
|
||||
:class="isActive(item.to) ? 'bg-white text-black' : 'text-white/70 hover:bg-white/10 hover:text-white'"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
<Icon :name="item.icon" class="w-[18px] h-[18px]" />
|
||||
{{ item.label }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="p-3 border-t border-white/10 shrink-0">
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<div class="space-y-3 p-2">
|
||||
<div v-for="i in rows" :key="i" class="animate-pulse">
|
||||
<div class="h-3.5 rounded bg-gray-100" :style="{ width: `${40 + ((i * 13) % 50)}%` }" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ rows?: number }>(), { rows: 5 })
|
||||
</script>
|
||||
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div>
|
||||
<label v-if="label" class="block text-sm font-semibold text-gray-800 mb-1.5">{{ label }}<span v-if="required" class="text-red-500 ml-0.5">*</span></label>
|
||||
<textarea
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:rows="rows"
|
||||
class="w-full rounded-xl border bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:ring-2 resize-y"
|
||||
:class="error ? 'border-red-300 focus:border-red-500 focus:ring-red-500/10' : 'border-gray-200 focus:border-black focus:ring-black/10'"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLTextAreaElement).value)"
|
||||
/>
|
||||
<p v-if="error" class="mt-1 text-xs text-red-600">{{ error }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
label?: string
|
||||
placeholder?: string
|
||||
error?: string
|
||||
disabled?: boolean
|
||||
required?: boolean
|
||||
rows?: number
|
||||
}>(),
|
||||
{ label: '', placeholder: '', error: '', disabled: false, required: false, rows: 3 },
|
||||
)
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div class="fixed top-4 right-4 z-[200] flex flex-col gap-2 w-80 max-w-[calc(100vw-2rem)]">
|
||||
<TransitionGroup name="toast">
|
||||
<div
|
||||
v-for="t in toast.toasts"
|
||||
:key="t.id"
|
||||
class="flex items-start gap-3 rounded-xl border bg-white px-4 py-3 shadow-lg"
|
||||
:class="borderClass(t.type)"
|
||||
>
|
||||
<Icon :name="iconFor(t.type)" class="w-5 h-5 mt-0.5" :class="iconClass(t.type)" />
|
||||
<p class="flex-1 text-sm text-gray-800 break-words">{{ t.message }}</p>
|
||||
<button @click="toast.remove(t.id)" class="text-gray-400 hover:text-gray-600" aria-label="close">
|
||||
<Icon name="ph:x" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
const borderClass = (type: string) => {
|
||||
if (type === 'success') return 'border-green-200'
|
||||
if (type === 'error') return 'border-red-200'
|
||||
return 'border-gray-200'
|
||||
}
|
||||
const iconFor = (type: string) => {
|
||||
if (type === 'success') return 'ph:check-circle-fill'
|
||||
if (type === 'error') return 'ph:warning-circle-fill'
|
||||
return 'ph:info-fill'
|
||||
}
|
||||
const iconClass = (type: string) => {
|
||||
if (type === 'success') return 'text-green-600'
|
||||
if (type === 'error') return 'text-red-600'
|
||||
return 'text-gray-400'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.toast-enter-active,
|
||||
.toast-leave-active {
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
.toast-enter-from,
|
||||
.toast-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(16px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<button
|
||||
type="button"
|
||||
class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-black/10"
|
||||
:class="modelValue ? 'bg-black' : 'bg-gray-300'"
|
||||
@click="emit('update:modelValue', !modelValue)"
|
||||
>
|
||||
<span
|
||||
class="inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform duration-200"
|
||||
:class="modelValue ? 'translate-x-6' : 'translate-x-1'"
|
||||
/>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{ modelValue: boolean }>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: boolean] }>()
|
||||
</script>
|
||||
Reference in New Issue
Block a user