refactor: 重构知识库文件上传和处理, 支持 pdf

This commit is contained in:
2026-03-23 16:30:13 +08:00
parent 89af7c17f1
commit 63ea2686e1
17 changed files with 905 additions and 1782 deletions

View File

@@ -6,35 +6,16 @@ return [
|--------------------------------------------------------------------------
| 文档转换配置
|--------------------------------------------------------------------------
|
| 这里配置文档转换相关的设置,包括转换驱动、超时时间和队列配置。
|
*/
'conversion' => [
/*
| 转换驱动
| 支持的驱动: 'pandoc', 'phpword'
| 推荐使用 pandoc 以获得更好的转换质量
*/
'driver' => env('DOCUMENT_CONVERSION_DRIVER', 'pandoc'),
/*
| Pandoc 可执行文件路径
| 如果 pandoc 在系统 PATH 中,可以直接使用 'pandoc'
| 否则需要指定完整路径,如 '/usr/local/bin/pandoc'
*/
'pandoc_path' => env('PANDOC_PATH', '/opt/homebrew/bin/pandoc'),
/*
| 转换超时时间(秒)
| 大文档可能需要更长的转换时间
*/
'timeout' => env('CONVERSION_TIMEOUT', 300),
/*
| 队列名称
| 文档转换任务将被分发到此队列
*/
'queue' => env('CONVERSION_QUEUE', 'documents'),
@@ -49,37 +30,33 @@ return [
'retry_delay' => env('CONVERSION_RETRY_DELAY', 60),
],
/*
|--------------------------------------------------------------------------
| 支持的文件格式
|--------------------------------------------------------------------------
*/
'supported_formats' => [
'extensions' => ['docx', 'pdf', 'pptx', 'xlsx'],
'mime_types' => [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/pdf',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
],
/*
|--------------------------------------------------------------------------
| Markdown 配置
|--------------------------------------------------------------------------
|
| Markdown 渲染和处理相关的配置。
|
*/
'markdown' => [
/*
| Markdown 渲染器
| 支持的渲染器: 'commonmark', 'parsedown'
*/
'renderer' => env('MARKDOWN_RENDERER', 'commonmark'),
/*
| 是否清理 HTML 以防止 XSS 攻击
*/
'sanitize' => env('MARKDOWN_SANITIZE', true),
/*
| Markdown 预览长度(字符数)
| 用于在数据库中存储的内容摘要
*/
'preview_length' => env('MARKDOWN_PREVIEW_LENGTH', 500),
/*
| Markdown 文件最大大小(字节)
| 超过此大小的文件将分块处理
*/
'max_file_size' => env('MARKDOWN_MAX_FILE_SIZE', 10485760), // 10MB
],
@@ -87,26 +64,11 @@ return [
|--------------------------------------------------------------------------
| 存储配置
|--------------------------------------------------------------------------
|
| 文档和 Markdown 文件的存储配置。
|
*/
'storage' => [
/*
| 文档存储磁盘
*/
'documents_disk' => env('DOCUMENTS_DISK', 'documents'),
/*
| Markdown 存储磁盘
*/
'markdown_disk' => env('MARKDOWN_DISK', 'markdown'),
/*
| 是否按日期组织文件目录
| 格式: YYYY/MM/DD/
*/
'organize_by_date' => env('STORAGE_ORGANIZE_BY_DATE', true),
],