feat: 添加自定义卡片内容为空时删除卡片的功能

This commit is contained in:
Sunwuyuan
2025-12-07 13:31:41 +08:00
parent 1831c9144d
commit ac508d5eb4
+10
View File
@@ -1143,6 +1143,16 @@ export default {
this.state.boardData.homework[this.currentEditSubject]?.content || ""; this.state.boardData.homework[this.currentEditSubject]?.content || "";
if (content !== originalContent.trim()) { if (content !== originalContent.trim()) {
// 如果内容为空且是自定义卡片,则删除该卡片
if (!content && this.currentEditSubject.startsWith('custom-')) {
delete this.state.boardData.homework[this.currentEditSubject];
this.state.synced = false;
if (this.autoSave) {
await this.trySave(true);
}
this.state.dialogVisible = false;
return;
}
// 如果是自定义卡片,保留其他属性 // 如果是自定义卡片,保留其他属性
if (this.state.boardData.homework[this.currentEditSubject].type === 'custom') { if (this.state.boardData.homework[this.currentEditSubject].type === 'custom') {
this.state.boardData.homework[this.currentEditSubject].content = content; this.state.boardData.homework[this.currentEditSubject].content = content;