feat: 个人中心重设计 + 后台全量响应式适配

- 个人中心重设计:对齐站点黑白编辑风(极简资料区+细分隔线统计、下划线页签、
  细边框卡片、克制危险区、收藏网格、评论列表),移除后台系组件与彩色渐变
- 后台响应式适配:表格页 md 以下卡片堆叠(md:hidden/hidden md:block 双模板)、
  Dashboard 统计卡自适应、表单双语两列、AdminModal 移动端底部弹层、
  触摸目标与间距统一,覆盖全部 9 个后台页 + 布局
This commit is contained in:
2026-08-06 19:21:37 +08:00
parent b15a983e3c
commit f1d2a405f9
12 changed files with 513 additions and 497 deletions
+12 -5
View File
@@ -3,17 +3,18 @@
<Transition name="modal"> <Transition name="modal">
<div <div
v-if="open" v-if="open"
class="fixed inset-0 z-[150] flex items-center justify-center bg-black/40 p-4" class="fixed inset-0 z-[150] flex items-end justify-center bg-black/40 p-0 sm:items-center sm:p-4"
@click.self="emit('update:open', false)" @click.self="emit('update:open', false)"
> >
<div class="w-full max-w-lg rounded-2xl bg-white shadow-2xl"> <!-- 移动端底部弹层;≥sm 居中 -->
<div class="w-full max-w-lg rounded-t-2xl bg-white shadow-2xl sm:rounded-2xl sm:max-h-[85vh] sm:flex sm:flex-col max-h-[92vh] flex flex-col">
<div class="flex items-center justify-between border-b border-gray-100 px-6 py-4"> <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> <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"> <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" /> <Icon name="ph:x" class="w-5 h-5" />
</button> </button>
</div> </div>
<div class="px-6 py-5 max-h-[70vh] overflow-y-auto"><slot /></div> <div class="px-6 py-5 overflow-y-auto min-h-0"><slot /></div>
<div v-if="$slots.footer" class="flex justify-end gap-2 border-t border-gray-100 px-6 py-4"> <div v-if="$slots.footer" class="flex justify-end gap-2 border-t border-gray-100 px-6 py-4">
<slot name="footer" /> <slot name="footer" />
</div> </div>
@@ -31,7 +32,7 @@ const emit = defineEmits<{ 'update:open': [v: boolean] }>()
<style scoped> <style scoped>
.modal-enter-active, .modal-enter-active,
.modal-leave-active { .modal-leave-active {
transition: opacity 0.2s ease; transition: opacity 0.22s ease;
} }
.modal-enter-from, .modal-enter-from,
.modal-leave-to { .modal-leave-to {
@@ -39,10 +40,16 @@ const emit = defineEmits<{ 'update:open': [v: boolean] }>()
} }
.modal-enter-active > div, .modal-enter-active > div,
.modal-leave-active > div { .modal-leave-active > div {
transition: transform 0.2s ease; transition: transform 0.28s ease;
} }
.modal-enter-from > div,
.modal-leave-to > div {
transform: translateY(24px);
}
@media (min-width: 640px) {
.modal-enter-from > div, .modal-enter-from > div,
.modal-leave-to > div { .modal-leave-to > div {
transform: scale(0.97) translateY(8px); transform: scale(0.97) translateY(8px);
} }
}
</style> </style>
+3 -2
View File
@@ -18,7 +18,7 @@ const sidebarOpen = ref(false)
<!-- 移动端顶栏 --> <!-- 移动端顶栏 -->
<header <header
class="lg:hidden fixed top-0 inset-x-0 z-40 h-14 bg-black text-white flex items-center justify-between px-4 shadow-lg" class="lg:hidden fixed top-0 inset-x-0 z-50 h-14 bg-black text-white flex items-center justify-between px-4 shadow-lg"
> >
<NuxtLink to="/admin" class="flex items-center gap-2" @click="sidebarOpen = false"> <NuxtLink to="/admin" class="flex items-center gap-2" @click="sidebarOpen = false">
<div <div
@@ -30,8 +30,9 @@ const sidebarOpen = ref(false)
</NuxtLink> </NuxtLink>
<button <button
type="button" type="button"
class="w-9 h-9 rounded-lg hover:bg-white/10 flex items-center justify-center transition-colors" class="w-10 h-10 rounded-lg hover:bg-white/10 flex items-center justify-center transition-colors"
aria-label="切换菜单" aria-label="切换菜单"
:aria-expanded="sidebarOpen"
@click="sidebarOpen = !sidebarOpen" @click="sidebarOpen = !sidebarOpen"
> >
<Icon :name="sidebarOpen ? 'ph:x' : 'ph:list'" class="w-5 h-5" /> <Icon :name="sidebarOpen ? 'ph:x' : 'ph:list'" class="w-5 h-5" />
+196 -348
View File
@@ -1,12 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
/** /**
* 个人中心(全新设计)。 * 个人中心(重新设计)—— 对齐站点黑白编辑风:极简、大排版、充足留白。
* - 顶部深色渐变资料卡:头像 / 用户名 / 邮箱 / 角色徽标 / 注册时间 / 三项统计 * - 资料区:头像 + 大号姓名 + 邮箱 + 角色/加入时间 + 三项统计(细分隔线)
* - pill 页签:profile / favorites / comments * - 导航:下划线页签
* - profile:资料编辑、修改密码、删除账号(危险区 + 确认弹窗) * - profile:资料编辑 / 修改密码 / 删除账号(克制危险区)
* - favorites:作品封面网格卡(封面 / 标题 / 年份 / 分类 / 取消收藏) * - favorites:作品封面网格;comments:评论列表
* - comments:评论卡片列表
* - 数据:favorites = /api/favorites + /api/work;comments = /api/account/comments
*/ */
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue' import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@@ -14,45 +12,32 @@ import { useSeoMeta } from '#imports'
import gsap from 'gsap' import gsap from 'gsap'
import { useUserStore } from '~/stores/user' import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal' import { useAuthModalStore } from '~/stores/authModal'
import { useToastStore } from '~/stores/toast'
import { useApiError } from '~/composables/useApiError' import { useApiError } from '~/composables/useApiError'
const { t, locale } = useI18n() const { t, locale } = useI18n()
const userStore = useUserStore() const userStore = useUserStore()
const authModal = useAuthModalStore() const authModal = useAuthModalStore()
const toast = useToastStore()
const apiError = useApiError() const apiError = useApiError()
useSeoMeta({ title: () => t('account.title') }) useSeoMeta({ title: () => t('account.title') })
const isAdmin = computed(() => userStore.user?.role === 'admin') const isAdmin = computed(() => userStore.user?.role === 'admin')
const formatDate = (raw?: string) => { const formatDate = (raw?: string, monthOnly = false) => {
if (!raw) return '' if (!raw) return ''
const d = new Date(String(raw).replace(' ', 'T') + 'Z') const d = new Date(String(raw).replace(' ', 'T') + 'Z')
if (Number.isNaN(d.getTime())) return raw if (Number.isNaN(d.getTime())) return raw
const loc = locale.value === 'zh' ? 'zh-CN' : 'en-US' const loc = locale.value === 'zh' ? 'zh-CN' : 'en-US'
return new Intl.DateTimeFormat(loc, { year: 'numeric', month: 'short', day: 'numeric' }).format(d) return new Intl.DateTimeFormat(loc, monthOnly ? { year: 'numeric', month: 'short' } : { year: 'numeric', month: 'short', day: 'numeric' }).format(d)
}
// 统计卡「加入于」用紧凑格式(仅年月)
const formatMonth = (raw?: string) => {
if (!raw) return ''
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
if (Number.isNaN(d.getTime())) return formatDate(raw)
const loc = locale.value === 'zh' ? 'zh-CN' : 'en-US'
return new Intl.DateTimeFormat(loc, { year: 'numeric', month: 'short' }).format(d)
} }
/* ---------- 页签 ---------- */ /* ---------- 页签 ---------- */
const activeTab = ref('profile') const activeTab = ref('profile')
const tabs = computed(() => [ const tabs = computed(() => [
{ key: 'profile', label: t('account.profile'), count: null as number | null }, { key: 'profile', label: t('account.profile'), count: null as number | null },
{ key: 'favorites', label: t('account.favorites'), count: favorites.value.length }, { key: 'favorites', label: t('account.favorites'), count: favorites.value.length },
{ key: 'comments', label: t('account.comments'), count: myComments.value.length }, { key: 'comments', label: t('account.comments'), count: myComments.value.length },
]) ])
const switchTab = (key: string) => { const switchTab = (key: string) => {
if (key === activeTab.value) return if (key === activeTab.value) return
activeTab.value = key activeTab.value = key
@@ -60,57 +45,43 @@ const switchTab = (key: string) => {
if (key === 'comments') loadComments() if (key === 'comments') loadComments()
} }
/* ---------- 个人资料 ---------- */ /* ---------- 资料编辑 ---------- */
const profileForm = reactive({ username: '', phone: '' }) const profileForm = reactive({ username: '', phone: '' })
const profileSaving = ref(false) const profileSaving = ref(false)
const profileMsg = ref<{ ok: boolean; text: string } | null>(null)
const initProfileForm = () => { const initProfileForm = () => {
profileForm.username = userStore.user?.username ?? '' profileForm.username = userStore.user?.username ?? ''
profileForm.phone = userStore.user?.phone ?? '' profileForm.phone = userStore.user?.phone ?? ''
} }
const saveProfile = async () => { const saveProfile = async () => {
profileSaving.value = true profileSaving.value = true
const result = await userStore.updateProfile({ profileMsg.value = null
username: profileForm.username, const result = await userStore.updateProfile({ username: profileForm.username, phone: profileForm.phone })
phone: profileForm.phone,
})
profileSaving.value = false profileSaving.value = false
if (result.success) { profileMsg.value = result.success
toast.success(t('account.saved')) ? { ok: true, text: t('account.saved') }
} else { : { ok: false, text: apiError({ data: { code: result.code } }) }
toast.error(apiError({ data: { code: result.code } }))
}
} }
/* ---------- 修改密码 ---------- */ /* ---------- 修改密码 ---------- */
const pwForm = reactive({ currentPassword: '', newPassword: '', confirmPassword: '' }) const pwForm = reactive({ currentPassword: '', newPassword: '', confirmPassword: '' })
const pwSaving = ref(false) const pwSaving = ref(false)
const pwError = ref('') const pwError = ref('')
const pwOk = ref(false)
const changePassword = async () => { const changePassword = async () => {
pwError.value = '' pwError.value = ''
if (pwForm.newPassword.length < 8) { pwOk.value = false
pwError.value = t('account.changePassword.tooShort') if (pwForm.newPassword.length < 8) { pwError.value = t('account.changePassword.tooShort'); return }
return if (pwForm.newPassword !== pwForm.confirmPassword) { pwError.value = t('account.changePassword.mismatch'); return }
}
if (pwForm.newPassword !== pwForm.confirmPassword) {
pwError.value = t('account.changePassword.mismatch')
return
}
pwSaving.value = true pwSaving.value = true
try { try {
await $fetch('/api/auth/password', { await $fetch('/api/auth/password', { method: 'PATCH', body: { currentPassword: pwForm.currentPassword, newPassword: pwForm.newPassword } })
method: 'PATCH',
body: { currentPassword: pwForm.currentPassword, newPassword: pwForm.newPassword },
})
pwForm.currentPassword = '' pwForm.currentPassword = ''
pwForm.newPassword = '' pwForm.newPassword = ''
pwForm.confirmPassword = '' pwForm.confirmPassword = ''
toast.success(t('account.changePassword.success')) pwOk.value = true
} catch (err) { } catch (err) {
pwError.value = pwError.value = (err as any)?.data?.code === 'WRONG_PASSWORD'
(err as any)?.data?.code === 'WRONG_PASSWORD'
? t('account.changePassword.wrongPassword') ? t('account.changePassword.wrongPassword')
: apiError(err, 'account.changePassword.failed') : apiError(err, 'account.changePassword.failed')
} finally { } finally {
@@ -123,28 +94,21 @@ const deletePassword = ref('')
const deleting = ref(false) const deleting = ref(false)
const deleteError = ref('') const deleteError = ref('')
const deleteConfirmOpen = ref(false) const deleteConfirmOpen = ref(false)
const askDeleteAccount = () => { const askDeleteAccount = () => {
deleteError.value = '' deleteError.value = ''
if (!deletePassword.value.trim()) { if (!deletePassword.value.trim()) { deleteError.value = t('account.deleteAccount.passwordPlaceholder'); return }
deleteError.value = t('account.deleteAccount.passwordPlaceholder')
return
}
deleteConfirmOpen.value = true deleteConfirmOpen.value = true
} }
const doDeleteAccount = async () => { const doDeleteAccount = async () => {
deleting.value = true deleting.value = true
try { try {
await $fetch('/api/auth/me', { method: 'DELETE', body: { password: deletePassword.value } }) await $fetch('/api/auth/me', { method: 'DELETE', body: { password: deletePassword.value } })
deleteConfirmOpen.value = false deleteConfirmOpen.value = false
toast.success(t('account.deleteAccount.success'))
await userStore.logout() await userStore.logout()
await navigateTo('/') await navigateTo('/')
} catch (err) { } catch (err) {
deleteConfirmOpen.value = false deleteConfirmOpen.value = false
deleteError.value = deleteError.value = (err as any)?.data?.code === 'WRONG_PASSWORD'
(err as any)?.data?.code === 'WRONG_PASSWORD'
? t('account.deleteAccount.wrongPassword') ? t('account.deleteAccount.wrongPassword')
: apiError(err) : apiError(err)
} finally { } finally {
@@ -152,29 +116,13 @@ const doDeleteAccount = async () => {
} }
} }
/* ---------- 我的收藏 ---------- */ /* ---------- 收藏 ---------- */
interface FavedWork { interface FavedWork { slug: string; titleZh: string; titleEn: string; image: string | null; year: string; category: string }
slug: string
titleZh: string
titleEn: string
image: string | null
year: string
category: string
}
const favorites = ref<FavedWork[]>([]) const favorites = ref<FavedWork[]>([])
const favLoading = ref(false) const favLoading = ref(false)
const favLoaded = ref(false) const favLoaded = ref(false)
const favTitle = (w: FavedWork) => (locale.value === 'zh' ? w.titleZh : w.titleEn) const favTitle = (w: FavedWork) => (locale.value === 'zh' ? w.titleZh : w.titleEn)
const categoryLabel = (cat: string) => (['webDesign', 'branding', 'development'].includes(cat) ? t(`work.categories.${cat}`) : cat)
const CATEGORY_KEYS: Record<string, string> = {
webDesign: 'webDesign',
branding: 'branding',
development: 'development',
}
const categoryLabel = (cat: string) =>
CATEGORY_KEYS[cat] ? t(`work.categories.${CATEGORY_KEYS[cat]}`) : cat
const loadFavorites = async () => { const loadFavorites = async () => {
if (favLoaded.value) return if (favLoaded.value) return
favLoading.value = true favLoading.value = true
@@ -186,34 +134,20 @@ const loadFavorites = async () => {
const bySlug = new Map(workRes.works.map((w) => [w.slug, w])) const bySlug = new Map(workRes.works.map((w) => [w.slug, w]))
favorites.value = favRes.slugs.map((s) => bySlug.get(s)).filter(Boolean) as FavedWork[] favorites.value = favRes.slugs.map((s) => bySlug.get(s)).filter(Boolean) as FavedWork[]
favLoaded.value = true favLoaded.value = true
} catch (err) { } catch (err) { console.error('load favorites error:', err) } finally { favLoading.value = false }
console.error('load favorites error:', err)
} finally {
favLoading.value = false
} }
}
const removeFavorite = async (slug: string) => { const removeFavorite = async (slug: string) => {
try { try {
await $fetch('/api/favorites', { method: 'DELETE', body: { workSlug: slug } }) await $fetch('/api/favorites', { method: 'DELETE', body: { workSlug: slug } })
favorites.value = favorites.value.filter((f) => f.slug !== slug) favorites.value = favorites.value.filter((f) => f.slug !== slug)
toast.success(t('favorites.remove')) } catch (err) { console.error('remove favorite error:', err) }
} catch (err) {
toast.error(apiError(err))
}
} }
/* ---------- 我的评论 ---------- */ /* ---------- 我的评论 ---------- */
interface MyComment { interface MyComment { id: number; newsSlug: string; content: string; createdAt: string }
id: number
newsSlug: string
content: string
createdAt: string
}
const myComments = ref<MyComment[]>([]) const myComments = ref<MyComment[]>([])
const commentLoading = ref(false) const commentLoading = ref(false)
const commentsLoaded = ref(false) const commentsLoaded = ref(false)
const loadComments = async () => { const loadComments = async () => {
if (commentsLoaded.value) return if (commentsLoaded.value) return
commentLoading.value = true commentLoading.value = true
@@ -221,25 +155,20 @@ const loadComments = async () => {
const data = await $fetch<{ comments: MyComment[] }>('/api/account/comments') const data = await $fetch<{ comments: MyComment[] }>('/api/account/comments')
myComments.value = data.comments myComments.value = data.comments
commentsLoaded.value = true commentsLoaded.value = true
} catch (err) { } catch (err) { console.error('load comments error:', err) } finally { commentLoading.value = false }
console.error('load comments error:', err)
} finally {
commentLoading.value = false
}
} }
/* ---------- 页面入场动画 ---------- */ /* ---------- 入场动画 ---------- */
const mainRef = ref<HTMLElement | null>(null) const mainRef = ref<HTMLElement | null>(null)
let ctx: gsap.Context | null = null let ctx: gsap.Context | null = null
const runIntro = () => { const runIntro = () => {
ctx?.revert() ctx?.revert()
if (!mainRef.value) return if (!mainRef.value) return
ctx = gsap.context(() => { ctx = gsap.context(() => {
const targets = gsap.utils.toArray<HTMLElement>('[data-animate]', mainRef.value) const targets = gsap.utils.toArray<HTMLElement>('[data-animate]', mainRef.value)
if (!targets.length) return if (!targets.length) return
gsap.set(targets, { autoAlpha: 0, y: 24 }) gsap.set(targets, { autoAlpha: 0, y: 22 })
gsap.to(targets, { autoAlpha: 1, y: 0, duration: 0.7, ease: 'power3.out', stagger: 0.1 }) gsap.to(targets, { autoAlpha: 1, y: 0, duration: 0.7, ease: 'power3.out', stagger: 0.08 })
}, mainRef.value) }, mainRef.value)
} }
@@ -247,231 +176,202 @@ onMounted(async () => {
await nextTick() await nextTick()
initProfileForm() initProfileForm()
runIntro() runIntro()
// 统计数字依赖收藏/评论数据,异步补齐(入场动画不等待网络) if (userStore.isAuthenticated) await Promise.all([loadFavorites(), loadComments()])
if (userStore.isAuthenticated) {
await Promise.all([loadFavorites(), loadComments()])
}
})
onBeforeUnmount(() => {
ctx?.revert()
}) })
onBeforeUnmount(() => ctx?.revert())
</script> </script>
<template> <template>
<main <main ref="mainRef" class="page-container min-h-screen pt-28 md:pt-36 pb-24 px-4 md:px-8 mx-auto max-w-[1000px]">
ref="mainRef"
class="page-container min-h-screen pt-24 md:pt-32 pb-24 px-4 md:px-8 mx-auto max-w-[1100px]"
>
<AdminToast />
<!-- 未登录 --> <!-- 未登录 -->
<section <section v-if="!userStore.isAuthenticated" data-animate class="max-w-sm mx-auto mt-10 md:mt-20 text-center">
v-if="!userStore.isAuthenticated"
data-animate
class="max-w-md mx-auto mt-10 md:mt-16 p-10 rounded-3xl bg-white border border-gray-100 shadow-xl text-center"
>
<div class="w-16 h-16 mx-auto rounded-full bg-gray-100 flex items-center justify-center mb-6"> <div class="w-16 h-16 mx-auto rounded-full bg-gray-100 flex items-center justify-center mb-6">
<Icon name="ph:user-duotone" class="w-8 h-8 text-gray-400" /> <Icon name="ph:user-duotone" class="w-8 h-8 text-gray-400" />
</div> </div>
<h1 class="text-2xl font-bold text-black mb-3">{{ t('account.title') }}</h1> <h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black mb-3">{{ t('account.title') }}</h1>
<p class="text-gray-500 mb-8">{{ t('auth.loginRequired') }}</p> <p class="text-gray-500 mb-8">{{ t('auth.loginRequired') }}</p>
<AdminButton size="lg" @click="authModal.openLogin()"> <button
<Icon name="ph:sign-in" class="w-4 h-4" /> @click="authModal.openLogin()"
class="px-8 py-3 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors"
>
{{ t('auth.login') }} {{ t('auth.login') }}
</AdminButton> </button>
</section> </section>
<template v-else> <template v-else>
<!-- 顶部资料卡 --> <!-- 资料区(黑白极简) -->
<section data-animate class="relative overflow-hidden rounded-3xl bg-black text-white shadow-xl"> <header data-animate class="rounded-3xl border border-gray-100 bg-white shadow-sm">
<!-- 装饰渐变 --> <div class="px-6 py-8 md:px-10 md:py-10">
<div class="pointer-events-none absolute -top-24 -right-20 w-72 h-72 rounded-full bg-gradient-to-br from-indigo-500/40 via-fuchsia-500/20 to-transparent blur-3xl"></div> <div class="flex flex-col md:flex-row md:items-start gap-6 md:gap-8">
<div class="pointer-events-none absolute -bottom-28 -left-16 w-80 h-80 rounded-full bg-gradient-to-tr from-cyan-400/30 to-blue-600/10 blur-3xl"></div>
<div class="relative p-6 md:p-10">
<!-- 身份信息 -->
<div class="flex flex-col md:flex-row md:items-center gap-5 md:gap-7">
<div class="flex-shrink-0">
<div class="w-20 h-20 md:w-24 md:h-24 rounded-2xl bg-white/10 border border-white/20 p-1.5">
<img <img
:src="userStore.avatar" :src="userStore.avatar"
:alt="userStore.user?.username" :alt="userStore.user?.username"
class="w-full h-full rounded-xl object-cover" class="w-20 h-20 md:w-24 md:h-24 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0"
/> />
</div>
</div>
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
<div class="flex items-center gap-3 flex-wrap"> <div class="flex items-center gap-3 flex-wrap">
<h1 class="text-2xl md:text-3xl font-bold tracking-tight">{{ userStore.user?.username }}</h1> <h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black">{{ userStore.user?.username }}</h1>
<AdminBadge v-if="isAdmin" tone="amber"> <span
<Icon name="ph:shield-check" class="w-3 h-3" /> {{ t('account.roleAdmin') }} class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold"
</AdminBadge> :class="isAdmin ? 'bg-black text-white' : 'bg-gray-100 text-gray-600'"
<AdminBadge v-else tone="blue">{{ t('account.roleUser') }}</AdminBadge> >
<Icon :name="isAdmin ? 'ph:shield-check' : 'ph:user'" class="w-3 h-3" />
{{ isAdmin ? t('account.roleAdmin') : t('account.roleUser') }}
</span>
</div> </div>
<p class="mt-2 flex items-center gap-2 text-sm md:text-base text-white/70"> <p class="mt-2 text-gray-500">{{ userStore.user?.email }}</p>
<Icon name="ph:envelope-simple" class="w-4 h-4 flex-shrink-0" /> <p class="mt-1 text-sm text-gray-400">
<span class="truncate">{{ userStore.user?.email }}</span>
</p>
<p class="mt-1 flex items-center gap-2 text-xs md:text-sm text-white/50">
<Icon name="ph:calendar-dots" class="w-4 h-4 flex-shrink-0" />
{{ t('account.joinedAt') }} · {{ formatDate(userStore.user?.createdAt) }} {{ t('account.joinedAt') }} · {{ formatDate(userStore.user?.createdAt) }}
</p> </p>
</div> </div>
<!-- 管理员入口 -->
<div v-if="isAdmin" class="flex-shrink-0">
<NuxtLink <NuxtLink
v-if="isAdmin"
to="/admin" to="/admin"
class="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-white text-black text-sm font-semibold hover:bg-white/90 transition-colors shadow-lg" class="inline-flex items-center gap-1.5 text-sm font-semibold text-black underline underline-offset-4 hover:text-gray-500 transition-colors flex-shrink-0"
> >
<Icon name="ph:gear-six" class="w-4 h-4" />
{{ t('account.adminEntry') }} {{ t('account.adminEntry') }}
<Icon name="ph:arrow-right" class="w-4 h-4" />
</NuxtLink> </NuxtLink>
</div> </div>
</div>
<!-- 统计 --> <!-- 统计(细分隔线) -->
<div class="mt-8 grid grid-cols-3 gap-3 md:gap-5"> <div class="mt-8 grid grid-cols-3 divide-x divide-gray-200 border-t border-gray-100 pt-6">
<div class="rounded-2xl bg-white/10 border border-white/10 px-3 py-4 md:py-5 text-center"> <div class="text-center">
<p class="text-xl md:text-3xl font-bold leading-none">{{ favorites.length }}</p> <p class="text-2xl md:text-3xl font-bold text-black leading-none">{{ favorites.length }}</p>
<p class="mt-2 text-[11px] md:text-xs text-white/60">{{ t('account.statFavorites') }}</p> <p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statFavorites') }}</p>
</div> </div>
<div class="rounded-2xl bg-white/10 border border-white/10 px-3 py-4 md:py-5 text-center"> <div class="text-center">
<p class="text-xl md:text-3xl font-bold leading-none">{{ myComments.length }}</p> <p class="text-2xl md:text-3xl font-bold text-black leading-none">{{ myComments.length }}</p>
<p class="mt-2 text-[11px] md:text-xs text-white/60">{{ t('account.statComments') }}</p> <p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statComments') }}</p>
</div> </div>
<div class="rounded-2xl bg-white/10 border border-white/10 px-3 py-4 md:py-5 text-center"> <div class="text-center">
<p class="text-sm md:text-base font-bold leading-tight break-words">{{ formatMonth(userStore.user?.createdAt) }}</p> <p class="text-lg md:text-2xl font-bold text-black leading-none">{{ formatDate(userStore.user?.createdAt, true) }}</p>
<p class="mt-2 text-[11px] md:text-xs text-white/60">{{ t('account.statJoined') }}</p> <p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statJoined') }}</p>
</div> </div>
</div> </div>
</div> </div>
</section> </header>
<!-- 页签 --> <!-- 页签(下划线) -->
<nav data-animate class="mt-8 md:mt-10 flex justify-center"> <nav data-animate class="mt-10 border-b border-gray-200">
<div class="inline-flex p-1.5 rounded-full bg-white border border-gray-100 shadow-sm"> <div class="flex gap-8 overflow-x-auto">
<button <button
v-for="tab in tabs" v-for="tab in tabs"
:key="tab.key" :key="tab.key"
type="button" type="button"
@click="switchTab(tab.key)" @click="switchTab(tab.key)"
class="flex items-center gap-2 px-5 md:px-6 py-2.5 rounded-full text-sm font-semibold transition-all duration-300" class="flex items-center gap-2 py-3 text-sm font-semibold border-b-2 -mb-px whitespace-nowrap transition-colors"
:class="activeTab === tab.key ? 'bg-black text-white shadow' : 'text-gray-500 hover:text-black'" :class="activeTab === tab.key ? 'border-black text-black' : 'border-transparent text-gray-400 hover:text-black'"
> >
{{ tab.label }} {{ tab.label }}
<span <span v-if="tab.count != null" class="text-xs text-gray-400">{{ tab.count }}</span>
v-if="tab.count != null"
class="text-[11px] leading-none px-1.5 py-1 rounded-full"
:class="activeTab === tab.key ? 'bg-white/20 text-white' : 'bg-gray-100 text-gray-500'"
>
{{ tab.count }}
</span>
</button> </button>
</div> </div>
</nav> </nav>
<!-- 内容区 --> <!-- 内容 -->
<div class="mt-8 md:mt-10"> <div class="mt-8 md:mt-10">
<Transition name="panel" mode="out-in"> <Transition name="panel" mode="out-in">
<!-- 个人资料 --> <!-- 个人资料 -->
<section v-if="activeTab === 'profile'" key="profile" class="space-y-6 max-w-2xl mx-auto"> <section v-if="activeTab === 'profile'" key="profile" class="space-y-6 max-w-2xl mx-auto">
<!-- 资料编辑 --> <!-- 资料编辑 -->
<div class="rounded-3xl bg-white border border-gray-100 shadow-sm overflow-hidden"> <div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
<div class="px-6 py-4 border-b border-gray-100 flex items-center gap-3"> <div class="px-6 md:px-8 py-5 border-b border-gray-100">
<div class="w-9 h-9 rounded-xl bg-gray-100 text-gray-600 flex items-center justify-center"> <h3 class="text-lg font-bold text-black">{{ t('account.profile') }}</h3>
<Icon name="ph:user-focus" class="w-5 h-5" /> <p class="text-sm text-gray-400 mt-0.5">个人基本信息</p>
</div>
<div class="px-6 md:px-8 py-6 space-y-5">
<div>
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.username') }}</label>
<input v-model="profileForm.username" type="text"
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" />
</div> </div>
<div> <div>
<h3 class="text-base font-bold text-black">{{ t('account.profile') }}</h3> <label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.phone') }}</label>
<p class="text-xs text-gray-400">个人基本信息</p> <input v-model="profileForm.phone" type="tel"
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" />
</div> </div>
<div>
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.email') }}</label>
<input :value="userStore.user?.email ?? ''" type="email" disabled
class="w-full rounded-xl border border-gray-200 bg-gray-50 px-3.5 py-2.5 text-sm text-gray-500 cursor-not-allowed" />
</div> </div>
<div class="p-6 space-y-5"> <p v-if="profileMsg" class="text-sm" :class="profileMsg.ok ? 'text-green-600' : 'text-red-600'">{{ profileMsg.text }}</p>
<AdminInput v-model="profileForm.username" :label="t('account.username')" required /> <div class="flex justify-end">
<AdminInput v-model="profileForm.phone" :label="t('account.phone')" type="tel" /> <button
<AdminInput @click="saveProfile"
:model-value="userStore.user?.email ?? ''" :disabled="profileSaving"
:label="t('account.email')" class="inline-flex items-center gap-2 px-6 py-2.5 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors disabled:opacity-50"
type="email" >
disabled <Icon v-if="profileSaving" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
/>
<div class="flex justify-end pt-1">
<AdminButton :loading="profileSaving" @click="saveProfile">
<Icon v-if="!profileSaving" name="ph:floppy-disk" class="w-4 h-4" />
{{ profileSaving ? t('account.saving') : t('account.save') }} {{ profileSaving ? t('account.saving') : t('account.save') }}
</AdminButton> </button>
</div> </div>
</div> </div>
</div> </div>
<!-- 修改密码 --> <!-- 修改密码 -->
<div class="rounded-3xl bg-white border border-gray-100 shadow-sm overflow-hidden"> <div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
<div class="px-6 py-4 border-b border-gray-100 flex items-center gap-3"> <div class="px-6 md:px-8 py-5 border-b border-gray-100">
<div class="w-9 h-9 rounded-xl bg-gray-100 text-gray-600 flex items-center justify-center"> <h3 class="text-lg font-bold text-black">{{ t('account.changePassword.title') }}</h3>
<Icon name="ph:key" class="w-5 h-5" /> <p class="text-sm text-gray-400 mt-0.5">定期更换密码更安全</p>
</div>
<form class="px-6 md:px-8 py-6 space-y-5" @submit.prevent="changePassword">
<div>
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.changePassword.currentPassword') }}</label>
<input v-model="pwForm.currentPassword" type="password" autocomplete="current-password" required
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" />
</div> </div>
<div> <div>
<h3 class="text-base font-bold text-black">{{ t('account.changePassword.title') }}</h3> <label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.changePassword.newPassword') }}</label>
<p class="text-xs text-gray-400">定期更换密码更安全</p> <input v-model="pwForm.newPassword" type="password" autocomplete="new-password" required
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" />
</div> </div>
<div>
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.changePassword.confirmPassword') }}</label>
<input v-model="pwForm.confirmPassword" type="password" autocomplete="new-password" required
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" />
</div> </div>
<form class="p-6 space-y-5" @submit.prevent="changePassword">
<AdminInput
v-model="pwForm.currentPassword"
:label="t('account.changePassword.currentPassword')"
type="password"
required
/>
<AdminInput
v-model="pwForm.newPassword"
:label="t('account.changePassword.newPassword')"
type="password"
required
/>
<AdminInput
v-model="pwForm.confirmPassword"
:label="t('account.changePassword.confirmPassword')"
type="password"
required
/>
<p v-if="pwError" class="text-sm text-red-600">{{ pwError }}</p> <p v-if="pwError" class="text-sm text-red-600">{{ pwError }}</p>
<div class="flex justify-end pt-1"> <p v-if="pwOk" class="text-sm text-green-600">{{ t('account.changePassword.success') }}</p>
<AdminButton type="submit" variant="secondary" :loading="pwSaving"> <div class="flex justify-end">
<Icon v-if="!pwSaving" name="ph:lock-simple" class="w-4 h-4" /> <button
type="submit"
:disabled="pwSaving"
class="inline-flex items-center gap-2 px-6 py-2.5 rounded-full border border-gray-200 text-gray-700 text-sm font-semibold hover:border-black hover:text-black transition-colors disabled:opacity-50"
>
<Icon v-if="pwSaving" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
{{ pwSaving ? t('account.changePassword.saving') : t('account.changePassword.submit') }} {{ pwSaving ? t('account.changePassword.saving') : t('account.changePassword.submit') }}
</AdminButton> </button>
</div> </div>
</form> </form>
</div> </div>
<!-- 删除账号(危险区) --> <!-- 删除账号(克制危险区) -->
<div class="rounded-3xl border-2 border-red-100 bg-red-50/50 shadow-sm overflow-hidden"> <div class="rounded-2xl border border-red-200 bg-red-50/40 overflow-hidden">
<div class="px-6 py-4 border-b border-red-100 flex items-center gap-3"> <div class="px-6 md:px-8 py-5 border-b border-red-100">
<div class="w-9 h-9 rounded-xl bg-red-100 text-red-600 flex items-center justify-center"> <h3 class="text-lg font-bold text-red-600">{{ t('account.deleteAccount.title') }}</h3>
<Icon name="ph:warning" class="w-5 h-5" /> <p class="text-sm text-red-400 mt-0.5">危险操作</p>
</div> </div>
<div> <div class="px-6 md:px-8 py-6 space-y-5">
<h3 class="text-base font-bold text-red-600">{{ t('account.deleteAccount.title') }}</h3>
<p class="text-xs text-red-400">危险操作</p>
</div>
</div>
<div class="p-6 space-y-5">
<p class="text-sm text-gray-600 leading-relaxed">{{ t('account.deleteAccount.hint') }}</p> <p class="text-sm text-gray-600 leading-relaxed">{{ t('account.deleteAccount.hint') }}</p>
<AdminInput <div>
v-model="deletePassword" <label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('auth.password') }}</label>
:label="t('auth.password')" <input v-model="deletePassword" type="password" autocomplete="current-password"
:placeholder="t('account.deleteAccount.passwordPlaceholder')" :placeholder="t('account.deleteAccount.passwordPlaceholder')"
type="password" @keydown.enter.prevent="askDeleteAccount"
/> 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-red-400 focus:ring-2 focus:ring-red-500/10" />
</div>
<p v-if="deleteError" class="text-sm text-red-600">{{ deleteError }}</p> <p v-if="deleteError" class="text-sm text-red-600">{{ deleteError }}</p>
<div class="flex justify-end pt-1"> <div class="flex justify-end">
<AdminButton variant="danger" :loading="deleting" @click="askDeleteAccount"> <button
<Icon v-if="!deleting" name="ph:trash" class="w-4 h-4" /> @click="askDeleteAccount"
:disabled="deleting"
class="inline-flex items-center gap-2 px-6 py-2.5 rounded-full bg-red-600 text-white text-sm font-semibold hover:bg-red-700 transition-colors disabled:opacity-50"
>
<Icon v-if="deleting" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
{{ t('account.deleteAccount.confirmButton') }} {{ t('account.deleteAccount.confirmButton') }}
</AdminButton> </button>
</div> </div>
</div> </div>
</div> </div>
@@ -480,70 +380,41 @@ onBeforeUnmount(() => {
<!-- 我的收藏 --> <!-- 我的收藏 -->
<section v-else-if="activeTab === 'favorites'" key="favorites"> <section v-else-if="activeTab === 'favorites'" key="favorites">
<div v-if="favLoading" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5"> <div v-if="favLoading" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
<div <div v-for="i in 3" :key="i" class="rounded-2xl border border-gray-100 bg-white overflow-hidden animate-pulse">
v-for="i in 3"
:key="i"
class="rounded-2xl bg-white border border-gray-100 shadow-sm overflow-hidden animate-pulse"
>
<div class="aspect-[4/3] bg-gray-100"></div> <div class="aspect-[4/3] bg-gray-100"></div>
<div class="p-4 space-y-2"> <div class="p-4 space-y-2"><div class="h-3.5 rounded bg-gray-100 w-2/3"></div><div class="h-3 rounded bg-gray-100 w-1/3"></div></div>
<div class="h-3.5 rounded bg-gray-100 w-2/3"></div>
<div class="h-3 rounded bg-gray-100 w-1/3"></div>
</div> </div>
</div> </div>
<div v-else-if="!favorites.length" class="text-center py-20">
<Icon name="ph:bookmark-simple" class="w-12 h-12 text-gray-200 mx-auto mb-4" />
<p class="text-gray-500">{{ t('account.emptyFavorites') }}</p>
</div> </div>
<AdminEmptyState
v-else-if="!favorites.length"
icon="ph:bookmark-simple"
:title="t('account.emptyFavorites')"
/>
<div v-else class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5"> <div v-else class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
<div <div v-for="fav in favorites" :key="fav.slug"
v-for="fav in favorites" class="group rounded-2xl overflow-hidden bg-white border border-gray-100 shadow-sm hover:shadow-xl transition-all duration-300 hover:-translate-y-1">
:key="fav.slug"
class="group rounded-2xl overflow-hidden bg-white border border-gray-100 shadow-sm hover:shadow-xl transition-all duration-300 hover:-translate-y-1"
>
<div class="relative aspect-[4/3] overflow-hidden bg-gray-50"> <div class="relative aspect-[4/3] overflow-hidden bg-gray-50">
<NuxtLink :to="`/work/${fav.slug}`" class="block w-full h-full" :aria-label="favTitle(fav)"> <NuxtLink :to="`/work/${fav.slug}`" class="block w-full h-full" :aria-label="favTitle(fav)">
<img <img v-if="fav.image" :src="fav.image" :alt="favTitle(fav)" loading="lazy"
v-if="fav.image" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
:src="fav.image" <div v-else class="w-full h-full flex items-center justify-center"><Icon name="ph:image" class="w-8 h-8 text-gray-300" /></div>
:alt="favTitle(fav)"
class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
/>
<div v-else class="w-full h-full flex items-center justify-center">
<Icon name="ph:image" class="w-8 h-8 text-gray-300" />
</div>
</NuxtLink> </NuxtLink>
<span <span v-if="fav.year"
v-if="fav.year" class="absolute top-3 left-3 px-2.5 py-1 rounded-full bg-black/60 backdrop-blur-sm text-white text-xs font-semibold pointer-events-none">
class="absolute top-3 left-3 px-2.5 py-1 rounded-full bg-black/60 backdrop-blur-sm text-white text-xs font-semibold pointer-events-none"
>
{{ fav.year }} {{ fav.year }}
</span> </span>
<button <button type="button" @click="removeFavorite(fav.slug)"
type="button"
@click="removeFavorite(fav.slug)"
class="absolute top-3 right-3 w-9 h-9 rounded-full bg-white/90 backdrop-blur-sm text-gray-600 hover:bg-red-500 hover:text-white flex items-center justify-center shadow transition-all duration-200" class="absolute top-3 right-3 w-9 h-9 rounded-full bg-white/90 backdrop-blur-sm text-gray-600 hover:bg-red-500 hover:text-white flex items-center justify-center shadow transition-all duration-200"
:aria-label="t('favorites.remove')" :aria-label="t('favorites.remove')">
>
<Icon name="ph:bookmark-simple-fill" class="w-4 h-4" /> <Icon name="ph:bookmark-simple-fill" class="w-4 h-4" />
</button> </button>
</div> </div>
<div class="p-4"> <div class="p-4">
<NuxtLink <NuxtLink :to="`/work/${fav.slug}`" class="block font-bold text-black group-hover:text-gray-600 transition-colors truncate">
:to="`/work/${fav.slug}`"
class="block font-bold text-black group-hover:text-gray-600 transition-colors truncate"
>
{{ favTitle(fav) }} {{ favTitle(fav) }}
</NuxtLink> </NuxtLink>
<p class="mt-1.5 inline-flex items-center gap-1.5"> <span class="mt-1.5 inline-block px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 text-xs font-medium">
<span class="px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 text-xs font-medium">
{{ categoryLabel(fav.category) }} {{ categoryLabel(fav.category) }}
</span> </span>
</p>
</div> </div>
</div> </div>
</div> </div>
@@ -552,38 +423,23 @@ onBeforeUnmount(() => {
<!-- 我的评论 --> <!-- 我的评论 -->
<section v-else key="comments" class="max-w-2xl mx-auto"> <section v-else key="comments" class="max-w-2xl mx-auto">
<div v-if="commentLoading" class="space-y-4"> <div v-if="commentLoading" class="space-y-4">
<div <div v-for="i in 3" :key="i" class="rounded-2xl border border-gray-100 bg-white p-5 animate-pulse space-y-3">
v-for="i in 3" <div class="h-3.5 rounded bg-gray-100 w-1/4"></div><div class="h-3 rounded bg-gray-100 w-full"></div>
:key="i"
class="rounded-2xl bg-white border border-gray-100 shadow-sm p-5 animate-pulse space-y-3"
>
<div class="h-3.5 rounded bg-gray-100 w-1/4"></div>
<div class="h-3 rounded bg-gray-100 w-full"></div>
<div class="h-3 rounded bg-gray-100 w-2/3"></div>
</div> </div>
</div> </div>
<div v-else-if="!myComments.length" class="text-center py-20">
<AdminEmptyState <Icon name="ph:chat-circle-text" class="w-12 h-12 text-gray-200 mx-auto mb-4" />
v-else-if="!myComments.length" <p class="text-gray-500">{{ t('account.emptyComments') }}</p>
icon="ph:chat-circle-text" </div>
:title="t('account.emptyComments')" <div v-else class="divide-y divide-gray-100 border border-gray-100 bg-white rounded-2xl shadow-sm">
/> <div v-for="comment in myComments" :key="comment.id" class="p-5 md:p-6 flex gap-4">
<div v-else class="space-y-4">
<div
v-for="comment in myComments"
:key="comment.id"
class="rounded-2xl bg-white border border-gray-100 shadow-sm p-5 flex gap-4"
>
<div class="w-10 h-10 rounded-full bg-gray-100 text-gray-400 flex items-center justify-center flex-shrink-0"> <div class="w-10 h-10 rounded-full bg-gray-100 text-gray-400 flex items-center justify-center flex-shrink-0">
<Icon name="ph:chat-circle-dots" class="w-5 h-5" /> <Icon name="ph:chat-circle-dots" class="w-5 h-5" />
</div> </div>
<div class="min-w-0 flex-1"> <div class="min-w-0 flex-1">
<div class="flex items-center justify-between gap-3 flex-wrap"> <div class="flex items-center justify-between gap-3 flex-wrap">
<NuxtLink <NuxtLink :to="`/news/${comment.newsSlug}`"
:to="`/news/${comment.newsSlug}`" class="inline-flex items-center gap-1.5 text-sm font-semibold text-black hover:text-gray-600 transition-colors">
class="inline-flex items-center gap-1.5 text-sm font-semibold text-black hover:text-gray-600 transition-colors"
>
<Icon name="ph:article" class="w-4 h-4 text-gray-400" /> <Icon name="ph:article" class="w-4 h-4 text-gray-400" />
#{{ comment.newsSlug }} #{{ comment.newsSlug }}
</NuxtLink> </NuxtLink>
@@ -599,40 +455,32 @@ onBeforeUnmount(() => {
</template> </template>
<!-- 删除账号确认 --> <!-- 删除账号确认 -->
<AdminModal <div v-if="deleteConfirmOpen" class="fixed inset-0 z-[150] flex items-center justify-center bg-black/40 p-4" @click.self="deleteConfirmOpen = false">
:open="deleteConfirmOpen" <div class="w-full max-w-sm rounded-2xl bg-white shadow-2xl overflow-hidden">
:title="t('account.deleteAccount.title')" <div class="px-6 py-5 border-b border-gray-100 flex items-start gap-3">
@update:open="deleteConfirmOpen = $event"
>
<div class="flex items-start gap-3">
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-red-50 text-red-600"> <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-red-50 text-red-600">
<Icon name="ph:warning-fill" class="w-5 h-5" /> <Icon name="ph:warning-fill" class="w-5 h-5" />
</div> </div>
<p class="text-sm text-gray-700 leading-relaxed">{{ t('account.deleteAccount.confirmText') }}</p> <p class="text-sm text-gray-700 leading-relaxed pt-1">{{ t('account.deleteAccount.confirmText') }}</p>
</div> </div>
<template #footer> <div class="flex justify-end gap-2 px-6 py-4">
<AdminButton variant="secondary" size="sm" :disabled="deleting" @click="deleteConfirmOpen = false"> <button @click="deleteConfirmOpen = false" :disabled="deleting"
class="px-4 py-2 rounded-full border border-gray-200 text-sm font-semibold text-gray-600 hover:border-gray-300 transition-colors disabled:opacity-50">
{{ t('account.deleteAccount.cancelButton') }} {{ t('account.deleteAccount.cancelButton') }}
</AdminButton> </button>
<AdminButton variant="danger" size="sm" :loading="deleting" @click="doDeleteAccount"> <button @click="doDeleteAccount" :disabled="deleting"
class="inline-flex items-center gap-2 px-5 py-2 rounded-full bg-red-600 text-white text-sm font-semibold hover:bg-red-700 transition-colors disabled:opacity-50">
<Icon v-if="deleting" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
{{ t('account.deleteAccount.confirmButton') }} {{ t('account.deleteAccount.confirmButton') }}
</AdminButton> </button>
</template> </div>
</AdminModal> </div>
</div>
</main> </main>
</template> </template>
<style scoped> <style scoped>
.panel-enter-active, .panel-enter-active, .panel-leave-active { transition: opacity 0.25s ease, transform 0.25s ease; }
.panel-leave-active { .panel-enter-from { opacity: 0; transform: translateY(12px); }
transition: opacity 0.28s ease, transform 0.28s ease; .panel-leave-to { opacity: 0; transform: translateY(-8px); }
}
.panel-enter-from {
opacity: 0;
transform: translateY(14px);
}
.panel-leave-to {
opacity: 0;
transform: translateY(-8px);
}
</style> </style>
+25 -6
View File
@@ -145,8 +145,8 @@ const formatDate = (raw?: string) => {
<span v-if="keyword" class="text-sm text-gray-400">· 当前页匹配 {{ filteredLogs.length }} 条</span> <span v-if="keyword" class="text-sm text-gray-400">· 当前页匹配 {{ filteredLogs.length }} 条</span>
</div> </div>
<div class="mb-5 flex flex-col sm:flex-row gap-3"> <div class="mb-5 flex flex-col gap-3 md:flex-row">
<div class="relative flex-1 sm:max-w-xs"> <div class="relative flex-1 md:max-w-xs">
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" /> <Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
<input <input
v-model="keyword" v-model="keyword"
@@ -163,7 +163,7 @@ const formatDate = (raw?: string) => {
<Icon name="ph:x" class="w-3.5 h-3.5" /> <Icon name="ph:x" class="w-3.5 h-3.5" />
</button> </button>
</div> </div>
<AdminSelect v-model="actionFilter" :options="ACTION_OPTIONS" class="w-full sm:w-40" /> <AdminSelect v-model="actionFilter" :options="ACTION_OPTIONS" class="w-full md:w-40" />
</div> </div>
<!-- 加载态 --> <!-- 加载态 -->
@@ -192,12 +192,13 @@ const formatDate = (raw?: string) => {
<!-- 日志表格 --> <!-- 日志表格 -->
<template v-else> <template v-else>
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden"> <!-- 桌面表格(md+) -->
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="w-full text-sm"> <table class="w-full text-sm">
<thead> <thead>
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50"> <tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">时间</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap sticky left-0 bg-gray-50 z-10 border-r border-gray-100">时间</th>
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">操作人</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">操作人</th>
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">操作</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">操作</th>
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">对象</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">对象</th>
@@ -206,7 +207,7 @@ const formatDate = (raw?: string) => {
</thead> </thead>
<tbody class="divide-y divide-gray-50"> <tbody class="divide-y divide-gray-50">
<tr v-for="log in filteredLogs" :key="log.id" class="hover:bg-gray-50/60 transition-colors"> <tr v-for="log in filteredLogs" :key="log.id" class="hover:bg-gray-50/60 transition-colors">
<td class="px-5 py-4 text-gray-500 text-xs whitespace-nowrap">{{ formatDate(log.createdAt) }}</td> <td class="px-5 py-4 text-gray-500 text-xs whitespace-nowrap sticky left-0 bg-white z-10 border-r border-gray-100">{{ formatDate(log.createdAt) }}</td>
<td class="px-5 py-4 text-gray-700 whitespace-nowrap">{{ log.actor_name || 'system' }}</td> <td class="px-5 py-4 text-gray-700 whitespace-nowrap">{{ log.actor_name || 'system' }}</td>
<td class="px-5 py-4 whitespace-nowrap"> <td class="px-5 py-4 whitespace-nowrap">
<AdminBadge :tone="actionMeta(log.action).tone">{{ actionMeta(log.action).label }}</AdminBadge> <AdminBadge :tone="actionMeta(log.action).tone">{{ actionMeta(log.action).label }}</AdminBadge>
@@ -223,6 +224,24 @@ const formatDate = (raw?: string) => {
</div> </div>
</div> </div>
<!-- 移动端卡片(<md) -->
<div class="md:hidden space-y-3">
<div v-for="log in filteredLogs" :key="log.id" class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4">
<div class="flex items-center justify-between gap-2">
<AdminBadge :tone="actionMeta(log.action).tone">{{ actionMeta(log.action).label }}</AdminBadge>
<span class="text-xs text-gray-400 flex-shrink-0">{{ formatDate(log.createdAt) }}</span>
</div>
<div class="mt-2 flex items-center gap-2 text-sm">
<span class="text-gray-400 flex-shrink-0">操作人</span>
<span class="text-gray-700 truncate">{{ log.actor_name || 'system' }}</span>
</div>
<div class="mt-1.5">
<code class="inline-block max-w-full text-xs text-gray-600 bg-gray-50 border border-gray-100 rounded px-2 py-1 break-all">{{ log.target }}</code>
</div>
<p class="mt-2 text-sm text-gray-600 break-words">{{ log.detail || '—' }}</p>
</div>
</div>
<div class="mt-4"> <div class="mt-4">
<AdminPagination :total="total" :page="page" :page-size="pageSize" @page="changePage" /> <AdminPagination :total="total" :page="page" :page-size="pageSize" @page="changePage" />
</div> </div>
+42 -6
View File
@@ -178,8 +178,8 @@ const formatDate = (raw?: string) => {
<span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span> <span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span>
</div> </div>
<div class="mb-5 flex flex-wrap items-center gap-3"> <div class="mb-5 flex flex-col gap-3 md:flex-row md:items-center">
<div class="relative flex-1 sm:max-w-xs"> <div class="relative flex-1 md:max-w-xs">
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" /> <Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
<input <input
v-model="keyword" v-model="keyword"
@@ -196,7 +196,7 @@ const formatDate = (raw?: string) => {
<Icon name="ph:x" class="w-3.5 h-3.5" /> <Icon name="ph:x" class="w-3.5 h-3.5" />
</button> </button>
</div> </div>
<AdminButton variant="danger" size="sm" :disabled="!selected.size" @click="batchConfirmOpen = true"> <AdminButton variant="danger" size="sm" class="w-full md:w-auto" :disabled="!selected.size" @click="batchConfirmOpen = true">
<Icon name="ph:trash" class="w-4 h-4" /> 批量删除 <Icon name="ph:trash" class="w-4 h-4" /> 批量删除
</AdminButton> </AdminButton>
</div> </div>
@@ -227,12 +227,13 @@ const formatDate = (raw?: string) => {
<!-- 评论表格 --> <!-- 评论表格 -->
<template v-else> <template v-else>
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden"> <!-- 桌面表格(md+) -->
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="w-full text-sm"> <table class="w-full text-sm">
<thead> <thead>
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50"> <tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
<th class="px-5 py-4 w-10"> <th class="px-5 py-4 w-10 sticky left-0 bg-gray-50 z-10 border-r border-gray-100">
<input <input
type="checkbox" type="checkbox"
:checked="allChecked" :checked="allChecked"
@@ -254,7 +255,7 @@ const formatDate = (raw?: string) => {
class="hover:bg-gray-50/60 transition-colors" class="hover:bg-gray-50/60 transition-colors"
:class="selected.has(c.id) ? 'bg-gray-50/70' : ''" :class="selected.has(c.id) ? 'bg-gray-50/70' : ''"
> >
<td class="px-5 py-4"> <td class="px-5 py-4 sticky left-0 bg-white z-10 border-r border-gray-100">
<input <input
type="checkbox" type="checkbox"
:checked="selected.has(c.id)" :checked="selected.has(c.id)"
@@ -289,6 +290,41 @@ const formatDate = (raw?: string) => {
</div> </div>
</div> </div>
<!-- 移动端卡片(<md) -->
<div class="md:hidden space-y-3">
<div
v-for="c in filteredComments"
:key="c.id"
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4"
:class="selected.has(c.id) ? 'ring-2 ring-black/5 border-black/10' : ''"
>
<div class="flex items-start gap-3">
<input
type="checkbox"
:checked="selected.has(c.id)"
class="w-5 h-5 mt-0.5 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0"
@change="toggleOne(c.id)"
/>
<div class="min-w-0 flex-1">
<div class="flex items-center justify-between gap-2">
<NuxtLink
:to="`/news/${c.newsSlug}`"
class="inline-flex items-center gap-1.5 font-semibold text-black min-w-0"
>
<Icon name="ph:article" class="w-4 h-4 text-gray-400 flex-shrink-0" />
<span class="truncate">#{{ c.newsSlug }}</span>
</NuxtLink>
<AdminButton size="sm" variant="ghost" class="min-h-10 shrink-0 -my-1" @click="askDelete(c)">
<Icon name="ph:trash" class="w-4 h-4" />
</AdminButton>
</div>
<p class="mt-1 text-xs text-gray-400">作者:{{ c.username }} · {{ formatDate(c.createdAt) }}</p>
<p class="mt-2 text-sm text-gray-700 break-words line-clamp-3">{{ c.content }}</p>
</div>
</div>
</div>
</div>
<div class="mt-4"> <div class="mt-4">
<AdminPagination :total="total" :page="page" :page-size="pageSize" @page="changePage" /> <AdminPagination :total="total" :page="page" :page-size="pageSize" @page="changePage" />
</div> </div>
+31 -21
View File
@@ -208,8 +208,8 @@ const formatDate = (raw?: string) => {
<span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span> <span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span>
</div> </div>
<div class="mb-5 flex flex-wrap items-center gap-3"> <div class="mb-5 flex flex-col gap-3 md:flex-row md:items-center">
<div class="relative flex-1 sm:max-w-xs"> <div class="relative flex-1 md:max-w-xs">
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" /> <Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
<input <input
v-model="keyword" v-model="keyword"
@@ -233,9 +233,9 @@ const formatDate = (raw?: string) => {
{ value: 'unread', label: '未读' }, { value: 'unread', label: '未读' },
{ value: 'read', label: '已读' }, { value: 'read', label: '已读' },
]" ]"
class="w-full sm:w-36" class="w-full md:w-36"
/> />
<AdminButton variant="danger" size="sm" :disabled="!selected.size" @click="batchConfirmOpen = true"> <AdminButton variant="danger" size="sm" class="w-full md:w-auto" :disabled="!selected.size" @click="batchConfirmOpen = true">
<Icon name="ph:trash" class="w-4 h-4" /> 批量删除 <Icon name="ph:trash" class="w-4 h-4" /> 批量删除
</AdminButton> </AdminButton>
</div> </div>
@@ -270,35 +270,35 @@ const formatDate = (raw?: string) => {
/> />
<!-- 消息卡片列表 --> <!-- 消息卡片列表 -->
<div v-else class="space-y-4"> <div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
<div <div
v-for="c in pagedContacts" v-for="c in pagedContacts"
:key="c.id" :key="c.id"
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-5 md:p-6 transition-shadow" class="bg-white rounded-2xl border border-gray-100 shadow-sm p-5 flex flex-col gap-3 transition-shadow"
:class="[selected.has(c.id) ? 'ring-2 ring-black/5 border-black/10' : 'hover:shadow-md']" :class="[selected.has(c.id) ? 'ring-2 ring-black/5 border-black/10' : 'hover:shadow-md']"
> >
<div class="flex items-start justify-between gap-4"> <div class="flex items-start gap-3 min-w-0">
<div class="flex items-center gap-3 min-w-0">
<input <input
type="checkbox" type="checkbox"
:checked="selected.has(c.id)" :checked="selected.has(c.id)"
class="w-4 h-4 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0 mt-1" class="w-5 h-5 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0 mt-0.5"
@change="toggleOne(c.id)" @change="toggleOne(c.id)"
/> />
<div class="w-10 h-10 rounded-full bg-black text-white flex items-center justify-center font-bold flex-shrink-0"> <div class="w-10 h-10 rounded-full bg-black text-white flex items-center justify-center font-bold flex-shrink-0">
{{ (c.name || '?').charAt(0) }} {{ (c.name || '?').charAt(0) }}
</div> </div>
<div class="min-w-0"> <div class="min-w-0 flex-1">
<div class="flex items-center gap-2 flex-wrap"> <div class="flex flex-wrap items-center gap-x-2">
<h3 class="font-bold text-black">{{ c.name }}</h3> <h3 class="font-bold text-black">{{ c.name }}</h3>
<a :href="`mailto:${c.email}`" class="text-sm text-gray-500 hover:text-black transition-colors truncate"> <a :href="`mailto:${c.email}`" class="text-sm text-gray-500 hover:text-black transition-colors break-all">
{{ c.email }} {{ c.email }}
</a> </a>
</div> </div>
<p class="text-xs text-gray-400 mt-1">{{ formatDate(c.createdAt) }}</p> <p class="text-xs text-gray-400 mt-1">{{ formatDate(c.createdAt) }}</p>
</div> </div>
</div> </div>
<div class="flex items-center gap-2 flex-shrink-0">
<div class="flex flex-wrap items-center gap-2">
<AdminBadge :tone="Number(c.delivered) === 1 ? 'green' : 'amber'"> <AdminBadge :tone="Number(c.delivered) === 1 ? 'green' : 'amber'">
<Icon :name="Number(c.delivered) === 1 ? 'ph:check' : 'ph:clock'" class="w-3.5 h-3.5" /> <Icon :name="Number(c.delivered) === 1 ? 'ph:check' : 'ph:clock'" class="w-3.5 h-3.5" />
{{ Number(c.delivered) === 1 ? '已送达' : '未送达' }} {{ Number(c.delivered) === 1 ? '已送达' : '未送达' }}
@@ -307,21 +307,31 @@ const formatDate = (raw?: string) => {
<Icon :name="Number(c.read) === 1 ? 'ph:envelope-open' : 'ph:envelope-simple'" class="w-3.5 h-3.5" /> <Icon :name="Number(c.read) === 1 ? 'ph:envelope-open' : 'ph:envelope-simple'" class="w-3.5 h-3.5" />
{{ Number(c.read) === 1 ? '已读' : '未读' }} {{ Number(c.read) === 1 ? '已读' : '未读' }}
</AdminBadge> </AdminBadge>
<AdminButton size="sm" variant="secondary" :loading="togglingId === c.id" @click="toggleRead(c)"> </div>
<div class="flex-1 border-t border-gray-100 pt-3">
<p class="text-sm font-semibold text-gray-800">{{ c.subject }}</p>
<p class="mt-1.5 text-sm text-gray-600 whitespace-pre-line break-words">{{ c.message }}</p>
</div>
<div class="mt-auto pt-3 border-t border-gray-100 flex flex-wrap items-center gap-2">
<AdminButton
size="sm"
variant="secondary"
class="flex-1 min-w-0 min-h-10"
:loading="togglingId === c.id"
@click="toggleRead(c)"
>
<Icon :name="Number(c.read) === 1 ? 'ph:envelope-open' : 'ph:envelope-simple'" class="w-3.5 h-3.5" />
{{ Number(c.read) === 1 ? '标为未读' : '标为已读' }} {{ Number(c.read) === 1 ? '标为未读' : '标为已读' }}
</AdminButton> </AdminButton>
<AdminButton size="sm" variant="ghost" @click="askDelete(c)"> <AdminButton size="sm" variant="ghost" class="min-h-10 shrink-0" @click="askDelete(c)">
<Icon name="ph:trash" class="w-4 h-4" /> <Icon name="ph:trash" class="w-4 h-4" />
</AdminButton> </AdminButton>
</div> </div>
</div> </div>
<div class="mt-4 border-t border-gray-100 pt-4">
<p class="text-sm font-semibold text-gray-800">{{ c.subject }}</p>
<p class="mt-1.5 text-sm text-gray-600 whitespace-pre-line break-words">{{ c.message }}</p>
</div>
</div>
<div class="mt-4"> <div class="md:col-span-2 lg:col-span-3">
<AdminPagination :total="filteredContacts.length" :page="page" :page-size="pageSize" @page="changePage" /> <AdminPagination :total="filteredContacts.length" :page="page" :page-size="pageSize" @page="changePage" />
</div> </div>
</div> </div>
+3 -3
View File
@@ -196,7 +196,7 @@ const initial = (name?: string) => (name || '?').charAt(0).toUpperCase()
<AdminCard class="h-full transition-all duration-300 hover:-translate-y-0.5 hover:shadow-md"> <AdminCard class="h-full transition-all duration-300 hover:-translate-y-0.5 hover:shadow-md">
<div class="flex items-start justify-between gap-3"> <div class="flex items-start justify-between gap-3">
<div> <div>
<p class="text-3xl font-bold text-black leading-none">{{ card.value }}</p> <p class="text-2xl sm:text-3xl font-bold text-black leading-none tabular-nums">{{ card.value }}</p>
<p class="mt-2 text-sm font-semibold text-gray-800">{{ card.label }}</p> <p class="mt-2 text-sm font-semibold text-gray-800">{{ card.label }}</p>
<p class="mt-1 text-xs text-gray-400">{{ card.sub }}</p> <p class="mt-1 text-xs text-gray-400">{{ card.sub }}</p>
</div> </div>
@@ -300,11 +300,11 @@ const initial = (name?: string) => (name || '?').charAt(0).toUpperCase()
</div> </div>
<div v-else class="flex items-center gap-4"> <div v-else class="flex items-center gap-4">
<div class="flex-1"> <div class="flex-1">
<p class="text-2xl font-bold text-black leading-none">{{ files.length }}</p> <p class="text-2xl font-bold text-black leading-none tabular-nums">{{ files.length }}</p>
<p class="mt-1 text-xs text-gray-500">图片文件</p> <p class="mt-1 text-xs text-gray-500">图片文件</p>
</div> </div>
<div class="flex-1"> <div class="flex-1">
<p class="text-2xl font-bold text-black leading-none">{{ formatSize(storageTotalBytes) }}</p> <p class="text-2xl font-bold text-black leading-none tabular-nums">{{ formatSize(storageTotalBytes) }}</p>
<p class="mt-1 text-xs text-gray-500">总大小</p> <p class="mt-1 text-xs text-gray-500">总大小</p>
</div> </div>
</div> </div>
+11 -9
View File
@@ -271,7 +271,7 @@ const doDelete = async () => {
<button <button
v-if="keyword" v-if="keyword"
@click="keyword = ''" @click="keyword = ''"
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center" class="absolute right-2.5 top-1/2 -translate-y-1/2 w-6 h-6 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
aria-label="清空筛选" aria-label="清空筛选"
> >
<Icon name="ph:x" class="w-3.5 h-3.5" /> <Icon name="ph:x" class="w-3.5 h-3.5" />
@@ -366,10 +366,10 @@ const doDelete = async () => {
</td> </td>
<td class="px-5 py-4"> <td class="px-5 py-4">
<div class="flex items-center justify-end gap-2"> <div class="flex items-center justify-end gap-2">
<AdminButton size="sm" variant="secondary" @click="openEdit(a)"> <AdminButton size="sm" variant="secondary" class="min-h-10" @click="openEdit(a)">
<Icon name="ph:pencil-simple" class="w-3.5 h-3.5" /> 编辑 <Icon name="ph:pencil-simple" class="w-3.5 h-3.5" /> 编辑
</AdminButton> </AdminButton>
<AdminButton size="sm" variant="danger" @click="askDelete(a)"> <AdminButton size="sm" variant="danger" class="min-h-10" @click="askDelete(a)">
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除 <Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
</AdminButton> </AdminButton>
</div> </div>
@@ -408,7 +408,7 @@ const doDelete = async () => {
:options="CATEGORIES" :options="CATEGORIES"
/> />
<AdminInput v-model="form.date" type="date" label="发布日期" /> <AdminInput v-model="form.date" type="date" label="发布日期" />
<div class="grid grid-cols-2 gap-5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
<AdminInput <AdminInput
:model-value="String(form.readTime)" :model-value="String(form.readTime)"
type="number" type="number"
@@ -431,7 +431,7 @@ const doDelete = async () => {
<!-- 标题与摘要 --> <!-- 标题与摘要 -->
<AdminCard title="标题与摘要"> <AdminCard title="标题与摘要">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5"> <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<div class="space-y-4"> <div class="space-y-4">
<AdminInput v-model="form.titleZh" label="中文标题" required /> <AdminInput v-model="form.titleZh" label="中文标题" required />
<AdminTextarea v-model="form.excerptZh" label="中文摘要" :rows="3" /> <AdminTextarea v-model="form.excerptZh" label="中文摘要" :rows="3" />
@@ -457,14 +457,16 @@ const doDelete = async () => {
</AdminCard> </AdminCard>
<!-- 提交 --> <!-- 提交 -->
<div class="flex items-center justify-end gap-3"> <div class="flex flex-col sm:flex-row sm:items-center sm:justify-end gap-3">
<p v-if="formError" class="mr-auto text-sm text-red-600">{{ formError }}</p> <p v-if="formError" class="text-sm text-red-600 sm:mr-auto">{{ formError }}</p>
<AdminButton variant="secondary" @click="backToList">取消</AdminButton> <div class="flex items-center gap-3 w-full sm:w-auto sm:justify-end">
<AdminButton :loading="saving" @click="save"> <AdminButton class="flex-1 sm:flex-none" variant="secondary" @click="backToList">取消</AdminButton>
<AdminButton class="flex-1 sm:flex-none" :loading="saving" @click="save">
{{ saving ? '保存中…' : editingId != null ? '保存修改' : '创建动态' }} {{ saving ? '保存中…' : editingId != null ? '保存修改' : '创建动态' }}
</AdminButton> </AdminButton>
</div> </div>
</div> </div>
</div>
</template> </template>
<!-- 删除确认 --> <!-- 删除确认 -->
+36 -6
View File
@@ -175,8 +175,8 @@ const formatDate = (raw?: string) => {
<span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span> <span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span>
</div> </div>
<div class="mb-5 flex flex-wrap items-center gap-3"> <div class="mb-5 flex flex-col gap-3 md:flex-row md:items-center">
<div class="relative flex-1 sm:max-w-xs"> <div class="relative flex-1 md:max-w-xs">
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" /> <Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
<input <input
v-model="keyword" v-model="keyword"
@@ -193,7 +193,7 @@ const formatDate = (raw?: string) => {
<Icon name="ph:x" class="w-3.5 h-3.5" /> <Icon name="ph:x" class="w-3.5 h-3.5" />
</button> </button>
</div> </div>
<AdminButton variant="danger" size="sm" :disabled="!selected.size" @click="batchConfirmOpen = true"> <AdminButton variant="danger" size="sm" class="w-full md:w-auto" :disabled="!selected.size" @click="batchConfirmOpen = true">
<Icon name="ph:trash" class="w-4 h-4" /> 批量删除 <Icon name="ph:trash" class="w-4 h-4" /> 批量删除
</AdminButton> </AdminButton>
</div> </div>
@@ -224,12 +224,13 @@ const formatDate = (raw?: string) => {
<!-- 订阅表格 --> <!-- 订阅表格 -->
<template v-else> <template v-else>
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden"> <!-- 桌面表格(md+) -->
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="w-full text-sm"> <table class="w-full text-sm">
<thead> <thead>
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50"> <tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
<th class="px-5 py-4 w-10"> <th class="px-5 py-4 w-10 sticky left-0 bg-gray-50 z-10 border-r border-gray-100">
<input <input
type="checkbox" type="checkbox"
:checked="allChecked" :checked="allChecked"
@@ -249,7 +250,7 @@ const formatDate = (raw?: string) => {
class="hover:bg-gray-50/60 transition-colors" class="hover:bg-gray-50/60 transition-colors"
:class="selected.has(s.id) ? 'bg-gray-50/70' : ''" :class="selected.has(s.id) ? 'bg-gray-50/70' : ''"
> >
<td class="px-5 py-4"> <td class="px-5 py-4 sticky left-0 bg-white z-10 border-r border-gray-100">
<input <input
type="checkbox" type="checkbox"
:checked="selected.has(s.id)" :checked="selected.has(s.id)"
@@ -280,6 +281,35 @@ const formatDate = (raw?: string) => {
</div> </div>
</div> </div>
<!-- 移动端卡片(<md) -->
<div class="md:hidden space-y-3">
<div
v-for="s in pagedSubscribers"
:key="s.id"
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4"
:class="selected.has(s.id) ? 'ring-2 ring-black/5 border-black/10' : ''"
>
<div class="flex items-start gap-3">
<input
type="checkbox"
:checked="selected.has(s.id)"
class="w-5 h-5 mt-0.5 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0"
@change="toggleOne(s.id)"
/>
<div class="min-w-0 flex-1">
<a :href="`mailto:${s.email}`" class="inline-flex items-center gap-2 font-semibold text-black break-all">
<Icon name="ph:envelope-simple" class="w-4 h-4 text-gray-400 flex-shrink-0" />
{{ s.email }}
</a>
<p class="mt-1 text-xs text-gray-400">{{ formatDate(s.createdAt) }}</p>
</div>
<AdminButton size="sm" variant="ghost" class="min-h-10 shrink-0 -my-1" @click="askDelete(s)">
<Icon name="ph:trash" class="w-4 h-4" />
</AdminButton>
</div>
</div>
</div>
<div class="mt-4"> <div class="mt-4">
<AdminPagination :total="filteredSubscribers.length" :page="page" :page-size="pageSize" @page="changePage" /> <AdminPagination :total="filteredSubscribers.length" :page="page" :page-size="pageSize" @page="changePage" />
</div> </div>
+3 -3
View File
@@ -136,7 +136,7 @@ const formatDate = (raw?: string) => {
</div> </div>
<div class="mb-5"> <div class="mb-5">
<div class="relative flex-1 sm:max-w-xs"> <div class="relative flex-1 md:max-w-xs">
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" /> <Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
<input <input
v-model="keyword" v-model="keyword"
@@ -181,7 +181,7 @@ const formatDate = (raw?: string) => {
<!-- 图片网格 --> <!-- 图片网格 -->
<template v-else> <template v-else>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4"> <div class="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4">
<div <div
v-for="f in pagedFiles" v-for="f in pagedFiles"
:key="f.name" :key="f.name"
@@ -191,7 +191,7 @@ const formatDate = (raw?: string) => {
<img :src="f.url" :alt="f.name" loading="lazy" class="w-full h-full object-cover" /> <img :src="f.url" :alt="f.name" loading="lazy" class="w-full h-full object-cover" />
<button <button
@click="askDelete(f)" @click="askDelete(f)"
class="absolute top-2 right-2 w-8 h-8 rounded-full bg-black/60 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-600" class="absolute top-2 right-2 w-10 h-10 lg:w-8 lg:h-8 rounded-full bg-black/60 text-white flex items-center justify-center opacity-100 lg:opacity-0 lg:group-hover:opacity-100 transition-opacity hover:bg-red-600"
title="删除图片" title="删除图片"
> >
<Icon name="ph:trash" class="w-4 h-4" /> <Icon name="ph:trash" class="w-4 h-4" />
+65 -6
View File
@@ -152,8 +152,8 @@ const formatDate = (raw?: string) => {
<span class="text-sm text-gray-400">· 管理员 {{ adminCount }} · 普通用户 {{ users.length - adminCount }}</span> <span class="text-sm text-gray-400">· 管理员 {{ adminCount }} · 普通用户 {{ users.length - adminCount }}</span>
</div> </div>
<div class="mb-5 flex flex-col sm:flex-row gap-3"> <div class="mb-5 flex flex-col gap-3 md:flex-row">
<div class="relative flex-1 sm:max-w-xs"> <div class="relative flex-1 md:max-w-xs">
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" /> <Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
<input <input
v-model="keyword" v-model="keyword"
@@ -177,7 +177,7 @@ const formatDate = (raw?: string) => {
{ value: 'admin', label: '管理员' }, { value: 'admin', label: '管理员' },
{ value: 'user', label: '普通用户' }, { value: 'user', label: '普通用户' },
]" ]"
class="w-full sm:w-40" class="w-full md:w-40"
/> />
</div> </div>
@@ -207,12 +207,13 @@ const formatDate = (raw?: string) => {
<!-- 用户表格 --> <!-- 用户表格 -->
<template v-else> <template v-else>
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden"> <!-- 桌面表格(md+) -->
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="w-full text-sm"> <table class="w-full text-sm">
<thead> <thead>
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50"> <tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">ID</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap sticky left-0 bg-gray-50 z-10 border-r border-gray-100">ID</th>
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">用户名</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">用户名</th>
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">邮箱</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">邮箱</th>
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">手机号</th> <th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">手机号</th>
@@ -223,7 +224,7 @@ const formatDate = (raw?: string) => {
</thead> </thead>
<tbody class="divide-y divide-gray-50"> <tbody class="divide-y divide-gray-50">
<tr v-for="u in pagedUsers" :key="u.id" class="hover:bg-gray-50/60 transition-colors"> <tr v-for="u in pagedUsers" :key="u.id" class="hover:bg-gray-50/60 transition-colors">
<td class="px-5 py-4 text-gray-400 font-mono text-xs whitespace-nowrap">#{{ u.id }}</td> <td class="px-5 py-4 text-gray-400 font-mono text-xs whitespace-nowrap sticky left-0 bg-white z-10 border-r border-gray-100">#{{ u.id }}</td>
<td class="px-5 py-4 font-semibold text-black whitespace-nowrap">{{ u.username }}</td> <td class="px-5 py-4 font-semibold text-black whitespace-nowrap">{{ u.username }}</td>
<td class="px-5 py-4 text-gray-600">{{ u.email || '—' }}</td> <td class="px-5 py-4 text-gray-600">{{ u.email || '—' }}</td>
<td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ u.phone || '—' }}</td> <td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ u.phone || '—' }}</td>
@@ -258,6 +259,64 @@ const formatDate = (raw?: string) => {
</div> </div>
</div> </div>
<!-- 移动端卡片(<md) -->
<div class="md:hidden space-y-3">
<div
v-for="u in pagedUsers"
:key="u.id"
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4"
>
<div class="flex items-center justify-between gap-3">
<div class="flex items-center gap-3 min-w-0">
<div
class="w-10 h-10 rounded-full bg-black text-white flex items-center justify-center font-bold flex-shrink-0"
>
{{ (u.username || '?').charAt(0).toUpperCase() }}
</div>
<div class="min-w-0">
<p class="font-semibold text-black truncate">{{ u.username }}</p>
<p class="text-xs text-gray-400 font-mono">#{{ u.id }}</p>
</div>
</div>
<AdminBadge :tone="u.role === 'admin' ? 'black' : 'gray'" class="flex-shrink-0">
<Icon v-if="u.role === 'admin'" name="ph:crown-simple" class="w-3 h-3" />
{{ u.role === 'admin' ? '管理员' : '用户' }}
</AdminBadge>
</div>
<dl class="mt-3 space-y-1.5 text-sm">
<div class="flex justify-between gap-3">
<dt class="text-gray-400 flex-shrink-0">邮箱</dt>
<dd class="text-gray-700 text-right break-all">{{ u.email || '—' }}</dd>
</div>
<div class="flex justify-between gap-3">
<dt class="text-gray-400 flex-shrink-0">手机号</dt>
<dd class="text-gray-700 text-right">{{ u.phone || '—' }}</dd>
</div>
<div class="flex justify-between gap-3">
<dt class="text-gray-400 flex-shrink-0">注册时间</dt>
<dd class="text-gray-700 text-right">{{ formatDate(u.createdAt) }}</dd>
</div>
</dl>
<div class="mt-4 flex flex-wrap items-center gap-2">
<template v-if="u.id !== meId">
<AdminButton
size="sm"
class="flex-1 min-h-10"
:variant="u.role === 'admin' ? 'secondary' : 'primary'"
:loading="togglingId === u.id"
@click="toggleRole(u)"
>
{{ u.role === 'admin' ? '设为用户' : '设为管理员' }}
</AdminButton>
<AdminButton size="sm" variant="danger" class="min-h-10" @click="askDelete(u)">
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
</AdminButton>
</template>
<AdminBadge v-else tone="gray">当前账号</AdminBadge>
</div>
</div>
</div>
<div class="mt-4"> <div class="mt-4">
<AdminPagination :total="filteredUsers.length" :page="page" :page-size="pageSize" @page="changePage" /> <AdminPagination :total="filteredUsers.length" :page="page" :page-size="pageSize" @page="changePage" />
</div> </div>
+18 -14
View File
@@ -339,7 +339,7 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
<button <button
v-if="keyword" v-if="keyword"
@click="keyword = ''" @click="keyword = ''"
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center" class="absolute right-2.5 top-1/2 -translate-y-1/2 w-6 h-6 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
aria-label="清空筛选" aria-label="清空筛选"
> >
<Icon name="ph:x" class="w-3.5 h-3.5" /> <Icon name="ph:x" class="w-3.5 h-3.5" />
@@ -458,10 +458,10 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
</td> </td>
<td class="px-5 py-4"> <td class="px-5 py-4">
<div class="flex items-center justify-end gap-2"> <div class="flex items-center justify-end gap-2">
<AdminButton size="sm" variant="secondary" @click="openEdit(w)"> <AdminButton size="sm" variant="secondary" class="min-h-10" @click="openEdit(w)">
<Icon name="ph:pencil-simple" class="w-3.5 h-3.5" /> 编辑 <Icon name="ph:pencil-simple" class="w-3.5 h-3.5" /> 编辑
</AdminButton> </AdminButton>
<AdminButton size="sm" variant="danger" @click="askDelete(w)"> <AdminButton size="sm" variant="danger" class="min-h-10" @click="askDelete(w)">
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除 <Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
</AdminButton> </AdminButton>
</div> </div>
@@ -518,7 +518,7 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
<!-- 标题与简介 --> <!-- 标题与简介 -->
<AdminCard title="标题与简介"> <AdminCard title="标题与简介">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5"> <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<div class="space-y-4"> <div class="space-y-4">
<AdminInput v-model="form.titleZh" label="中文标题" required /> <AdminInput v-model="form.titleZh" label="中文标题" required />
<AdminTextarea v-model="form.descriptionZh" label="中文简介" :rows="3" /> <AdminTextarea v-model="form.descriptionZh" label="中文简介" :rows="3" />
@@ -533,7 +533,7 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
<!-- 项目详情(中英) --> <!-- 项目详情(中英) -->
<AdminCard title="项目详情(中英各一组)"> <AdminCard title="项目详情(中英各一组)">
<div class="space-y-6"> <div class="space-y-6">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5"> <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<div class="space-y-4"> <div class="space-y-4">
<AdminTextarea v-model="form.overviewZh" label="中文概述(Overview)" :rows="4" /> <AdminTextarea v-model="form.overviewZh" label="中文概述(Overview)" :rows="4" />
<AdminTextarea v-model="form.challengeZh" label="中文挑战(Challenge)" :rows="3" /> <AdminTextarea v-model="form.challengeZh" label="中文挑战(Challenge)" :rows="3" />
@@ -546,7 +546,7 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
</div> </div>
</div> </div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5"> <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<AdminInput v-model="form.clientZh" label="中文客户(Client)" /> <AdminInput v-model="form.clientZh" label="中文客户(Client)" />
<AdminInput v-model="form.clientEn" label="English Client" /> <AdminInput v-model="form.clientEn" label="English Client" />
<AdminInput v-model="form.durationZh" label="中文周期(Duration)" placeholder="如 3 个月" /> <AdminInput v-model="form.durationZh" label="中文周期(Duration)" placeholder="如 3 个月" />
@@ -572,24 +572,25 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
<div <div
v-for="(url, i) in form.gallery" v-for="(url, i) in form.gallery"
:key="i" :key="i"
class="flex items-center gap-3 border border-gray-200 rounded-xl bg-white p-3" class="flex flex-col sm:flex-row sm:items-center gap-3 border border-gray-200 rounded-xl bg-white p-3"
> >
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
<input <input
v-model="form.gallery[i]" v-model="form.gallery[i]"
type="text" type="text"
placeholder="图片 URL(本地 /uploads/... 或 https://...)" placeholder="图片 URL(本地 /uploads/... 或 https://...)"
class="w-full px-3 py-2 rounded-lg border border-gray-200 bg-gray-50 text-sm outline-none transition-all focus:border-black focus:bg-white" class="w-full px-3 py-2.5 rounded-lg border border-gray-200 bg-gray-50 text-sm outline-none transition-all focus:border-black focus:bg-white"
/> />
<div v-if="url" class="mt-2"> <div v-if="url" class="mt-2">
<img :src="url" alt="图集预览" class="h-24 w-auto max-w-full rounded-lg border border-gray-100 object-cover" /> <img :src="url" alt="图集预览" class="h-24 w-auto max-w-full rounded-lg border border-gray-100 object-cover" />
</div> </div>
</div> </div>
<div class="flex items-center gap-2 sm:flex-shrink-0">
<button <button
type="button" type="button"
:disabled="galleryUploading && uploadingIndex === i" :disabled="galleryUploading && uploadingIndex === i"
@click="pickGalleryFile(i)" @click="pickGalleryFile(i)"
class="flex items-center gap-1.5 px-3 py-2 rounded-lg bg-black text-white text-xs font-semibold hover:bg-gray-800 transition-colors disabled:opacity-60 flex-shrink-0" class="flex-1 sm:flex-none flex items-center justify-center gap-1.5 px-3 py-2.5 min-h-10 rounded-lg bg-black text-white text-xs font-semibold hover:bg-gray-800 transition-colors disabled:opacity-60"
> >
<Icon <Icon
:name="galleryUploading && uploadingIndex === i ? 'ph:circle-notch' : 'ph:upload-simple'" :name="galleryUploading && uploadingIndex === i ? 'ph:circle-notch' : 'ph:upload-simple'"
@@ -600,12 +601,13 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
<button <button
type="button" type="button"
@click="removeGalleryRow(i)" @click="removeGalleryRow(i)"
class="w-8 h-8 rounded-lg hover:bg-red-50 text-gray-400 hover:text-red-600 flex items-center justify-center transition-colors flex-shrink-0" class="w-10 h-10 rounded-lg hover:bg-red-50 text-gray-400 hover:text-red-600 flex items-center justify-center transition-colors flex-shrink-0"
aria-label="删除该图" aria-label="删除该图"
> >
<Icon name="ph:trash" class="w-4 h-4" /> <Icon name="ph:trash" class="w-4 h-4" />
</button> </button>
</div> </div>
</div>
<p v-if="galleryError" class="text-xs text-red-600">{{ galleryError }}</p> <p v-if="galleryError" class="text-xs text-red-600">{{ galleryError }}</p>
</div> </div>
<input ref="galleryFileInput" type="file" accept="image/*" class="hidden" @change="onGalleryFile" /> <input ref="galleryFileInput" type="file" accept="image/*" class="hidden" @change="onGalleryFile" />
@@ -613,14 +615,16 @@ const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
</AdminCard> </AdminCard>
<!-- 提交 --> <!-- 提交 -->
<div class="flex items-center justify-end gap-3"> <div class="flex flex-col sm:flex-row sm:items-center sm:justify-end gap-3">
<p v-if="formError" class="mr-auto text-sm text-red-600">{{ formError }}</p> <p v-if="formError" class="text-sm text-red-600 sm:mr-auto">{{ formError }}</p>
<AdminButton variant="secondary" @click="backToList">取消</AdminButton> <div class="flex items-center gap-3 w-full sm:w-auto sm:justify-end">
<AdminButton :loading="saving" @click="save"> <AdminButton class="flex-1 sm:flex-none" variant="secondary" @click="backToList">取消</AdminButton>
<AdminButton class="flex-1 sm:flex-none" :loading="saving" @click="save">
{{ saving ? '保存中…' : editingId != null ? '保存修改' : '创建作品' }} {{ saving ? '保存中…' : editingId != null ? '保存修改' : '创建作品' }}
</AdminButton> </AdminButton>
</div> </div>
</div> </div>
</div>
</template> </template>
<!-- 删除确认 --> <!-- 删除确认 -->