Files
EasyDesignCollection/tool/check_update.dart
T

30 lines
1.2 KiB
Dart
Raw Permalink Normal View History

// 开发自检工具:直接调用应用内更新服务,检查服务器上的最新版本。
//
// 用途:验证更新链路(网络可达 / 接口解析 / 版本判定 / 附件匹配)。
// 运行:
// 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');
}
}