gongxiangp2/app/page.tsx
chenpei 02df0b7ef4 perf: facets 服务端缓存 + loadMonths 查询优化 + 首页去重复卡片
- facets API 增加内存缓存(TTL 5 分钟,键=角色+部门+筛选参数,容量 200 条)
- loadMonths 从 findMany 全表扫描改为 groupBy 按月聚合(数据库侧完成)
- 首页移除下方白卡区块(与编号索引重复)+ 恢复 05-07 规划中板块行
2026-08-17 09:09:51 +08:00

331 lines
14 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 方向契约(用户裁定方向:Zen Minimal × Future Organic 融合 · 2026-08-15)
* THESIS: 看板首页是一张"编辑页"——白纸、黑字、发丝线、超大留白;七个板块排成一列
* 编号索引(作品集列表语言),悬停整行浮现;唯一的柔光来自一枚有机渐变光晕。
* 拒绝卡片阵列、拒绝重色块、拒绝装饰;安静得像一本品牌中心的白皮书。
* OWN-WORLD: 白 #fafafa/#fff、墨 #1a1c1d、正文灰 #6b7075、注脚灰 #86898e、发丝线 #e7e8ea、
* 柔粉色场(唯一彩色氛围)+ 微型大写字距标注、
* 黑实心按钮 8px 圆角、无阴影平面化;全部文字对比过 WCAG(≥4.5:1 / 大字 ≥3:1)。
* STORY: 打开即读:巨字「品牌中心」+ 一句矿脉定位;视线沿编号索引下移——
* 01 资产、02 组织、03 考核、04 过稿是活的(可点,行变黑);后续板块仍在生长。
* 四块已上线板块以克制的白卡提供入口;页脚是跟踪字距的微型注脚。
* FIRST VIEWPORT: 极简顶栏(logo+由壹点·品牌中心)→ 超大 600 字重「品牌中心」+ 定位语 →
* 右侧一枚柔粉渐变色场压角 → 下方七条发丝线分隔的编号索引行。
* FORM: 用户在 Stitch 自生成的候选 3(Zen Minimal)与 4(Future Organic)融合,
* 参考作品集文件夹两份 DESIGN.md(Monochrome/Studio Minimalist)裁定。
* FINISH: unreviewed and undocumented is unfinished; this build ends with the finish review, the verdict, and DESIGN.md
*/
'use client'
import { useEffect, useRef } from 'react'
import Link from 'next/link'
import { useRouter } from 'next/navigation'
import { useSession } from 'next-auth/react'
import gsap from 'gsap'
import { useGSAP } from '@gsap/react'
import MaterialsHeader from '@/components/board/MaterialsHeader'
import BrandFluidField from '@/components/board/BrandFluidField'
gsap.registerPlugin(useGSAP)
const ADMIN_ROLES = ['ADMIN', 'SYSTEM_ADMIN', 'DEPT_ADMIN']
function StatusDot({ tone }: { tone: 'live' | 'building' | 'planned' }) {
const tones = { live: 'bg-[#157a4b]', building: 'bg-[#6e79c8]', planned: 'bg-[#9aa0a8]' } as const
return <span aria-hidden="true" className={`inline-block h-[7px] w-[7px] shrink-0 rounded-full ${tones[tone]}`} />
}
const labelCls = 'text-[11px] uppercase tracking-[0.14em] text-[#86898e]'
const focusRing = 'focus:outline-none focus-visible:ring-2 focus-visible:ring-[#1a1c1d]/70 focus-visible:ring-offset-2 focus-visible:ring-offset-[#fafafa]'
/** 会话加载中的骨架行(防止管理员首帧闪灰) */
function SkeletonIndex() {
return (
<div className="border-t border-[#e7e8ea]">
{Array.from({ length: 7 }).map((_, i) => (
<div key={i} className="flex items-center gap-4 border-b border-[#e7e8ea] py-9 md:gap-8">
<div className="h-3 w-8 shrink-0 animate-pulse bg-[#eceef0]" />
<div className="min-w-0 flex-1 space-y-2.5">
<div className="h-5 w-44 animate-pulse bg-[#eceef0]" />
<div className="h-3 w-72 max-w-full animate-pulse bg-[#f2f3f5]" />
</div>
</div>
))}
</div>
)
}
export default function BoardHomePage() {
const { data: session, status } = useSession()
const router = useRouter()
const pageRef = useRef<HTMLDivElement>(null)
const sessionLoading = status === 'loading'
const sessionUser = session?.user as { role?: string } | undefined
const isAdmin = ADMIN_ROLES.includes(sessionUser?.role || '')
useEffect(() => {
if (status === 'unauthenticated') {
router.replace('/login')
}
}, [status, router])
const indexRows = [
{
no: '01',
title: '创意资产库',
en: 'Creative Assets',
tone: 'live' as const,
status: '运行中',
live: true,
href: '/materials',
desc: '素材浏览、上传、分享与下载——品牌中心的创意资产都在这里,全部功能照常使用。',
},
{
no: '02',
title: '组织管理',
en: 'People & Org',
tone: 'live' as const,
status: '已上线',
live: isAdmin,
href: '/organization',
desc: '人员主档以钉钉唯一值绑定 HR 花名册,组织树与在职状态每日 02:00 自动同步。',
},
{
no: '03',
title: '绩效考核',
en: 'Performance',
tone: 'live' as const,
status: '已上线',
live: true,
href: '/performance-survey',
desc: '个人考核、公共看板与调研管理——任务进度和结果在同一处收敛。',
},
{
no: '04',
title: '作品过稿看板',
en: 'Work Review',
tone: 'live' as const,
status: '已上线',
live: true,
href: '/work-review',
desc: '作品提交、版本迭代与评审意见——让创意协作从上传后继续推进。',
},
{
no: '05',
title: '中心仪表盘',
en: 'Dashboard',
tone: 'building' as const,
status: '建设中',
live: false,
desc: '将接入:核心指标 · 业务趋势 · 六品牌健康度 · 团队产能 · 风险预警',
},
{
no: '06',
title: '业务经营',
en: 'Operations',
tone: 'planned' as const,
status: '规划中',
live: false,
desc: '将包含:新品上新 · 品牌塑造 · 创意生产 · 业绩转化 · 项目协同',
},
{
no: '07',
title: '治理与设置',
en: 'Governance',
tone: 'planned' as const,
status: '规划中',
live: false,
desc: '将包含:权限角色 · 数据口径 · 编辑能力 · 通知机制',
},
]
useGSAP(() => {
if (sessionLoading || typeof window.matchMedia !== 'function') return
if (
!pageRef.current?.querySelector('[data-hero-title]') ||
!pageRef.current.querySelector('[data-row-line]') ||
!pageRef.current.querySelector('[data-row]') ||
!pageRef.current.querySelector('[data-foot]')
) {
return
}
const motion = gsap.matchMedia()
motion.add('(prefers-reduced-motion: no-preference)', () => {
const tl = gsap.timeline({ defaults: { ease: 'expo.out' } })
tl
// 主标题:对焦揭幕——虚焦+宽字距 → 聚焦收拢(重、慢,配 quint 级缓动)
.fromTo(
'[data-hero-title]',
{ filter: 'blur(16px)', opacity: 0, letterSpacing: '0.16em' },
{
filter: 'blur(0px)',
opacity: 1,
letterSpacing: '-0.03em',
duration: 1.15,
ease: 'power4.out',
clearProps: 'filter,opacity,letterSpacing',
},
)
// 定位语
.fromTo(
'[data-hero]',
{ y: 12, autoAlpha: 0 },
{ y: 0, autoAlpha: 1, duration: 0.55, clearProps: 'opacity,visibility,transform' },
'-=0.85',
)
// 图纸先行:每行的发丝线依次画出,内容再落位
.fromTo(
'[data-row-line]',
{ scaleX: 0 },
{ scaleX: 1, duration: 0.6, stagger: 0.07 },
'-=0.55',
)
.fromTo(
'[data-row]',
{ y: 14, autoAlpha: 0 },
{ y: 0, autoAlpha: 1, duration: 0.55, stagger: 0.07, clearProps: 'opacity,visibility,transform' },
'-=0.5',
)
.fromTo(
'[data-foot]',
{ autoAlpha: 0 },
{ autoAlpha: 1, duration: 0.6, clearProps: 'opacity,visibility' },
'-=0.35',
)
})
return () => motion.revert()
}, { scope: pageRef, dependencies: [sessionLoading] })
return (
// direction: zen-minimal × future-organic fusion (user-curated) — THESIS: 白皮书式的编号索引,悬停浮现
<div ref={pageRef} className="board-home min-h-screen bg-[#fafafa] text-[#1a1c1d]">
<style>{`.board-home ::selection { background: #eef0fa; color: #1a1c1d; }`}</style>
{/* ===== 平台顶栏(首页模式:品牌 + 五大板块导航 + 工具 + 用户菜单) ===== */}
<MaterialsHeader session={session} />
<main className="mx-auto max-w-[1280px] px-6">
{/* ===== 编辑页首:巨字 + 柔光 ===== */}
<section className="relative isolate overflow-hidden pb-16 pt-20 md:pb-24 md:pt-28">
{/* 动态品牌色场:来自 Future Organic,只在首屏承担一次有色氛围 */}
<BrandFluidField />
<div className="relative z-10">
{/* 巨型标题:入场对焦揭幕(GSAP blur+tracking),悬停字距呼吸(CSS) */}
<h1
data-hero-title
className="group cursor-default text-[clamp(60px,9vw,132px)] font-semibold leading-[1.04] tracking-[-0.03em] transition-[letter-spacing] duration-700 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:tracking-[0.035em]"
>
品牌中心
</h1>
<p data-hero className="mt-6 max-w-xl text-[15px] leading-relaxed text-[#6b7075] md:text-[16px]">
品牌的矿脉,从人到资产到经营,统一开采。
</p>
</div>
</section>
{/* ===== 编号索引(作品集列表语言;加载中骨架化防闪灰) ===== */}
{sessionLoading ? (
<SkeletonIndex />
) : (
<section aria-label="板块索引" className="border-t border-[#e7e8ea]">
{indexRows.map((row) =>
row.live ? (
<Link
key={row.no}
data-row
href={row.href ?? '#'}
className={`group relative grid grid-cols-[44px_1fr_auto] items-baseline gap-4 rounded-sm py-7 transition-colors duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] hover:bg-white md:grid-cols-[64px_1fr_160px_120px_32px] md:gap-8 md:py-9 ${focusRing}`}
>
{/* 基线发丝线:入场画出,悬停加深 */}
<span
data-row-line
aria-hidden="true"
className="absolute inset-x-0 bottom-0 h-px origin-left bg-[#e7e8ea] transition-colors duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:bg-[#d9dcdf]"
/>
{/* 悬停定位线:从左划出 */}
<span
aria-hidden="true"
className="absolute inset-x-0 bottom-[-1px] h-[2px] origin-left scale-x-0 bg-[#1a1c1d] transition-transform duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:scale-x-100"
/>
<span className="font-en text-[13px] tabular-nums text-[#86898e] transition-all duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1 group-hover:text-[#5a66b8]">
{row.no}
</span>
<div className="min-w-0">
<h2 className="text-[24px] font-semibold tracking-tight transition-transform duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1.5 md:text-[30px]">
{row.title}
</h2>
<p className="mt-1.5 text-[13px] leading-relaxed text-[#6b7075] transition-all duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1 group-hover:text-[#4a4f55]">
{row.desc}
</p>
</div>
<span className={`font-en hidden text-[11px] uppercase tracking-[0.14em] text-[#86898e] transition-colors duration-[350ms] group-hover:text-[#6b7075] md:inline`}>
{row.en}
</span>
<span className="flex items-center gap-2">
<StatusDot tone={row.tone} />
<span className="text-[12px] text-[#6b7075]">{row.status}</span>
</span>
<span
aria-hidden="true"
className="hidden -translate-x-2 text-[18px] text-[#1a1c1d] opacity-0 transition-all duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-0 group-hover:opacity-100 group-focus-visible:translate-x-0 group-focus-visible:opacity-100 md:inline"
>
→
</span>
</Link>
) : (
<div
key={row.no}
data-row
aria-disabled="true"
className="relative grid grid-cols-[44px_1fr_auto] items-baseline gap-4 py-7 md:grid-cols-[64px_1fr_160px_120px_32px] md:gap-8 md:py-9"
>
<span
data-row-line
aria-hidden="true"
className="absolute inset-x-0 bottom-0 h-px origin-left bg-[#e7e8ea]"
/>
<span className="font-en text-[13px] tabular-nums text-[#86898e]">{row.no}</span>
<div className="min-w-0">
<h2 className="text-[24px] font-medium tracking-tight text-[#8f9398] md:text-[30px]">
{row.title}
</h2>
<p className="mt-1.5 text-[13px] leading-relaxed text-[#86898e]">{row.desc}</p>
</div>
<span className="font-en hidden text-[11px] uppercase tracking-[0.14em] text-[#86898e] md:inline">
{row.en}
</span>
<span className="flex items-center gap-2">
<StatusDot tone={row.tone} />
<span className="text-[12px] text-[#86898e]">{row.status}</span>
</span>
<span aria-hidden="true" className="hidden text-[18px] text-transparent md:inline">
·
</span>
</div>
),
)}
</section>
)}
{/* ===== 微型注脚 ===== */}
<footer data-foot className="flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-[#e7e8ea] py-10">
<span className="font-en text-[10px] uppercase tracking-[0.2em] text-[#86898e]">Ground</span>
<span className="text-[12px] text-[#6b7075]">
本看板由「由壹点3D素材库」改造而来,素材库现有功能不受影响。
</span>
<Link
href="/materials"
className={`rounded-sm text-[12px] font-medium text-[#5a66b8] underline-offset-4 hover:underline ${focusRing}`}
>
直达创意资产库 →
</Link>
</footer>
</main>
</div>
)
}