440e017203
- 根因:Flutter 模板只在 debug/profile 清单中声明 INTERNET,release 包默认没有, 导致发布版「检查更新」与「AI 生成」全部无法联网 - 主清单补充 INTERNET 权限,并新增 network_security_config:仅对更新服务器 放行明文 HTTP(其余域名仍禁止) - UpdateService.check 支持传入模拟版本(自检用);新增 tool/check_update.dart 开发自检工具,可直接验证更新链路 - 版本号 1.2.2+14
30 lines
1.2 KiB
Dart
30 lines
1.2 KiB
Dart
// 开发自检工具:直接调用应用内更新服务,检查服务器上的最新版本。
|
|
//
|
|
// 用途:验证更新链路(网络可达 / 接口解析 / 版本判定 / 附件匹配)。
|
|
// 运行:
|
|
// dart run tool\check_update.dart
|
|
//
|
|
// 说明:使用的是与客户端完全相同的 lib/update/update_service.dart。
|
|
import '../lib/update/update_service.dart';
|
|
import '../lib/version.dart';
|
|
|
|
Future<void> main(List<String> args) async {
|
|
// 可传入一个版本号模拟旧安装(如 `dart run tool\check_update.dart 1.2.1`)。
|
|
final String current = args.isNotEmpty ? args.first : kAppVersion;
|
|
print('当前版本(模拟): $current');
|
|
try {
|
|
final UpdateInfo? info = await UpdateService.check(currentVersion: current);
|
|
if (info == null) {
|
|
print('结果: 已是最新版本(服务器无更高版本或缺少当前平台的安装包)');
|
|
return;
|
|
}
|
|
print('结果: 发现新版本 v${info.version}');
|
|
print('安装包: ${info.assetName} ${(info.assetSize / 1048576).toStringAsFixed(1)} MB');
|
|
print('下载地址: ${info.assetUrl}');
|
|
print('---- 更新说明 ----');
|
|
print(info.notes.trim());
|
|
} catch (e) {
|
|
print('检查失败: $e');
|
|
}
|
|
}
|