From 5fe8b035f7755f8e643cb76e7967bb5ca50cae3b Mon Sep 17 00:00:00 2001 From: bluish <734499798@qq.com> Date: Tue, 13 Jan 2026 10:11:49 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/routes.py | 4 ++++ frontend/css/style.css | 2 ++ frontend/js/app.js | 31 +++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/backend/routes.py b/backend/routes.py index 0e916f3..0244110 100644 --- a/backend/routes.py +++ b/backend/routes.py @@ -28,6 +28,7 @@ class TaskUpdate(BaseModel): title: Optional[str] = None description: Optional[str] = None status: Optional[str] = None + polished_description: Optional[str] = None # 支持更新或清空润色描述 class TimerRequest(BaseModel): task_id: int @@ -127,6 +128,9 @@ async def update_task(task_id: int, data: TaskUpdate, db: Session = Depends(get_ task.description = data.description if data.status is not None: task.status = data.status + # 支持更新或清空 polished_description(包括设置为 null) + if hasattr(data, 'polished_description'): + task.polished_description = data.polished_description task.updated_at = datetime.utcnow() db.commit() diff --git a/frontend/css/style.css b/frontend/css/style.css index 6041d85..8b24863 100644 --- a/frontend/css/style.css +++ b/frontend/css/style.css @@ -266,6 +266,8 @@ body { color: #718096; line-height: 1.6; margin-bottom: 15px; + white-space: pre-wrap; /* 保留换行和空格 */ + word-wrap: break-word; /* 长单词自动换行 */ } .task-description.polished { diff --git a/frontend/js/app.js b/frontend/js/app.js index 27bdcab..941144f 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -384,11 +384,38 @@ class WorkListApp { } // 使用润色版本 - usePolishedDescription() { + async usePolishedDescription() { const polishedText = document.querySelector('.polished-text').textContent; document.getElementById('taskDescription').value = polishedText; document.getElementById('polishedDescription').style.display = 'none'; - this.showNotification('已使用润色版本', 'success'); + + // 如果是编辑模式,立即保存更新,将润色版本替换原始描述 + if (this.currentEditingTask) { + try { + this.showLoading(); + + // 更新任务:description = 润色版本, polished_description = null + await api.updateTask(this.currentEditingTask.id, { + description: polishedText, + polished_description: null // 清空润色字段 + }); + + // 关闭模态框 + this.hideModal(document.getElementById('taskModal')); + + // 刷新任务列表 + await this.loadTasks(); + + this.showNotification('已应用润色版本', 'success'); + } catch (error) { + console.error('应用润色版本失败:', error); + this.showNotification(error.message || '应用润色版本失败', 'error'); + } finally { + this.hideLoading(); + } + } else { + this.showNotification('已使用润色版本', 'success'); + } } // 丢弃润色版本