优化显示
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
// 丢弃润色版本
|
||||
|
||||
Reference in New Issue
Block a user