From f08a2a0deadebc4f12810651abb566be0810dc47 Mon Sep 17 00:00:00 2001 From: laoyang Date: Thu, 5 Nov 2026 16:13:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=BE=85=E5=8A=9E):=20=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=B8=A6=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=97=B6=E9=97=B4=20(#55)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 现象 新建待办时,截止时间默认被填成"今天 09:00",用户还得手动清掉。 ## 根因 两处叠加: 1. `Index.openTodoCreator()` 传了 `pendingTodoDate = this.selectedDate` 2. `TodoEditPage.initPage()` 拿到这个值就 `this.hasDue = true`, 并把截止时间设成"该日 09:00" 而 `@State hasDue` 本身的默认值是 `false` —— 逻辑上"默认有截止"是这两处 预填把它顶成 true 的。 ## 语义上也不对 日程(VEVENT)是"发生在某天某时的**事**",所以默认带时间合理; 待办(VTODO)是"**要完成的事**",多数一开始并不确定哪天截止, CalDAV 的 VTODO 里 DUE 本来就是可选字段。 ## 修法 1. `openTodoCreator` 不再传 `selectedDate`,改为传 0(不预填) 2. `TodoEditPage` 去掉预填分支:`hasDue` 保持 false、`dueMs` 保持 0 3. 日期选择器仍预置一个合理初值(明天 09:00),用户点了才会真正设置 ## 真机验证(5NC0225B27004718) | 验证项 | 结果 | |---|---| | 截止时间显示 | `无截止时间`(原来是 `2026-11-05 09:00`)✅ | | 「清除」按钮 | 不存在(无截止时不显示)✅ | | 右侧箭头 `›` | 存在,整行可点 ✅ | ## 编译 BUILD SUCCESSFUL --- entry/src/main/ets/pages/Index.ets | 5 ++++- entry/src/main/ets/pages/TodoEditPage.ets | 22 +++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 2763062..9b4bb57 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -3627,8 +3627,11 @@ struct Index { */ private async openTodoCreator(): Promise { // ⭐ 改为独立页面(与新建日程一致):预置参数后跳转 + // 待办默认**没有截止时间**(与日程不同:待办不是"发生在某天的事", + // 而是"要完成的事",多数待办一开始并不确定哪天截止)。 + // 所以不传 pendingTodoDate(0 = 不预填)。 AppStorage.setOrCreate('pendingTodoId', 0); - AppStorage.setOrCreate('pendingTodoDate', this.selectedDate); + AppStorage.setOrCreate('pendingTodoDate', 0); router.pushUrl({ url: 'pages/TodoEditPage' }); } diff --git a/entry/src/main/ets/pages/TodoEditPage.ets b/entry/src/main/ets/pages/TodoEditPage.ets index dc4e25f..b1aa26b 100644 --- a/entry/src/main/ets/pages/TodoEditPage.ets +++ b/entry/src/main/ets/pages/TodoEditPage.ets @@ -191,19 +191,15 @@ struct TodoEditPage { if (this.books.length > 0) { this.bookKey = this.books[0].calKey; } - // 预填截止日(从月视图某天点进来时带过来) - const preDate: number = AppStorage.get('pendingTodoDate') ?? 0; - AppStorage.setOrCreate('pendingTodoDate', 0); - if (preDate > 0) { - const d = new Date(preDate); - this.pickDate = new Date(d.getFullYear(), d.getMonth(), d.getDate()); - this.hasDue = true; - this.dueMs = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 9, 0).getTime(); - } else { - // 默认"明天 09:00",与新建日程口径一致 - const base = new Date(); - this.pickDate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1); - } + // ⭐ 新建待办默认**无截止时间**(hasDue 保持 false)。 + // 待办是"要完成的事",不是"发生在某天的事",多数一开始不确定哪天截止。 + // 日期选择器只预置一个合理的初始值(明天),用户点了才会真正设置。 + const base = new Date(); + this.pickDate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1); + this.pickHour = 9; + this.pickMin = 0; + this.hasDue = false; + this.dueMs = 0; } } catch (err) { LogUtil.write(`待办编辑页初始化失败: ${(err as BusinessError).message ?? ''}`);