核心功能: - 项目初始化 (Nuxt 4 + Nuxt UI + Pinia + ofetch) - TypeScript 类型定义 (User, Article, Comment, API 响应) - 认证系统 (登录/登出、Cookie 支持、权限中间件) - 文章列表页 (筛选、分页、响应式布局) - 文章详情页 (Markdown 渲染、评论系统) - 文章编辑器 (左右分栏、实时预览、Markdown 工具栏) 管理后台: - 侧边栏布局、权限检查 - 数据分析 (数据统计卡片、热门文章、评论审核统计) - 文章管理 (表格、筛选、删除) - 评论管理 (审核通过/拒绝、删除) - 用户管理 (角色管理、删除) 全局组件: - 导航栏 (暗色模式切换、移动端菜单) - 页脚 - 403/404 错误页 配置文件: - .env.example 环境变量模板 - nuxt.config.ts 完整配置 - 自定义 CSS 样式
124 lines
2.4 KiB
TypeScript
124 lines
2.4 KiB
TypeScript
export interface User {
|
|
id: number
|
|
email: string
|
|
username: string
|
|
displayName: string | null
|
|
avatarUrl: string | null
|
|
role: 'admin' | 'moderator' | 'user'
|
|
isActive: boolean
|
|
createdAt: string
|
|
updatedAt: string
|
|
}
|
|
|
|
export interface Article {
|
|
id: number
|
|
slug: string
|
|
title: string
|
|
content: string | null
|
|
excerpt: string | null
|
|
coverImageUrl: string | null
|
|
status: 'draft' | 'published' | 'archived'
|
|
visibility: 'public' | 'unlisted' | 'private'
|
|
viewCount: number
|
|
publishedAt: string | null
|
|
createdAt: string
|
|
updatedAt: string
|
|
author: Pick<User, 'id' | 'username' | 'displayName' | 'avatarUrl'>
|
|
comments?: Comment[]
|
|
reactions?: Reaction[]
|
|
}
|
|
|
|
export interface Comment {
|
|
id: number
|
|
articleId: number
|
|
parentId: number | null
|
|
content: string
|
|
status: 'pending' | 'approved' | 'rejected' | 'suspicious'
|
|
authorName: string | null
|
|
authorEmail: string | null
|
|
authorId: number | null
|
|
createdAt: string
|
|
updatedAt: string
|
|
author?: User | null
|
|
replies?: Comment[]
|
|
}
|
|
|
|
export interface Reaction {
|
|
id: number
|
|
articleId: number
|
|
userId: number
|
|
type: string
|
|
createdAt: string
|
|
}
|
|
|
|
export interface ArticleVersion {
|
|
id: number
|
|
articleId: number
|
|
content: string
|
|
title: string
|
|
version: number
|
|
createdAt: string
|
|
createdBy: Pick<User, 'id' | 'username' | 'displayName'>
|
|
}
|
|
|
|
export interface CommentAudit {
|
|
id: number
|
|
commentId: number
|
|
action: string
|
|
reason: string
|
|
performedBy: string
|
|
performedAt: string
|
|
}
|
|
|
|
export interface PaginationResponse<T> {
|
|
items: T[]
|
|
total: number
|
|
page: number
|
|
limit: number
|
|
totalPages: number
|
|
}
|
|
|
|
export interface AnalyticsSummary {
|
|
totalArticles: number
|
|
totalComments: number
|
|
totalUsers: number
|
|
totalViews: number
|
|
dailyViews: { date: string; views: number }[]
|
|
popularArticles: Article[]
|
|
commentStats: {
|
|
pending: number
|
|
approved: number
|
|
rejected: number
|
|
suspicious: number
|
|
}
|
|
}
|
|
|
|
export interface LoginCredentials {
|
|
emailOrUsername: string
|
|
password: string
|
|
}
|
|
|
|
export interface CreateArticleInput {
|
|
title: string
|
|
content: string
|
|
excerpt?: string
|
|
coverImageUrl?: string
|
|
status: 'draft' | 'published' | 'archived'
|
|
visibility: 'public' | 'unlisted' | 'private'
|
|
}
|
|
|
|
export interface UpdateArticleInput extends Partial<CreateArticleInput> {
|
|
slug?: string
|
|
}
|
|
|
|
export interface CreateCommentInput {
|
|
content: string
|
|
parentId?: number
|
|
}
|
|
|
|
export interface ApiError {
|
|
message: string
|
|
code: string
|
|
details?: Record<string, string[]>
|
|
}
|