From 10a917adf64481c53b14498e1eacc10318b5ac45 Mon Sep 17 00:00:00 2001 From: Developer Date: Fri, 26 Jun 2026 09:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A1=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 37 +++++++++++++++++++ lib/core/router/app_nav_extension.dart | 5 +-- .../services/auth/permission_service.dart | 25 ++++++------- .../presentation/reading_report_page.dart | 5 +-- .../privacy/permission_management_page.dart | 2 +- .../theme/theme_sections_style.dart | 2 +- pubspec.macos.yaml | 2 +- pubspec.ohos.yaml | 2 +- test/l10n/translation_coverage_test.dart | 6 ++- 9 files changed, 61 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a6abfa..849983e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,43 @@ *** +## [v6.139.0] - 2026-06-26 + +### 🧹 macOS 编译验证 + 静态分析清理 + +#### 背景 +编译运行 macOS 端验证应用状态,确认无构建错误和运行时异常。同时清理 `flutter analyze` 报告的低风险静态问题,并将 `PermissionService.openSettings` 透传权限名到原生日志,提升 macOS 权限跳转日志可读性。 + +#### 编译运行验证 +- `flutter run -d macos` 编译成功,应用正常启动 +- 网络请求正常(`/api/user_center/index`、`/api/webapi/ip`、`/api/feed/favorites` 返回 200) +- 菜单栏语言切换、GoRouter 路由跳转、权限被拒后引导跳转系统设置均工作正常 +- 运行日志中观察到的 `macOS photos 权限请求失败: permanentlyDenied` 属预期行为(用户在 TCC 弹窗拒绝),应用正确引导用户前往系统设置 + +#### 静态分析清理(25 → 20,0 error / 0 warning) +| 文件 | 修复 | +|------|------| +| `lib/features/reading_report/presentation/reading_report_page.dart` | 移除未使用的 `go_router` import | +| `lib/core/router/app_nav_extension.dart` | 移除冗余的 `flutter/widgets.dart` import(cupertino.dart 已覆盖) | +| `test/l10n/translation_coverage_test.dart` | 添加 `ignore_for_file: avoid_print`(测试诊断输出) | + +#### 权限跳转日志增强 +**`lib/core/services/auth/permission_service.dart`**: +- `openSettings()` 新增可选参数 `AppPermission? permission` +- macOS 分支透传 `permission.macosPermissionName` 到 `MacosPlatformService.openPermissionSettings()` +- 原生日志从「权限: nil」改善为「权限: photos」等具名输出(macOS 无法深链到具体权限子页,仅用于日志可读性) + +**调用点同步更新**(4 处): +- `_showSettingsDialog`:`openSettings(perm)` +- `_showDeniedDialog`:`openSettings(perm)` +- `permission_management_page.dart`:`openSettings(p)` +- `theme_sections_style.dart`:`openSettings(AppPermission.photos)` + +#### 验证 +- `flutter analyze` 通过,0 error / 0 warning,剩余 20 个 info(async gap、`bytes` 废弃、参数冗余)按需后续处理 + +--- + ## [v6.138.0] - 2026-06-26 ### 🔧 全量迁移应用数据至 Application Support(v6.137.0 后续) diff --git a/lib/core/router/app_nav_extension.dart b/lib/core/router/app_nav_extension.dart index e1797a67..11cf336b 100644 --- a/lib/core/router/app_nav_extension.dart +++ b/lib/core/router/app_nav_extension.dart @@ -1,13 +1,12 @@ // ============================================================ // 闲言APP — 跨平台导航扩展 // 创建时间: 2026-05-18 -// 更新时间: 2026-06-23 +// 更新时间: 2026-06-26 // 作用: 统一导航API,鸿蒙端使用OhosNavBridge,其他端使用GoRouter;自动记录最近路由 -// 上次更新: appPushWidget 新增 extra 参数 — 工作台模式下传递额外数据到右栏 +// 上次更新: 移除冗余的 flutter/widgets.dart import(cupertino.dart 已覆盖) // ============================================================ import 'package:flutter/cupertino.dart'; -import 'package:flutter/widgets.dart'; import 'package:go_router/go_router.dart'; import 'package:xianyan/core/utils/platform/platform_utils.dart' as pu; import 'package:xianyan/core/router/ohos_nav_bridge.dart'; diff --git a/lib/core/services/auth/permission_service.dart b/lib/core/services/auth/permission_service.dart index c002f4c5..3eb54f31 100644 --- a/lib/core/services/auth/permission_service.dart +++ b/lib/core/services/auth/permission_service.dart @@ -3,14 +3,9 @@ /// 创建时间: 2026-04-23 /// 更新时间: 2026-06-26 /// 作用: 统一管理应用权限请求,支持相机/相册/通知/位置/蓝牙/附近设备/麦克风/存储/网络/剪贴板/分享/本地服务器权限 + iOS ATT授权 -/// 上次更新: 1. macOS 端权限改为动态申请(原生 MethodChannel): -/// 新增 macOS 权限名称映射(camera/microphone/photos/notification), -/// checkStatus 调用 MacosPlatformService.checkPermission 查询 TCC 状态, -/// requestPermission 调用 MacosPlatformService.requestPermission 触发系统弹窗, -/// openSettings 调用 MacosPlatformService.openPermissionSettings 跳转系统设置。 -/// 替代之前"直接返回 granted"的简化方案,让用户能在权限管理页面主动触发授权。 -/// 2. 保留 localServer 虚拟权限、isPlatformRelevant 全平台适配、 -/// MissingPluginException 兜底等既有逻辑。 +/// 上次更新: openSettings() 新增可选 permission 参数,透传权限名到原生日志(macOS), +/// 改善「权限: nil」日志可读性;调用点同步更新(_showSettingsDialog / +/// _showDeniedDialog / permission_management_page / theme_sections_style)。 /// ============================================================ import 'dart:async'; @@ -814,12 +809,16 @@ class PermissionService { /// - macOS: 通过原生 MethodChannel 打开"系统设置 > 隐私与安全性" /// - Linux: 使用 xdg-open 打开系统设置(无统一协议,尝试 gnome-control-center) /// - 其他平台: 使用 permission_handler 的 openAppSettings() - static Future openSettings() async { + /// + /// [permission] 可选,传入触发跳转的权限以丰富原生日志(仅 macOS 生效)。 + static Future openSettings([AppPermission? permission]) async { // macOS: 通过原生 MethodChannel 打开系统设置(统一跳转入口) if (pu.isMacOS) { try { - await MacosPlatformService.openPermissionSettings(null); - _log.i('打开 macOS 系统设置: 隐私与安全性'); + // 透传权限名到原生层,仅用于日志可读性(macOS 无法深链到具体权限子页) + final macosName = permission?.macosPermissionName; + await MacosPlatformService.openPermissionSettings(macosName); + _log.i('打开 macOS 系统设置: 隐私与安全性${macosName != null ? '($macosName)' : ''}'); return true; } catch (e) { _log.e('打开 macOS 系统设置失败', e); @@ -924,7 +923,7 @@ class PermissionService { child: const Text('去设置'), onPressed: () { Navigator.pop(context); - openSettings(); + openSettings(perm); }, ), ], @@ -1025,7 +1024,7 @@ class PermissionService { child: const Text('去设置'), onPressed: () { Navigator.pop(context); - openSettings(); + openSettings(perm); }, ), CupertinoDialogAction( diff --git a/lib/features/reading_report/presentation/reading_report_page.dart b/lib/features/reading_report/presentation/reading_report_page.dart index c21ab633..deddb253 100644 --- a/lib/features/reading_report/presentation/reading_report_page.dart +++ b/lib/features/reading_report/presentation/reading_report_page.dart @@ -1,16 +1,15 @@ /// ============================================================ /// 闲言APP — 使用报告主页面 /// 创建时间: 2026-05-02 -/// 更新时间: 2026-06-22 +/// 更新时间: 2026-06-26 /// 作用: 周/月/年报切换 + 摘要卡片 + 趋势图 + 热力图 + 成就回顾 -/// 上次更新: 新增 CSV 导出按钮、热力图点击查看当日详情、同比环比变化率展示 +/// 上次更新: 移除未使用的 go_router import(静态分析清理) /// ============================================================ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:go_router/go_router.dart'; import 'package:share_plus/share_plus.dart'; import '../../../core/router/app_nav_extension.dart'; diff --git a/lib/features/settings/presentation/privacy/permission_management_page.dart b/lib/features/settings/presentation/privacy/permission_management_page.dart index d3df860c..58ef2727 100644 --- a/lib/features/settings/presentation/privacy/permission_management_page.dart +++ b/lib/features/settings/presentation/privacy/permission_management_page.dart @@ -328,7 +328,7 @@ class _PermissionManagementPageState permission: p, status: statuses[p] ?? AppPermissionStatus.notDetermined, onRequest: () => _requestPermission(p), - onOpenSettings: () => PermissionService.openSettings(), + onOpenSettings: () => PermissionService.openSettings(p), perm: perm, bounceAnimation: isNotification ? _bounceAnimation : null, ), diff --git a/lib/features/settings/presentation/theme/theme_sections_style.dart b/lib/features/settings/presentation/theme/theme_sections_style.dart index b1d42c9d..d13cb661 100644 --- a/lib/features/settings/presentation/theme/theme_sections_style.dart +++ b/lib/features/settings/presentation/theme/theme_sections_style.dart @@ -990,7 +990,7 @@ class WallpaperSection extends ConsumerWidget { child: Text(t.theme.goToSettings), onPressed: () { Navigator.pop(ctx); - PermissionService.openSettings(); + PermissionService.openSettings(AppPermission.photos); }, ), ], diff --git a/pubspec.macos.yaml b/pubspec.macos.yaml index 06ece259..086f0a70 100644 --- a/pubspec.macos.yaml +++ b/pubspec.macos.yaml @@ -21,7 +21,7 @@ name: xianyan description: "闲言 — 灵感语录更纯粹。每日拾句 + 壁纸创作 APP" publish_to: 'none' -version: 6.6.25+2606260 +version: 6.6.27+2606271 # 年月日-次 7位 environment: diff --git a/pubspec.ohos.yaml b/pubspec.ohos.yaml index 2a08edb6..cfaa8131 100644 --- a/pubspec.ohos.yaml +++ b/pubspec.ohos.yaml @@ -20,7 +20,7 @@ name: xianyan description: "闲言 — 灵感语录更纯粹。每日拾句 + 壁纸创作 APP" publish_to: 'none' -version: 6.6.25+2606260 +version: 6.6.27+2606271 # 年月日-次 7位 environment: diff --git a/test/l10n/translation_coverage_test.dart b/test/l10n/translation_coverage_test.dart index 4d5ef5b7..a134019d 100644 --- a/test/l10n/translation_coverage_test.dart +++ b/test/l10n/translation_coverage_test.dart @@ -1,11 +1,13 @@ /// ============================================================ /// 闲言APP — 翻译覆盖率检测测试 /// 创建时间: 2026-05-29 -/// 更新时间: 2026-05-29 +/// 更新时间: 2026-06-26 /// 作用: CI翻译覆盖率检测,确保各语言翻译完整度 -/// 上次更新: 初始创建 +/// 上次更新: 添加 avoid_print 文件级忽略(测试诊断输出) /// ============================================================ +// ignore_for_file: avoid_print + import 'package:flutter_test/flutter_test.dart'; import 'package:xianyan/l10n/translation_coverage.dart';