1 Commits

4 changed files with 127 additions and 394 deletions
+49 -190
View File
@@ -3,15 +3,12 @@ import { onBeforeUnmount, onMounted, ref, computed, watch } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import gsap from 'gsap' import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { useAppStore } from '~/stores/app' import { useAppStore } from '~/stores/app'
import { useUserStore } from '~/stores/user' import { useUserStore } from '~/stores/user'
import { useAuthModalStore } from '~/stores/authModal' import { useAuthModalStore } from '~/stores/authModal'
import AppLogo from '~/components/common/AppLogo.vue' import AppLogo from '~/components/common/AppLogo.vue'
import LoginModal from '~/components/common/LoginModal.vue' import LoginModal from '~/components/common/LoginModal.vue'
gsap.registerPlugin(ScrollTrigger)
const { t, locale, setLocale } = useI18n() const { t, locale, setLocale } = useI18n()
const route = useRoute() const route = useRoute()
const appStore = useAppStore() const appStore = useAppStore()
@@ -34,97 +31,70 @@ const navItems = computed<Array<{ name: string, path: string }>>(() => [
]) ])
const topHeaderRef = ref<HTMLElement | null>(null) const topHeaderRef = ref<HTMLElement | null>(null)
const bottomHeaderRef = ref<HTMLElement | null>(null)
const mobileMenuRef = ref<HTMLElement | null>(null) const mobileMenuRef = ref<HTMLElement | null>(null)
const isMobileMenuOpen = ref(false) const isMobileMenuOpen = ref(false)
const isUserMenuOpen = ref(false) const isUserMenuOpen = ref(false)
let topHeaderTween: gsap.core.Tween | null = null
let bottomHeaderScrollTrigger: ReturnType<typeof ScrollTrigger.create> | null = null // 滚动后为顶部导航加毛玻璃背景(内容不再与页面文字叠压)
let isBottomHeaderVisible = false const isScrolled = ref(false)
let fallbackTimer: ReturnType<typeof setTimeout> | null = null const onPageScroll = () => {
const y = window.scrollY || window.pageYOffset || 0
isScrolled.value = y > 20
}
let scrollPending = false
const scheduleScrollCheck = () => {
if (scrollPending) return
scrollPending = true
requestAnimationFrame(() => {
scrollPending = false
onPageScroll()
})
}
// 语言切换 // 语言切换
const switchLocale = () => { const switchLocale = () => {
setLocale(locale.value === 'zh' ? 'en' : 'zh') setLocale(locale.value === 'zh' ? 'en' : 'zh')
} }
// 切换用户菜单
const toggleUserMenu = () => { const toggleUserMenu = () => {
isUserMenuOpen.value = !isUserMenuOpen.value isUserMenuOpen.value = !isUserMenuOpen.value
} }
// 关闭用户菜单
const closeUserMenu = () => { const closeUserMenu = () => {
isUserMenuOpen.value = false isUserMenuOpen.value = false
} }
// 处理登出
const handleLogout = () => { const handleLogout = () => {
userStore.logout() userStore.logout()
closeUserMenu() closeUserMenu()
} }
const setBottomHeaderVisible = (visible: boolean) => { // 供外部或延迟调用的入场动画方法
if (!bottomHeaderRef.value || isBottomHeaderVisible === visible) {
return
}
isBottomHeaderVisible = visible
gsap.to(bottomHeaderRef.value, {
yPercent: visible ? 0 : 150,
autoAlpha: visible ? 1 : 0,
duration: 0.45,
ease: 'power2.out',
overwrite: 'auto',
force3D: true,
})
}
// 定义一个供外部或延迟调用的入场动画方法
const playHeaderIntro = () => { const playHeaderIntro = () => {
if (!topHeaderRef.value) return if (!topHeaderRef.value) return
// 如果已经触发过,清理可能存在的保底定时器
if (fallbackTimer) { if (fallbackTimer) {
clearTimeout(fallbackTimer) clearTimeout(fallbackTimer)
fallbackTimer = null fallbackTimer = null
} }
gsap.fromTo(topHeaderRef.value, gsap.fromTo(topHeaderRef.value,
{ { y: '100vh', opacity: 0 },
y: '100vh',
opacity: 0 // 恢复初始透明度为0,让它在屏幕最底部时是隐形的
},
{ {
y: 0, y: 0,
opacity: 1, // 伴随飞入的过程逐渐完全显示 opacity: 1,
duration: 1.4, duration: 1.4,
ease: 'power4.out', ease: 'power4.out',
delay: 0, delay: 0,
overwrite: 'auto', overwrite: 'auto',
clearProps: 'transform', clearProps: 'transform',
onComplete: () => { onComplete: () => {
// 动画完成时,强制把 style 的 opacity 移除,防止被内联样式锁死
if (topHeaderRef.value) { if (topHeaderRef.value) {
topHeaderRef.value.style.opacity = '' topHeaderRef.value.style.opacity = ''
} }
// 进场动画完毕后,再将滚动消失动画挂载到 ScrollTrigger
if (topHeaderTween) {
topHeaderTween.scrollTrigger?.kill()
ScrollTrigger.create({
animation: topHeaderTween,
start: 0,
end: 200,
scrub: true,
})
ScrollTrigger.refresh()
}
} }
}) })
} }
// 监听自定义事件,当首页的 Hero 动画完成或到达特定阶段时触发导航栏入场
const handleHeroReady = () => { const handleHeroReady = () => {
playHeaderIntro() playHeaderIntro()
} }
@@ -146,20 +116,8 @@ const hideTopHeader = () => {
const showTopHeaderInstant = () => { const showTopHeaderInstant = () => {
if (!topHeaderRef.value) return if (!topHeaderRef.value) return
gsap.set(topHeaderRef.value, { y: 0, opacity: 1 }) gsap.set(topHeaderRef.value, { y: 0, opacity: 1 })
topHeaderRef.value.style.opacity = '' topHeaderRef.value.style.opacity = ''
if (topHeaderTween) {
topHeaderTween.scrollTrigger?.kill()
ScrollTrigger.create({
animation: topHeaderTween,
start: 0,
end: 200,
scrub: true,
})
ScrollTrigger.refresh()
}
} }
// 切换移动端菜单 // 切换移动端菜单
@@ -169,24 +127,20 @@ const toggleMobileMenu = () => {
if (!mobileMenuRef.value) return if (!mobileMenuRef.value) return
if (isMobileMenuOpen.value) { if (isMobileMenuOpen.value) {
// 打开菜单
gsap.set(mobileMenuRef.value, { display: 'flex' }) gsap.set(mobileMenuRef.value, { display: 'flex' })
gsap.fromTo(mobileMenuRef.value, gsap.fromTo(mobileMenuRef.value,
{ opacity: 0, backdropFilter: 'blur(0px)' }, { opacity: 0, backdropFilter: 'blur(0px)' },
{ opacity: 1, backdropFilter: 'blur(12px)', duration: 0.3, ease: 'power2.out' } { opacity: 1, backdropFilter: 'blur(12px)', duration: 0.3, ease: 'power2.out' }
) )
// 菜单项依次出现
const menuItems = gsap.utils.toArray<HTMLElement>('.mobile-menu-item', mobileMenuRef.value) const menuItems = gsap.utils.toArray<HTMLElement>('.mobile-menu-item', mobileMenuRef.value)
gsap.fromTo(menuItems, gsap.fromTo(menuItems,
{ y: 30, opacity: 0 }, { y: 30, opacity: 0 },
{ y: 0, opacity: 1, duration: 0.4, stagger: 0.05, ease: 'power3.out', delay: 0.1 } { y: 0, opacity: 1, duration: 0.4, stagger: 0.05, ease: 'power3.out', delay: 0.1 }
) )
// 禁止背景滚动
document.body.style.overflow = 'hidden' document.body.style.overflow = 'hidden'
} else { } else {
// 关闭菜单
gsap.to(mobileMenuRef.value, gsap.to(mobileMenuRef.value,
{ {
opacity: 0, opacity: 0,
@@ -201,55 +155,22 @@ const toggleMobileMenu = () => {
} }
) )
// 恢复滚动
document.body.style.overflow = '' document.body.style.overflow = ''
} }
} }
// 关闭移动端菜单
const closeMobileMenu = () => { const closeMobileMenu = () => {
if (isMobileMenuOpen.value) { if (isMobileMenuOpen.value) {
toggleMobileMenu() toggleMobileMenu()
} }
} }
let fallbackTimer: ReturnType<typeof setTimeout> | null = null
onMounted(() => { onMounted(() => {
// 顶部导航在页面刚开始滚动的前 200px 内逐渐上移并隐藏。 scheduleScrollCheck()
topHeaderTween = gsap.to(topHeaderRef.value, { window.addEventListener('scroll', scheduleScrollCheck, { passive: true })
yPercent: -140, window.addEventListener('resize', scheduleScrollCheck, { passive: true })
autoAlpha: 0,
ease: 'none',
paused: true, // 初始不执行,等进场动画完毕再绑定到 ScrollTrigger
})
// 底部导航默认藏在视口下方,只有滚动到深处并向上滚时才出现。
gsap.set(bottomHeaderRef.value, {
xPercent: -50,
yPercent: 150,
autoAlpha: 0,
force3D: true
})
bottomHeaderScrollTrigger = ScrollTrigger.create({
start: 0,
end: 'max',
onUpdate: (self) => {
const scrollY = self.scroll()
// 深度超过 1000px 后向上滚,显示底部导航。
if (scrollY > 1000 && self.direction === -1) {
setBottomHeaderVisible(true)
return
}
// 回到 1000px 以内,或继续向下滚时,底部导航收回。
if (scrollY <= 1000 || self.direction === 1) {
setBottomHeaderVisible(false)
}
},
})
ScrollTrigger.refresh()
if (!appStore.isAppLoading && route.path !== '/') { if (!appStore.isAppLoading && route.path !== '/') {
showTopHeaderInstant() showTopHeaderInstant()
@@ -263,9 +184,7 @@ watch([() => appStore.isAppLoading, () => route.path], ([isLoading, path]) => {
if (path === '/') { if (path === '/') {
hideTopHeader() hideTopHeader()
window.addEventListener('hero-intro-done', handleHeroReady, { once: true }) window.addEventListener('hero-intro-done', handleHeroReady, { once: true })
fallbackTimer = setTimeout(() => { fallbackTimer = setTimeout(() => {
window.removeEventListener('hero-intro-done', handleHeroReady) window.removeEventListener('hero-intro-done', handleHeroReady)
playHeaderIntro() playHeaderIntro()
@@ -277,23 +196,17 @@ watch([() => appStore.isAppLoading, () => route.path], ([isLoading, path]) => {
}, { immediate: true }) }, { immediate: true })
onBeforeUnmount(() => { onBeforeUnmount(() => {
cleanupHeroReadyHook() cleanupHeroReadyHook()
topHeaderTween?.scrollTrigger?.kill() window.removeEventListener('scroll', scheduleScrollCheck)
topHeaderTween?.kill() window.removeEventListener('resize', scheduleScrollCheck)
bottomHeaderScrollTrigger?.kill() if (topHeaderRef.value) {
topHeaderTween = null gsap.killTweensOf(topHeaderRef.value)
bottomHeaderScrollTrigger = null }
isBottomHeaderVisible = false if (isMobileMenuOpen.value) {
if (topHeaderRef.value && bottomHeaderRef.value) { document.body.style.overflow = ''
gsap.killTweensOf([topHeaderRef.value, bottomHeaderRef.value]) }
} })
// 清理移动端菜单
if (isMobileMenuOpen.value) {
document.body.style.overflow = ''
}
})
// 监听路由变化,关闭移动端菜单
watch(() => route.path, () => { watch(() => route.path, () => {
closeMobileMenu() closeMobileMenu()
closeUserMenu() closeUserMenu()
@@ -319,9 +232,12 @@ if (typeof window !== 'undefined') {
</script> </script>
<template> <template>
<header ref="topHeaderRef" <header
class="site-header-top fixed left-0 right-0 top-0 z-50 mx-auto flex h-[100px] w-page-container max-w-[calc(100%-2rem)] items-center justify-between px-4 py-5" ref="topHeaderRef"
style="opacity: 0; transform: translateY(100vh);"> class="site-header-top fixed left-0 right-0 top-0 z-50 mx-auto flex h-[100px] w-page-container max-w-[calc(100%-2rem)] items-center justify-between px-4 py-5 transition-colors duration-300"
:class="isScrolled ? 'scrolled' : ''"
style="opacity: 0; transform: translateY(100vh);"
>
<!-- 左侧:Logo 和 标题 --> <!-- 左侧:Logo 和 标题 -->
<AppLogo /> <AppLogo />
@@ -365,7 +281,7 @@ if (typeof window !== 'undefined') {
class="flex items-center gap-3 px-4 py-2 rounded-full hover:bg-gray-100 transition-all duration-300" class="flex items-center gap-3 px-4 py-2 rounded-full hover:bg-gray-100 transition-all duration-300"
> >
<img <img
:src="userStore.user?.avatar" :src="userStore.user?.avatar ?? ''"
:alt="userStore.user?.username" :alt="userStore.user?.username"
class="w-9 h-9 rounded-full object-cover border-2 border-gray-200" class="w-9 h-9 rounded-full object-cover border-2 border-gray-200"
/> />
@@ -445,7 +361,6 @@ if (typeof window !== 'undefined') {
<!-- 移动端登录/用户信息 --> <!-- 移动端登录/用户信息 -->
<div class="mobile-menu-item mt-8 pt-8 border-t border-gray-200 w-full flex flex-col items-center gap-4"> <div class="mobile-menu-item mt-8 pt-8 border-t border-gray-200 w-full flex flex-col items-center gap-4">
<!-- 语言切换 -->
<button <button
@click="switchLocale" @click="switchLocale"
class="px-8 py-3 rounded-full border-2 border-black text-black text-base font-semibold hover:bg-gray-100 transition-all duration-300" class="px-8 py-3 rounded-full border-2 border-black text-black text-base font-semibold hover:bg-gray-100 transition-all duration-300"
@@ -453,7 +368,6 @@ if (typeof window !== 'undefined') {
{{ locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese') }} {{ locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese') }}
</button> </button>
<!-- 未登录 -->
<button <button
v-if="!userStore.isAuthenticated" v-if="!userStore.isAuthenticated"
@click="authModal.openLogin()" @click="authModal.openLogin()"
@@ -462,11 +376,10 @@ if (typeof window !== 'undefined') {
{{ t('auth.login') }} {{ t('auth.login') }}
</button> </button>
<!-- 已登录 -->
<div v-else class="flex flex-col items-center gap-4"> <div v-else class="flex flex-col items-center gap-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<img <img
:src="userStore.user?.avatar" :src="userStore.user?.avatar ?? ''"
:alt="userStore.user?.username" :alt="userStore.user?.username"
class="w-12 h-12 rounded-full object-cover border-2 border-gray-200" class="w-12 h-12 rounded-full object-cover border-2 border-gray-200"
/> />
@@ -489,70 +402,16 @@ if (typeof window !== 'undefined') {
<!-- 登录弹窗(由 authModal store 控制开关) --> <!-- 登录弹窗(由 authModal store 控制开关) -->
<LoginModal /> <LoginModal />
<header ref="bottomHeaderRef" class="site-header-bottom z-50 bg-white/80 backdrop-blur-md">
<!-- 左侧菜单 (前两个菜单项) -->
<nav class="flex items-center justify-evenly md:justify-end gap-3 md:gap-4 w-full">
<NuxtLink v-for="item in navItems.slice(0, 2)" :key="'bottom-' + item.name" :to="item.path"
class="group flex items-center font-semibold tracking-[-0.7px] text-black text-sm md:text-base whitespace-nowrap md:overflow-hidden"
style="justify-content: flex-start; position: relative;">
<div
class="flex items-center transition-transform duration-300 md:group-hover:translate-x-0 md:-translate-x-[18px] md:pr-[18px]">
<span class="hidden md:block mr-1 md:mr-2 h-1.5 w-1.5 md:h-2.5 md:w-2.5 rounded-full bg-black shrink-0"></span>
<span>{{ item.name }}</span>
</div>
</NuxtLink>
</nav>
<!-- 中间 Logo (组件内部自带跳转和动画) -->
<div class="flex items-center justify-center px-1 md:px-6">
<AppLogo compact click-action="top" />
</div>
<!-- 右侧菜单 (去除左侧两个和最后contact菜单后的所有菜单) -->
<nav class="flex items-center justify-evenly md:justify-start gap-3 md:gap-4 w-full">
<NuxtLink v-for="item in navItems.slice(2, navItems.length - 1)" :key="'bottom-' + item.name" :to="item.path"
class="group flex items-center font-semibold tracking-[-0.7px] text-black text-sm md:text-base whitespace-nowrap md:overflow-hidden"
style="justify-content: flex-start; position: relative;">
<div
class="flex items-center transition-transform duration-300 md:group-hover:translate-x-0 md:-translate-x-[18px] md:pr-[18px]">
<span class="hidden md:block mr-1 md:mr-2 h-1.5 w-1.5 md:h-2.5 md:w-2.5 rounded-full bg-black shrink-0"></span>
<span>{{ item.name }}</span>
</div>
</NuxtLink>
</nav>
</header>
</template> </template>
<style scoped> <style scoped>
.site-header-bottom { .site-header-top.scrolled {
border: 1px solid #ffffff47; background: rgba(255, 255, 255, 0.72);
border-radius: 12px; -webkit-backdrop-filter: saturate(180%) blur(16px);
grid-template-rows: auto; backdrop-filter: saturate(180%) blur(16px);
/* 移动端恢复三列,靠 flex 让菜单均匀铺开 */ border-radius: 0 0 18px 18px;
grid-template-columns: 1fr auto 1fr; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
grid-auto-columns: 1fr; border-bottom: 1px solid rgba(0, 0, 0, 0.06);
place-items: center;
width: calc(100% - 1rem);
max-width: 570px;
padding: 10px 10px;
display: grid;
position: fixed;
left: 50%;
bottom: 15px;
overflow: hidden;
visibility: hidden;
opacity: 0;
box-shadow: 0 -1px #0000001f, 0 12px 30px #0000001a, inset 0 1px #ffffff96;
}
@media (min-width: 768px) {
.site-header-bottom {
grid-template-columns: auto minmax(50px, auto) auto;
gap: 0;
width: fit-content;
padding: 15px 20px;
}
} }
/* 用户下拉菜单动画 */ /* 用户下拉菜单动画 */
+67 -93
View File
@@ -1,10 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
/** /**
* 个人中心(重新设计)—— 对齐站点黑白编辑风:极简、大排版、充足留白。 * 个人中心 —— 用站点一以贯之的黑白编辑风:克制、留白、无冗余。
* - 资料区:头像 + 大号姓名 + 邮箱 + 角色/加入时间 + 三项统计(细分隔线) * - 头部:头像 + 昵称 + 邮箱 + 加入时间(不重复展示收藏/评论数、不展示角色徽章)
* - 导航:下划线页签 * - 页签:个人资料 / 我的收藏 / 我的评论(计数只在页签出现一次)
* - profile:资料编辑(昵称/头像/邮箱,改后同步回统一认证中心) * - profile:仅三类可编辑信息——头像/昵称/邮箱,改后同步回统一认证中心
* - favorites:作品封面网格;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'
@@ -61,7 +60,6 @@ const saveProfile = async () => {
const result = await userStore.updateProfile({ const result = await userStore.updateProfile({
username: profileForm.username, username: profileForm.username,
email: profileEmail.value, email: profileEmail.value,
avatar: profileAvatar.value || undefined,
}) })
profileSaving.value = false profileSaving.value = false
profileMsg.value = result.success profileMsg.value = result.success
@@ -69,7 +67,7 @@ const saveProfile = async () => {
: { ok: false, text: apiError({ data: { code: result.code } }) } : { ok: false, text: apiError({ data: { code: result.code } }) }
} }
/* 头像选择并上传,成功后写入表单待保存 */ /* 头像:选择后上传(直连统一认证中心),即时生效并落库 */
const profileFileInput = ref<HTMLInputElement | null>(null) const profileFileInput = ref<HTMLInputElement | null>(null)
const triggerAvatarPick = () => profileFileInput.value?.click() const triggerAvatarPick = () => profileFileInput.value?.click()
const onAvatarPick = async (event: Event) => { const onAvatarPick = async (event: Event) => {
@@ -88,6 +86,7 @@ const onAvatarPick = async (event: Event) => {
fd.append('file', file) fd.append('file', file)
const data = await $fetch<{ url: string }>('/api/auth/avatar', { method: 'POST', body: fd }) const data = await $fetch<{ url: string }>('/api/auth/avatar', { method: 'POST', body: fd })
profileAvatar.value = data.url profileAvatar.value = data.url
if (userStore.user) userStore.user.avatar = data.url
profileMsg.value = { ok: true, text: t('account.avatar.success') } profileMsg.value = { ok: true, text: t('account.avatar.success') }
} catch (err) { } catch (err) {
profileMsg.value = { ok: false, text: apiError({ data: { code: (err as any)?.data?.code ?? 'VALIDATION_ERROR' } }) } profileMsg.value = { ok: false, text: apiError({ data: { code: (err as any)?.data?.code ?? 'VALIDATION_ERROR' } }) }
@@ -179,57 +178,29 @@ onBeforeUnmount(() => ctx?.revert())
</section> </section>
<template v-else> <template v-else>
<!-- 资料区(黑白极简) --> <!-- 身份信息 -->
<header data-animate class="rounded-3xl border border-gray-100 bg-white shadow-sm"> <header data-animate class="flex items-center gap-6 md:gap-8 border-b border-gray-200 pb-10">
<div class="px-6 py-8 md:px-10 md:py-10"> <img
<div class="flex flex-col md:flex-row md:items-start gap-6 md:gap-8"> :src="userStore.avatar"
<img :alt="userStore.user?.username"
:src="userStore.avatar" class="w-20 h-20 md:w-24 md:h-24 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0"
:alt="userStore.user?.username" />
class="w-20 h-20 md:w-24 md:h-24 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0" <div class="min-w-0">
/> <h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black truncate">{{ userStore.user?.username }}</h1>
<div class="flex-1 min-w-0"> <p class="mt-2 text-gray-500 truncate">{{ userStore.user?.email }}</p>
<div class="flex items-center gap-3 flex-wrap"> <p class="mt-1.5 text-sm text-gray-400">{{ t('account.joinedAt') }} · {{ formatDate(userStore.user?.createdAt) }}</p>
<h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black">{{ userStore.user?.username }}</h1>
<span class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-gray-100 text-gray-600">
<Icon name="ph:user" class="w-3 h-3" />
{{ t('account.roleUser') }}
</span>
</div>
<p class="mt-2 text-gray-500">{{ userStore.user?.email }}</p>
<p class="mt-1 text-sm text-gray-400">
{{ t('account.joinedAt') }} · {{ formatDate(userStore.user?.createdAt) }}
</p>
</div>
</div>
<!-- 统计(细分隔线) -->
<div class="mt-8 grid grid-cols-3 divide-x divide-gray-200 border-t border-gray-100 pt-6">
<div class="text-center">
<p class="text-2xl md:text-3xl font-bold text-black leading-none">{{ favorites.length }}</p>
<p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statFavorites') }}</p>
</div>
<div class="text-center">
<p class="text-2xl md:text-3xl font-bold text-black leading-none">{{ myComments.length }}</p>
<p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statComments') }}</p>
</div>
<div class="text-center">
<p class="text-lg md:text-2xl font-bold text-black leading-none">{{ formatDate(userStore.user?.createdAt, true) }}</p>
<p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statJoined') }}</p>
</div>
</div>
</div> </div>
</header> </header>
<!-- 页签(下划线) --> <!-- 页签 -->
<nav data-animate class="mt-10 border-b border-gray-200"> <nav data-animate class="mt-6 border-b border-gray-200">
<div class="flex gap-8 overflow-x-auto"> <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 py-3 text-sm font-semibold border-b-2 -mb-px whitespace-nowrap transition-colors" class="flex items-center gap-2 py-3.5 text-sm font-semibold border-b-2 -mb-px whitespace-nowrap transition-colors"
:class="activeTab === tab.key ? 'border-black text-black' : 'border-transparent text-gray-400 hover:text-black'" :class="activeTab === tab.key ? 'border-black text-black' : 'border-transparent text-gray-400 hover:text-black'"
> >
{{ tab.label }} {{ tab.label }}
@@ -241,55 +212,58 @@ onBeforeUnmount(() => ctx?.revert())
<!-- 内容 --> <!-- 内容 -->
<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="max-w-2xl mx-auto"> <section v-if="activeTab === 'profile'" key="profile" class="max-w-2xl mx-auto">
<div class="rounded-3xl border border-gray-100 bg-white shadow-sm overflow-hidden divide-y divide-gray-100"> <div class="rounded-3xl border border-gray-100 bg-white shadow-sm px-6 md:px-8 py-8">
<!-- 基本信息 -->
<div class="px-6 md:px-8 py-7">
<h3 class="text-lg font-bold text-black">{{ t('account.profile') }}</h3>
<p class="text-sm text-gray-400 mt-0.5">个人基本信息与头像</p>
<div class="mt-6 flex items-center gap-6"> <!-- 头像 -->
<img :src="profileAvatar || userStore.avatar" :alt="userStore.user?.username" <div class="flex items-center gap-5">
class="w-20 h-20 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0" /> <img
<div> :src="profileAvatar || userStore.avatar"
<button type="button" @click="triggerAvatarPick" :disabled="avatarUploading" :alt="userStore.user?.username"
class="inline-flex items-center gap-2 px-4 py-2 rounded-full border border-gray-200 text-sm font-semibold hover:border-black hover:text-black transition-colors disabled:opacity-50"> class="w-16 h-16 md:w-20 md:h-20 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0"
<Icon v-if="avatarUploading" name="ph:circle-notch" class="w-4 h-4 animate-spin" /> />
<Icon v-else name="ph:user-circle" class="w-4 h-4" /> <div>
{{ avatarUploading ? t('account.avatar.uploading') : t('account.avatar.change') }} <button
</button> type="button"
<input ref="profileFileInput" type="file" accept="image/*" class="hidden" @change="onAvatarPick" /> @click="triggerAvatarPick"
<p class="text-xs text-gray-400 mt-2">{{ t('account.avatarHint') }}</p> :disabled="avatarUploading"
</div> class="inline-flex items-center gap-2 px-4 py-2 rounded-full border border-gray-200 text-sm font-semibold hover:border-black hover:text-black transition-colors disabled:opacity-50"
</div> >
<Icon v-if="avatarUploading" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
<div class="mt-7 space-y-5"> <Icon v-else name="ph:user-circle" class="w-4 h-4" />
<div> {{ avatarUploading ? t('account.avatar.uploading') : t('account.avatar.change') }}
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.nickname') }}</label> </button>
<input v-model="profileForm.username" type="text" <input ref="profileFileInput" type="file" accept="image/*" class="hidden" @change="onAvatarPick" />
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" /> <p class="text-xs text-gray-400 mt-2 max-w-xs">{{ t('account.avatarHint') }}</p>
</div>
<div>
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.email') }}</label>
<input v-model="profileEmail" type="email"
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>
<p v-if="profileMsg" class="text-sm" :class="profileMsg.ok ? 'text-green-600' : 'text-red-600'">{{ profileMsg.text }}</p>
<div class="flex justify-end">
<button @click="saveProfile" :disabled="profileSaving"
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">
<Icon v-if="profileSaving" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
{{ profileSaving ? t('account.saving') : t('account.save') }}
</button>
</div>
</div> </div>
</div> </div>
<!-- 账号说明 --> <!-- 昵称 / 邮箱 -->
<div class="px-6 md:px-8 py-7 bg-gray-50/60"> <div class="mt-8 space-y-6 border-t border-gray-100 pt-8">
<h3 class="text-lg font-bold text-black">{{ t('account.ssoAccount') }}</h3> <div>
<p class="text-sm text-gray-500 mt-1 leading-relaxed">{{ t('account.ssoAccountHint') }}</p> <label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.nickname') }}</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>
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.email') }}</label>
<input v-model="profileEmail" type="email"
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>
<p v-if="profileMsg" class="text-sm" :class="profileMsg.ok ? 'text-green-600' : 'text-red-600'">{{ profileMsg.text }}</p>
<div class="flex justify-end pt-2">
<button
@click="saveProfile"
:disabled="profileSaving"
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"
>
<Icon v-if="profileSaving" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
{{ profileSaving ? t('account.saving') : t('account.save') }}
</button>
</div>
</div> </div>
</div> </div>
</section> </section>
+3 -53
View File
@@ -359,71 +359,21 @@
"profile": "Profile", "profile": "Profile",
"favorites": "Favorites", "favorites": "Favorites",
"comments": "My Comments", "comments": "My Comments",
"adminTitle": "Admin",
"username": "Username",
"nickname": "Nickname", "nickname": "Nickname",
"avatarHint": "Your avatar is synced to the unified identity provider. Supported: png/jpg/gif/webp/svg/avif, up to 8MB", "avatarHint": "Your avatar is synced to the unified identity provider. Supported: png/jpg/gif/webp/svg/avif, up to 8MB",
"email": "Email", "email": "Email",
"phone": "Phone",
"joinedAt": "Joined", "joinedAt": "Joined",
"role": "Role",
"roleAdmin": "Admin",
"roleUser": "User",
"save": "Save Changes", "save": "Save Changes",
"saving": "Saving...", "saving": "Saving...",
"saved": "Saved", "saved": "Saved",
"saveFailed": "Failed to save. Please try again.",
"ssoAccount": "Unified SSO Account",
"ssoAccountHint": "Changes to your nickname, avatar and email here are synced back to the unified identity provider (Casdoor) and stay consistent across all sites using it.",
"emptyFavorites": "No favorites yet. Go to the Work page to explore.",
"emptyComments": "No comments posted yet",
"admin": {
"contacts": "Contact Messages",
"subscribers": "Newsletter Subscribers",
"emptyContacts": "No contact messages",
"emptySubscribers": "No subscribers yet",
"name": "Name",
"email": "Email",
"subject": "Subject",
"message": "Message",
"date": "Date",
"delivered": "Delivered to inbox",
"notDelivered": "Not delivered (SMTP not configured)"
},
"adminEntry": "Admin Panel",
"changePassword": {
"title": "Change Password",
"currentPassword": "Current Password",
"newPassword": "New Password",
"confirmPassword": "Confirm New Password",
"submit": "Update Password",
"saving": "Updating...",
"success": "Password updated",
"failed": "Failed to update password",
"wrongPassword": "Current password is incorrect",
"tooShort": "New password must be at least 8 characters",
"mismatch": "Passwords do not match"
},
"deleteAccount": {
"title": "Delete Account",
"hint": "This cannot be undone. Your comments and favorites will be removed.",
"passwordPlaceholder": "Enter your password to confirm",
"confirmButton": "Delete",
"cancelButton": "Cancel",
"success": "Account deleted",
"wrongPassword": "Incorrect password",
"confirmText": "Delete your account permanently? This cannot be undone."
},
"statFavorites": "Favorites",
"statComments": "Comments",
"statJoined": "Joined",
"avatar": { "avatar": {
"change": "Change Avatar", "change": "Change Avatar",
"uploading": "Uploading...", "uploading": "Uploading...",
"remove": "Remove Avatar",
"error": "Failed to update avatar", "error": "Failed to update avatar",
"success": "Avatar updated" "success": "Avatar updated"
} },
"emptyFavorites": "No favorites yet. Go to the Work page to explore.",
"emptyComments": "No comments posted yet"
}, },
"comments": { "comments": {
"title": "Comments", "title": "Comments",
+4 -54
View File
@@ -359,71 +359,21 @@
"profile": "个人资料", "profile": "个人资料",
"favorites": "我的收藏", "favorites": "我的收藏",
"comments": "我的评论", "comments": "我的评论",
"adminTitle": "管理面板",
"username": "用户名",
"nickname": "昵称", "nickname": "昵称",
"avatarHint": "头像会同步到统一认证中心,支持 png/jpg/gif/webp/svg/avif,大小不超过 8MB", "avatarHint": "头像会同步到统一认证中心,支持 png/jpg/gif/webp/svg/avif,大小不超过 8MB",
"email": "邮箱", "email": "邮箱",
"phone": "手机号", "joinedAt": "加入时间",
"joinedAt": "注册时间",
"role": "角色",
"roleAdmin": "管理员",
"roleUser": "普通用户",
"save": "保存修改", "save": "保存修改",
"saving": "保存中...", "saving": "保存中...",
"saved": "已保存", "saved": "已保存",
"saveFailed": "保存失败,请重试",
"ssoAccount": "统一身份认证账号",
"ssoAccountHint": "昵称、头像与邮箱在此修改后会同步回统一身份认证中心(Casimir),在其他接入统一认证的站点也会保持一致。",
"emptyFavorites": "还没有收藏任何作品,去「作品」页看看吧",
"emptyComments": "还没有发表过评论",
"admin": {
"contacts": "联系消息",
"subscribers": "邮箱订阅",
"emptyContacts": "暂无联系消息",
"emptySubscribers": "暂无订阅用户",
"name": "姓名",
"email": "邮箱",
"subject": "主题",
"message": "留言内容",
"date": "时间",
"delivered": "已送达邮箱",
"notDelivered": "未送达(SMTP 未配置)"
},
"adminEntry": "进入后台管理",
"changePassword": {
"title": "修改密码",
"currentPassword": "当前密码",
"newPassword": "新密码",
"confirmPassword": "确认新密码",
"submit": "确认修改",
"saving": "提交中...",
"success": "密码已修改",
"failed": "修改失败,请重试",
"wrongPassword": "当前密码不正确",
"tooShort": "新密码至少需要 8 位",
"mismatch": "两次输入的新密码不一致"
},
"deleteAccount": {
"title": "删除账号",
"hint": "删除后无法恢复,将同时清除你的评论与收藏。",
"passwordPlaceholder": "输入当前密码确认",
"confirmButton": "确认删除",
"cancelButton": "取消",
"success": "账号已删除",
"wrongPassword": "密码不正确",
"confirmText": "确定要永久删除账号吗?此操作不可撤销。"
},
"statFavorites": "收藏",
"statComments": "评论",
"statJoined": "加入于",
"avatar": { "avatar": {
"change": "更换头像", "change": "更换头像",
"uploading": "上传中...", "uploading": "上传中...",
"remove": "移除头像",
"error": "头像更新失败", "error": "头像更新失败",
"success": "头像已更新" "success": "头像已更新"
} },
"emptyFavorites": "还没有收藏任何作品,去「作品」页看看吧",
"emptyComments": "还没有发表过评论"
}, },
"comments": { "comments": {
"title": "评论", "title": "评论",