Profile 与统一模块

用户资料、统一模块体系、网站条目与公开主页相关 API。

概览

链上资料页主界面在 src/app/[locale]/(default)/profile/page.tsx(客户端体量较大)。读写经 src/services/profile.ts 与 src/models/* 统一模块相关表。公开只读走 /api/public/profile/*。

主要 API(节选)

路由作用
GET/PUT /api/profile当前登录用户资料读/写(getUserUuid → profile 服务)
GET /api/profile/public对外展示用资料
GET/POST /api/modules/*、/api/modules/websites/*模块类型、网站 CRUD、排序、批量
GET /api/public/profile、/api/public/profile/[identifier]按标识获取公开主页
POST /api/profile/track-view公开主页访问统计

数据流

  1. 会话 → API 中 getUserUuid / NextAuth。
  2. 服务层(profile、public-profile、unified-modules)校验与编排。
  3. Drizzle src/models/* 写入 users、模块类型、网站及关联。

关键路径

  • 前端:src/components/profile/*、src/components/ui/quick-add-system.tsx(懒加载)。
  • 类型:src/types/profile.d.ts、src/types/unified-modules.ts。
  • 表结构:src/db/schema.ts。

说明

资料页逻辑分散,本文档为导航级说明;细粒度可后续拆分子页。

Dependencies

环境变量

  • DATABASE_URL — Profile/模块持久化必需。
  • NEXTAUTH_URL(或部署上的应用根 URL)— 部分路由会以绝对地址请求内部 API(如 favicon)。

数据库(src/db/schema.ts)

  • users、user_profiles
  • user_module_configs、user_module_website_relations、user_custom_module_types、user_custom_websites
  • preset_module_types、preset_websites(读取/从预设复制)
Profile 与统一模块 | 追踪狗文档