fix(待办): 新建待办默认不带截止时间 (#55)
## 现象 新建待办时,截止时间默认被填成"今天 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
This commit is contained in:
@@ -3627,8 +3627,11 @@ struct Index {
|
|||||||
*/
|
*/
|
||||||
private async openTodoCreator(): Promise<void> {
|
private async openTodoCreator(): Promise<void> {
|
||||||
// ⭐ 改为独立页面(与新建日程一致):预置参数后跳转
|
// ⭐ 改为独立页面(与新建日程一致):预置参数后跳转
|
||||||
|
// 待办默认**没有截止时间**(与日程不同:待办不是"发生在某天的事",
|
||||||
|
// 而是"要完成的事",多数待办一开始并不确定哪天截止)。
|
||||||
|
// 所以不传 pendingTodoDate(0 = 不预填)。
|
||||||
AppStorage.setOrCreate<number>('pendingTodoId', 0);
|
AppStorage.setOrCreate<number>('pendingTodoId', 0);
|
||||||
AppStorage.setOrCreate<number>('pendingTodoDate', this.selectedDate);
|
AppStorage.setOrCreate<number>('pendingTodoDate', 0);
|
||||||
router.pushUrl({ url: 'pages/TodoEditPage' });
|
router.pushUrl({ url: 'pages/TodoEditPage' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,19 +191,15 @@ struct TodoEditPage {
|
|||||||
if (this.books.length > 0) {
|
if (this.books.length > 0) {
|
||||||
this.bookKey = this.books[0].calKey;
|
this.bookKey = this.books[0].calKey;
|
||||||
}
|
}
|
||||||
// 预填截止日(从月视图某天点进来时带过来)
|
// ⭐ 新建待办默认**无截止时间**(hasDue 保持 false)。
|
||||||
const preDate: number = AppStorage.get<number>('pendingTodoDate') ?? 0;
|
// 待办是"要完成的事",不是"发生在某天的事",多数一开始不确定哪天截止。
|
||||||
AppStorage.setOrCreate<number>('pendingTodoDate', 0);
|
// 日期选择器只预置一个合理的初始值(明天),用户点了才会真正设置。
|
||||||
if (preDate > 0) {
|
const base = new Date();
|
||||||
const d = new Date(preDate);
|
this.pickDate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1);
|
||||||
this.pickDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
this.pickHour = 9;
|
||||||
this.hasDue = true;
|
this.pickMin = 0;
|
||||||
this.dueMs = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 9, 0).getTime();
|
this.hasDue = false;
|
||||||
} else {
|
this.dueMs = 0;
|
||||||
// 默认"明天 09:00",与新建日程口径一致
|
|
||||||
const base = new Date();
|
|
||||||
this.pickDate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
LogUtil.write(`待办编辑页初始化失败: ${(err as BusinessError).message ?? ''}`);
|
LogUtil.write(`待办编辑页初始化失败: ${(err as BusinessError).message ?? ''}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user