fix: preserve queued settings and recover interrupted or corrupt state

This commit is contained in:
Codex
2026-10-13 09:32:50 +08:00
parent 5ceab20b67
commit da5b8076a0
16 changed files with 373 additions and 50 deletions
+30
View File
@@ -159,6 +159,31 @@ class _ShellState extends State<_Shell> with WidgetsBindingObserver {
}
}
Future<void> _startFresh() async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('重新建立课表'),
content: const Text(
'损坏文件会保留为恢复副本,然后重新建立空课表。已有课程通知会取消;手机日历中原有课程日程需手动处理。',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('取消'),
),
FilledButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('保留损坏文件并重新建立'),
),
],
),
);
if (confirmed == true) {
await widget.controller.startFreshData();
}
}
@override
Widget build(BuildContext context) => AnimatedBuilder(
animation: Listenable.merge([
@@ -198,6 +223,11 @@ class _ShellState extends State<_Shell> with WidgetsBindingObserver {
onPressed: widget.controller.restoreBackup,
child: const Text('恢复最近备份'),
),
if (!widget.controller.storageReady)
TextButton(
onPressed: _startFresh,
child: const Text('重新建立课表'),
),
],
),
),