优化显示

This commit is contained in:
2026-01-13 10:11:49 +00:00
parent 1a9286c153
commit 5fe8b035f7
3 changed files with 35 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ class TaskUpdate(BaseModel):
title: Optional[str] = None title: Optional[str] = None
description: Optional[str] = None description: Optional[str] = None
status: Optional[str] = None status: Optional[str] = None
polished_description: Optional[str] = None # 支持更新或清空润色描述
class TimerRequest(BaseModel): class TimerRequest(BaseModel):
task_id: int task_id: int
@@ -127,6 +128,9 @@ async def update_task(task_id: int, data: TaskUpdate, db: Session = Depends(get_
task.description = data.description task.description = data.description
if data.status is not None: if data.status is not None:
task.status = data.status task.status = data.status
# 支持更新或清空 polished_description包括设置为 null
if hasattr(data, 'polished_description'):
task.polished_description = data.polished_description
task.updated_at = datetime.utcnow() task.updated_at = datetime.utcnow()
db.commit() db.commit()

View File

@@ -266,6 +266,8 @@ body {
color: #718096; color: #718096;
line-height: 1.6; line-height: 1.6;
margin-bottom: 15px; margin-bottom: 15px;
white-space: pre-wrap; /* 保留换行和空格 */
word-wrap: break-word; /* 长单词自动换行 */
} }
.task-description.polished { .task-description.polished {

View File

@@ -384,12 +384,39 @@ class WorkListApp {
} }
// 使用润色版本 // 使用润色版本
usePolishedDescription() { async usePolishedDescription() {
const polishedText = document.querySelector('.polished-text').textContent; const polishedText = document.querySelector('.polished-text').textContent;
document.getElementById('taskDescription').value = polishedText; document.getElementById('taskDescription').value = polishedText;
document.getElementById('polishedDescription').style.display = 'none'; document.getElementById('polishedDescription').style.display = 'none';
// 如果是编辑模式,立即保存更新,将润色版本替换原始描述
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'); this.showNotification('已使用润色版本', 'success');
} }
}
// 丢弃润色版本 // 丢弃润色版本
discardPolishedDescription() { discardPolishedDescription() {