From 440e017203e7654ec4ba65b2d2f8103afea25781 Mon Sep 17 00:00:00 2001 From: liuyu65 Date: Fri, 9 Oct 2026 10:12:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(android):=20=E4=BF=AE=E5=A4=8D=20release=20?= =?UTF-8?q?=E7=89=88=E6=97=A0=E6=B3=95=E8=81=94=E7=BD=91=EF=BC=88=E7=BC=BA?= =?UTF-8?q?=20INTERNET=20=E6=9D=83=E9=99=90=EF=BC=89=EF=BC=9B=E5=8F=91?= =?UTF-8?q?=E5=B8=83=20v1.2.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因:Flutter 模板只在 debug/profile 清单中声明 INTERNET,release 包默认没有, 导致发布版「检查更新」与「AI 生成」全部无法联网 - 主清单补充 INTERNET 权限,并新增 network_security_config:仅对更新服务器 放行明文 HTTP(其余域名仍禁止) - UpdateService.check 支持传入模拟版本(自检用);新增 tool/check_update.dart 开发自检工具,可直接验证更新链路 - 版本号 1.2.2+14 --- BUILD-NOTES.md | 2 +- README.md | 6 ++-- android/app/src/main/AndroidManifest.xml | 3 ++ .../main/res/xml/network_security_config.xml | 7 +++++ lib/ui/dialogs.dart | 2 +- lib/update/update_service.dart | 8 +++-- lib/version.dart | 2 +- pubspec.yaml | 2 +- release/RELEASE_NOTES_v1.2.2.md | 5 ++++ tool/check_update.dart | 29 +++++++++++++++++++ 10 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 android/app/src/main/res/xml/network_security_config.xml create mode 100644 release/RELEASE_NOTES_v1.2.2.md create mode 100644 tool/check_update.dart diff --git a/BUILD-NOTES.md b/BUILD-NOTES.md index 08cdedc..d3db458 100644 --- a/BUILD-NOTES.md +++ b/BUILD-NOTES.md @@ -127,7 +127,7 @@ flutter pub get flutter build apk --release # 产物:build\app\outputs\flutter-apk\app-release.apk ``` -- 发布包归档:`release\sequence_diagram_android_v1.2.1_release.apk`(**本地保留,不入库**;exe 的 `dist\` 同理)。 +- 发布包归档:`release\sequence_diagram_android_v1.2.2_release.apk`(**本地保留,不入库**;exe 的 `dist\` 同理)。 - 上架应用商店时建议在 `android\app\build.gradle.kts` 配置正式签名后再构建 AAB: `flutter build appbundle --release`。 - 应用名「时序图设计」、包名 `cc.sincos.sequence_diagram`、launcher 图标由 diff --git a/README.md b/README.md index 9a513a5..bc6967f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - **深色 / 浅色双主题**:右上角 ☀ / ☾ 一键切换,语义颜色不变,导出 SVG 与屏幕一致 - **导出 SVG**:矢量、分层、带语义 `id` / `data-*` 元数据,可直接进工艺卡与 MES -## 正式版 V1.2.1 +## 正式版 V1.2.2 **可运行的 Flutter Windows 桌面正式版**(源码在 `lib/`),设计人:呆头鹅。 @@ -97,7 +97,7 @@ Flutter 3.29+(Desktop) · CustomPainter 自绘 · Riverpod · 不可变模 - **正式签名**:release 用独立 keystore 签名(`android/key/release.jks`,见 `BUILD-NOTES.md`),更新安装无需卸载重装; - **构建**:JDK 17 + Android SDK 36(详见 `BUILD-NOTES.md`),Gradle 与 Maven 已配置国内镜像: ```bash - flutter build apk --release # 产物 → release/sequence_diagram_android_v1.2.1_release.apk + flutter build apk --release # 产物 → release/sequence_diagram_android_v1.2.2_release.apk ``` - **自测**:`test/tablet_layout_test.dart` 覆盖 1280×800、2560×1600、960×600、800×480、竖屏 800×1280、600×960 等 7 种分辨率的无溢出回归; - **demo 图**:`demo/tablet-*.png`(由 `test/tablet_screenshots_test.dart` 生成)。 @@ -113,6 +113,6 @@ Flutter 3.29+(Desktop) · CustomPainter 自绘 · Riverpod · 不可变模 - **软件**:时序图设计 · Sequence Diagram Studio - **设计人**:呆头鹅 -- **版本**:V1.2.1 +- **版本**:V1.2.2 - **版权**:Copyright © 2026 呆头鹅。保留所有权利。 - **架构文档**:[`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) · **使用帮助**:[`docs/HELP.md`](docs/HELP.md) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 18cc1e5..78a59c7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -3,9 +3,12 @@ + + diff --git a/android/app/src/main/res/xml/network_security_config.xml b/android/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000..4219d1e --- /dev/null +++ b/android/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,7 @@ + + + + + 124.220.63.9 + + diff --git a/lib/ui/dialogs.dart b/lib/ui/dialogs.dart index ff6f012..f63b6a1 100644 --- a/lib/ui/dialogs.dart +++ b/lib/ui/dialogs.dart @@ -2124,7 +2124,7 @@ class HelpDialog extends StatelessWidget { Text('时序图设计 · Sequence Diagram Studio', style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)), const SizedBox(height: 4), - Text('V1.2.1(${android ? '安卓版' : 'Windows 版'})', + Text('V1.2.2(${android ? '安卓版' : 'Windows 版'})', style: TextStyle(color: t.dim, fontSize: 12)), ], ), diff --git a/lib/update/update_service.dart b/lib/update/update_service.dart index 53d5d13..8152b1a 100644 --- a/lib/update/update_service.dart +++ b/lib/update/update_service.dart @@ -86,10 +86,12 @@ class UpdateService { /// 检查更新。 /// - /// 远端版本高于 [kAppVersion] 且存在当前平台的安装包时返回 [UpdateInfo]; + /// [currentVersion] 为当前版本(缺省用 [kAppVersion];自检工具可传入模拟值)。 + /// 远端版本高于当前版本且存在当前平台的安装包时返回 [UpdateInfo]; /// 无更新(或尚未发布任何版本)返回 null;网络 / 服务器异常抛出 [Exception], /// 由调用方决定是否静默。 - static Future check() async { + static Future check({String? currentVersion}) async { + final String current = currentVersion ?? kAppVersion; final HttpClient client = HttpClient() ..connectionTimeout = const Duration(seconds: 8); try { @@ -103,7 +105,7 @@ class UpdateService { } final Map j = jsonDecode(text) as Map; final String tag = (j['tag_name'] as String?) ?? ''; - if (!isNewerVersion(tag, kAppVersion)) return null; + if (!isNewerVersion(tag, current)) return null; final String notes = (j['body'] as String?) ?? ''; // 选择当前平台的安装包:安卓取 .apk;Windows 优先 .zip(绿色版整包)。 bool isTarget(String n) { diff --git a/lib/version.dart b/lib/version.dart index b3c8909..9a68248 100644 --- a/lib/version.dart +++ b/lib/version.dart @@ -2,4 +2,4 @@ /// /// 应用内更新检查用它判断服务器发布的版本是否更新; /// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。 -const String kAppVersion = '1.2.1'; +const String kAppVersion = '1.2.2'; diff --git a/pubspec.yaml b/pubspec.yaml index 1e164ab..87f7f9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.2.1+13 +version: 1.2.2+14 environment: sdk: ^3.13.3 diff --git a/release/RELEASE_NOTES_v1.2.2.md b/release/RELEASE_NOTES_v1.2.2.md new file mode 100644 index 0000000..a17be1f --- /dev/null +++ b/release/RELEASE_NOTES_v1.2.2.md @@ -0,0 +1,5 @@ +# V1.2.2 更新内容 + +- **修复发布版无法联网的问题**:补充网络访问权限(INTERNET),并为更新服务器 + 配置明文 HTTP 白名单——应用内「检查更新」恢复正常(此前 release 版收不到更新提示) +- AI 自然语言生成在发布版中同样恢复可用 diff --git a/tool/check_update.dart b/tool/check_update.dart new file mode 100644 index 0000000..453965a --- /dev/null +++ b/tool/check_update.dart @@ -0,0 +1,29 @@ +// 开发自检工具:直接调用应用内更新服务,检查服务器上的最新版本。 +// +// 用途:验证更新链路(网络可达 / 接口解析 / 版本判定 / 附件匹配)。 +// 运行: +// dart run tool\check_update.dart +// +// 说明:使用的是与客户端完全相同的 lib/update/update_service.dart。 +import '../lib/update/update_service.dart'; +import '../lib/version.dart'; + +Future main(List 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'); + } +}