## 主要变更 ### OCR 架构 - 新增多提供商 OCR 系统 (Tesseract.js, Baidu OCR, RapidOCR) - 添加 Provider 基类接口和工厂模式 - 支持 provider 自动选择和降级处理 - 新增 RapidOCR Python HTTP 服务 (端口 8080) ### 路径修复 - 修复 Windows 平台路径解析问题 - 统一路径处理工具 (lib/path.ts) - 修复 uploads 目录定位问题 ### 设置页面重构 - 三个标签页:API 配置、OCR 配置、AI 配置 - API 服务器地址配置 - OCR 服务商配置(Tesseract.js, RapidOCR, 百度 OCR) - AI 服务商配置(智谱 GLM, MiniMax, DeepSeek, Kimi, OpenAI, Anthropic) ### 端口配置 - 前端端口: 13056 - 后端端口: 13057 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
176 lines
4.5 KiB
Plaintext
176 lines
4.5 KiB
Plaintext
// Prisma Schema - 图片OCR与智能文档管理系统
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
}
|
|
|
|
// 用户
|
|
model User {
|
|
id String @id @default(uuid())
|
|
username String @unique
|
|
email String? @unique
|
|
password_hash String
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
documents Document[]
|
|
todos Todo[]
|
|
categories Category[]
|
|
tags Tag[]
|
|
images Image[]
|
|
configs Config[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
// 文档
|
|
model Document {
|
|
id String @id @default(uuid())
|
|
user_id String
|
|
title String?
|
|
content String
|
|
category_id String?
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
category Category? @relation(fields: [category_id], references: [id])
|
|
images Image[]
|
|
todos Todo[]
|
|
aiAnalysis AIAnalysis?
|
|
|
|
@@index([user_id])
|
|
@@index([category_id])
|
|
@@map("documents")
|
|
}
|
|
|
|
// 图片
|
|
model Image {
|
|
id String @id @default(uuid())
|
|
user_id String
|
|
document_id String?
|
|
file_path String
|
|
file_size Int
|
|
mime_type String
|
|
ocr_result String?
|
|
ocr_confidence Float?
|
|
processing_status String @default("pending")
|
|
quality_score Float?
|
|
error_message String?
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
document Document? @relation(fields: [document_id], references: [id], onDelete: SetNull)
|
|
|
|
@@index([user_id])
|
|
@@index([processing_status])
|
|
@@index([document_id])
|
|
@@map("images")
|
|
}
|
|
|
|
// 待办事项
|
|
model Todo {
|
|
id String @id @default(uuid())
|
|
user_id String
|
|
document_id String?
|
|
title String
|
|
description String?
|
|
priority String @default("medium")
|
|
status String @default("pending")
|
|
due_date DateTime?
|
|
category_id String?
|
|
completed_at DateTime?
|
|
confirmed_at DateTime?
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
document Document? @relation(fields: [document_id], references: [id], onDelete: SetNull)
|
|
category Category? @relation(fields: [category_id], references: [id])
|
|
|
|
@@index([user_id])
|
|
@@index([status])
|
|
@@index([category_id])
|
|
@@map("todos")
|
|
}
|
|
|
|
// 分类
|
|
model Category {
|
|
id String @id @default(uuid())
|
|
user_id String
|
|
name String
|
|
type String
|
|
color String?
|
|
icon String?
|
|
parent_id String?
|
|
sort_order Int @default(0)
|
|
usage_count Int @default(0)
|
|
is_ai_created Boolean @default(false)
|
|
created_at DateTime @default(now())
|
|
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
parent Category? @relation("CategoryToCategory", fields: [parent_id], references: [id])
|
|
children Category[] @relation("CategoryToCategory")
|
|
documents Document[]
|
|
todos Todo[]
|
|
|
|
@@index([user_id])
|
|
@@index([type])
|
|
@@map("categories")
|
|
}
|
|
|
|
// 标签
|
|
model Tag {
|
|
id String @id @default(uuid())
|
|
user_id String
|
|
name String
|
|
color String?
|
|
usage_count Int @default(0)
|
|
is_ai_created Boolean @default(false)
|
|
created_at DateTime @default(now())
|
|
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([user_id, name])
|
|
@@index([user_id])
|
|
@@map("tags")
|
|
}
|
|
|
|
// AI分析结果
|
|
model AIAnalysis {
|
|
id String @id @default(uuid())
|
|
document_id String @unique
|
|
provider String
|
|
model String
|
|
suggested_tags String
|
|
suggested_category String?
|
|
summary String?
|
|
raw_response String
|
|
created_at DateTime @default(now())
|
|
|
|
document Document @relation(fields: [document_id], references: [id], onDelete: Cascade)
|
|
|
|
@@map("ai_analyses")
|
|
}
|
|
|
|
// 配置
|
|
model Config {
|
|
id String @id @default(uuid())
|
|
user_id String
|
|
key String
|
|
value String
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([user_id, key])
|
|
@@index([user_id])
|
|
@@map("configs")
|
|
}
|