This commit is contained in:
Developer
2026-06-05 02:31:55 +08:00
parent a5d8483797
commit c014ad7dec
2 changed files with 23 additions and 3 deletions

View File

@@ -4,6 +4,24 @@
***
## [v6.16.8] - 2026-06-05
### 🛡️ main()初始化异常捕获修复
#### 问题
- **`_appMain()`未捕获异常** — `_appMain()`是返回`Future<void>`的异步函数,在`main()`中直接调用未await也未捕获异常。若初始化过程中发生未处理的异步异常如windowManager初始化失败、Catcher2配置异常等会导致顶层未处理的Future异常整个应用崩溃且无日志记录。
#### 修复
- **catchError兜底** — 在`main()`中为`_appMain()`调用添加`.catchError()`,捕获所有未处理的异步异常并记录日志,防止静默崩溃
#### 举一反三
- 所有异步入口函数调用必须处理Future异常catchError或try-catch
- 即使内部各步骤已有try-catch顶层仍需兜底保护防止遗漏
**修改文件:** `lib/main.dart`
***
## [v6.16.7] - 2026-06-05
### 🌐 Web端编译+运行修复 — Platform兼容+Zone mismatch+path_provider保护

View File

@@ -1,9 +1,9 @@
// ============================================================
// 闲言APP — 应用入口
// 创建时间: 2026-04-20
// 更新时间: 2026-05-30
// 更新时间: 2026-06-05
// 作用: main 函数,初始化存储 + 液态玻璃 + 异常捕获 + 启动 App
// 上次更新: 替换bitsdojo_window为window_manager桌面端窗口初始化
// 上次更新: _appMain()调用增加catchError捕获未处理异常防止初始化失败崩溃
// ============================================================
import 'dart:async';
@@ -50,7 +50,9 @@ void main() async {
// 移除外层 runZonedGuarded由 Catcher2 内部管理 zone
// 异常捕获由 Catcher2 + GlobalErrorHandler 共同处理
_appMain();
_appMain().catchError((Object e, StackTrace st) {
Log.e('main初始化失败', e, st);
});
}
/// 应用主入口逻辑