From 5497c485eaecc66ef6231da90f70a0a5f7ab44e3 Mon Sep 17 00:00:00 2001 From: 537yaha <2930134478@qq.com> Date: Mon, 2 Feb 2026 22:17:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=E5=8F=8AUI=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- backend/models/document.go | 20 ++++++++++---------- frontend/hooks/useSoundNotification.ts | 16 ++++++++++------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4e2cea8..758744d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ ### 方式一:预构建镜像一键部署(推荐,最简单)⭐ -> **最简单快捷的方式**,直接使用预构建的 Docker 镜像,无需构建,一行命令启动。 +> **最简单快捷的方式**,直接使用预构建的 Docker 镜像,无需构建,一行命令启动 #### 前置要求 diff --git a/backend/models/document.go b/backend/models/document.go index d62944a..601a80b 100644 --- a/backend/models/document.go +++ b/backend/models/document.go @@ -6,14 +6,14 @@ import ( // Document 文档模型 type Document struct { - ID uint `json:"id" gorm:"primarykey"` - KnowledgeBaseID uint `json:"knowledge_base_id" gorm:"index;not null"` - Title string `json:"title" gorm:"type:varchar(255);not null"` - Content string `json:"content" gorm:"type:text;not null"` - Summary string `json:"summary" gorm:"type:text"` // 摘要 - Type string `json:"type" gorm:"type:varchar(50);default:'document'"` // 文档类型:document, url, file - Status string `json:"status" gorm:"type:varchar(20);default:'draft'"` // 状态:draft(草稿)、published(已发布) - EmbeddingStatus string `json:"embedding_status" gorm:"type:varchar(20);default:'pending'"` // 向量化状态:pending(待处理)、processing(处理中)、completed(已完成)、failed(失败) - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID uint `json:"id" gorm:"primarykey"` + KnowledgeBaseID uint `json:"knowledge_base_id" gorm:"index;not null"` + Title string `json:"title" gorm:"type:varchar(255);not null"` + Content string `json:"content" gorm:"type:text;not null"` + Summary string `json:"summary" gorm:"type:text"` // 摘要 + Type string `json:"type" gorm:"type:varchar(50);default:'document'"` // 文档类型:document, url, file + Status string `json:"status" gorm:"type:varchar(20);default:'draft'"` // 状态:draft(草稿)、published(已发布) + EmbeddingStatus string `json:"embedding_status" gorm:"type:varchar(20);default:'pending'"` // 向量化状态:pending(待处理)、processing(处理中)、completed(已完成)、failed(失败) + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } diff --git a/frontend/hooks/useSoundNotification.ts b/frontend/hooks/useSoundNotification.ts index 4bc4610..e6f0bca 100644 --- a/frontend/hooks/useSoundNotification.ts +++ b/frontend/hooks/useSoundNotification.ts @@ -1,7 +1,7 @@ -import { useEffect, useRef } from "react"; -import { playNotificationSound } from "@/utils/sound"; +import { useCallback, useEffect, useRef, useState } from "react"; -export function useSoundNotification(enabled: boolean = true) { +export function useSoundNotification(initialEnabled: boolean = true) { + const [enabled, setEnabled] = useState(initialEnabled); const audioRef = useRef(null); useEffect(() => { @@ -20,13 +20,17 @@ export function useSoundNotification(enabled: boolean = true) { }; }, [enabled]); - const play = () => { + const play = useCallback(() => { if (enabled && audioRef.current) { audioRef.current.play().catch(() => { // 忽略播放错误 }); } - }; + }, [enabled]); - return { play }; + const toggle = useCallback(() => { + setEnabled((prev) => !prev); + }, []); + + return { enabled, toggle, play }; }