From 2f785d6279ac0b0367b43807ada73f24dd00d966 Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 31 Mar 2026 23:31:38 +0800 Subject: [PATCH] release --- CHANGELOG.md | 225 +++++++++++++++++- .../reports/problems/problems-report.html | 2 +- .../components/login_register_dialog.dart | 13 +- lib/views/profile/components/pop-menu.dart | 53 +++-- lib/views/profile/per_card.dart | 50 ++-- lib/views/profile/profile_page.dart | 190 ++++++++++++++- lib/views/profile/settings/app_fun.dart | 22 +- lib/views/profile/settings/offline-data.dart | 78 ++++-- lib/views/profile/settings/user-plan.dart | 4 +- .../main/resources/base/element/string.json | 4 +- .../main/resources/zh_CN/element/string.json | 2 +- 11 files changed, 549 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d08c302..f8ca4ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,222 @@ # Changelog -## 1.0.1 +All notable changes to this project will be documented in this file. -### Added -- 添加了支持 OpenHarmony 平台的 wakelock_plus 库 -- 依赖版本:wakelock_plus (git: https://gitcode.com/openharmony-sig/fluttertpc_wakelock_plus.git, ref: br_v1.4.0_ohos) +--- -## 1.0.0 +## [1.3.10] - 2026-03-31 -### Initial Release -- 项目初始化 -- 基础功能实现 \ No newline at end of file +### 新增 +- 💡 **屏幕常亮功能** + - 在个人设置页面添加了屏幕常亮开关 + - 实现了开关状态的管理 + - 添加了 OLED 屏幕提示对话框,告知用户可能的屏幕老化风险 + - 支持 OpenHarmony 平台 + - 涉及文件: + - `lib/views/profile/profile_page.dart` - 添加屏幕常亮开关和功能实现 + +### 变更 +- 📱 **修改弹出菜单按钮** + - 将弹出菜单中的 "设置" 按钮修改为 "取消" 按钮 + - 将 "退出软件" 按钮修改为 "返回桌面" 按钮 + - 优化了 "刷新数据" 按钮功能,点击时会刷新所有统计数据 + - 涉及文件: + - `lib/views/profile/components/pop-menu.dart` - 修改弹出菜单项 + +### 修复 +- 优化了屏幕常亮功能的错误处理 +- 增强了平台检测和日志输出 +- 为不支持屏幕常亮的设备添加了专门的错误提示 +- 🐛 **修复昵称修改不生效问题** + - 修复了点击确认图标后昵称没有保存的问题 + - 确保在编辑模式下点击确认图标时正确保存昵称到 `widget.userData['nickname']` + - 涉及文件: + - `lib/views/profile/per_card.dart` - 修复昵称保存逻辑 +- ⚙️ **更新重置设置默认值** + - 自动刷新:关闭 + - 调试信息:关闭 + - 预加载:开启 + - 隐藏次要按钮:关闭 + - 声音反馈:关闭 + - 震动反馈:开启 + - 全局Tips:开启 + - 涉及文件: + - `lib/views/profile/settings/app_fun.dart` - 更新重置设置逻辑 +- 🎨 **优化离线数据页面温馨提示卡片** + - 增加了字体大小,使关键信息更明显 + - 调整了间距,使布局更清晰 + - 优化了开启离线状态的方法说明,使其更易理解 + - 涉及文件: + - `lib/views/profile/settings/offline-data.dart` - 优化温馨提示卡片 +- 🎨 **优化屏幕常亮提示弹窗** + - 增加了圆角边框,提升视觉效果 + - 添加了图标和标题,使弹窗更美观 + - 优化了提示内容的布局和格式,使信息更清晰 + - 调整了按钮样式,增强视觉层次感 + - 涉及文件: + - `lib/views/profile/profile_page.dart` - 优化屏幕常亮提示弹窗 +- 🎨 **优化登录注册对话框** + - 在标题下方添加了副标题,说明微信号、手机号或邮箱都可以作为投票凭证 + - 涉及文件: + - `lib/views/profile/components/login_register_dialog.dart` - 添加副标题 +- 🎨 **优化个人卡片显示** + - 删除了等级显示,只保留 UEP 标识(如果用户加入了用户体验计划) + - 涉及文件: + - `lib/views/profile/per_card.dart` - 删除等级显示,优化 UEP 标识显示 + +--- + +## [1.3.9] - 2026-03-31 + +### 新增 +- 🆔 **UDID 设备信息显示** + - 在应用信息页面的设备信息列表中添加 UDID 显示 + - 使用 `flutter_udid` 库获取跨平台设备唯一标识 + - 支持点击复制 UDID 功能,带主题色 SnackBar 提示 + - 将 AppInfoPage 从 StatelessWidget 改为 StatefulWidget + - 添加 `_loadUdid()` 方法异步加载 UDID + - 在技术栈卡片中添加 flutter_udid 说明 + - 在开源协议对话框中添加 flutter_udid 条目 + - 涉及文件: + - `lib/views/profile/app-info.dart` - 添加 UDID 获取和显示 + +### 升级 +- 📦 **flutter_udid 库升级至 4.1.2** + - 升级本地 flutter_udid 包到最新版本 4.1.2 + - Android 平台:更新 Gradle 到 8.5.0,Kotlin 到 2.0.21,使用新的 FlutterPlugin API + - iOS 平台:替换 SAMKeychain 为 KeychainAccess,支持 iOS 13.0+ + - MacOS 平台:使用 KeychainAccess 和 IOKit 获取硬件 UUID + - HarmonyOS 平台:保持 3.0.0 版本,使用 OAID 获取设备标识 + - 解决 Gradle 依赖冲突(jcenter 废弃问题) + - 统一 JVM 目标版本为 17 + - 涉及文件: + - `packages/flutter_udid/pubspec.yaml` - 更新版本和平台配置 + - `packages/flutter_udid/android/build.gradle` - 更新 Gradle 和 Kotlin 版本 + - `packages/flutter_udid/android/src/main/kotlin/.../FlutterUdidPlugin.kt` - 更新插件 API + - `packages/flutter_udid/ios/flutter_udid.podspec` - 更新依赖和部署目标 + - `packages/flutter_udid/ios/Classes/SwiftFlutterUdidPlugin.swift` - 更新 KeychainAccess + - `packages/flutter_udid/macos/Classes/FlutterUdidPlugin.swift` - 更新实现 + +### 新增 +- 👥 **QQ 交流群卡片** + - 在了解我们页面的"官方网站"卡片下方添加 QQ 群卡片 + - 群号显示:271129018 + - 点击群号可复制到剪贴板 + - 蓝色主题色(Icons.group) + - 提示"💡 点击群号可复制" + - 涉及文件: + - `lib/views/profile/settings/learn-us.dart` - 添加 QQ 群卡片 + +--- + +## [1.3.8] - 2026-03-31 + +### 新增 +- 🎛️ **隐藏次要按钮功能** + - 在功能设置页面添加"隐藏次要按钮"开关 + - 开启后隐藏主页的"上一条"和"分享"悬浮按钮 + - 默认关闭,状态保存到 SharedPreferences + - 使用 `SecondaryButtonsManager` 单例管理状态 + - 实时响应开关状态变化,无需重启应用 + - 涉及文件: + - `lib/views/profile/settings/app_fun.dart` - 添加开关和状态管理 + - `lib/views/home/home-load.dart` - 添加 SecondaryButtonsManager 管理类 + - `lib/views/home/home_page.dart` - 使用 ValueListenableBuilder 监听状态变化 + +--- + +## [1.3.7] - 2026-03-31 + +### 新增 +- 📸 **诗词卡片截图分享功能** + - 在主页点赞按钮上方添加悬浮分享按钮,使用 📤 icon + - 点击按钮可将当前诗词卡片生成高清图片并分享 + - 使用 `RepaintBoundary` 和 `GlobalKey` 实现 Widget 截图 + - 集成 `share_plus` 库实现跨平台图片分享 + - 包含生成中、成功、失败的用户提示 + - 涉及文件: + - `lib/views/home/home_components.dart` - 添加 ShareImageUtils 工具类和 FloatingShareButton 组件 + - `lib/views/home/home_page.dart` - 添加截图 Key 和分享按钮布局 + - `lib/views/home/home_part.dart` - 添加 RepaintBoundary 支持截图 + +--- + +## [1.3.6] - 2026-03-31 + +### 优化 +- 🏷️ **文件重命名与统一** + - 将 `sqlite_storage_controller.dart` 重命名为 `shared_preferences_storage_controller.dart` + - 将类名 `SQLiteStorageController` 重命名为 `SharedPreferencesStorageController` + - 更新所有引用该文件的导入语句和类名调用 + - 涉及文件: + - `lib/main.dart` + - `lib/controllers/history_controller.dart` + - `lib/views/profile/profile_page.dart` + - `lib/views/profile/level/poetry.dart` + - `lib/views/profile/level/distinguish.dart` + - 保持功能不变,仅统一命名规范 + +--- + +## [1.3.5] - 2026-03-30 + +### 新增 +- 📜 **投稿记录功能** + - 新增投稿记录页面 `lib/views/profile/expand/tougao.dart` + - 显示历史投稿记录列表,按时间倒序排列 + - 支持展开查看详细信息(分类、诗人和标题、关键词、平台、介绍) + - 提供清空所有记录功能(带确认提示) + - 修改 `lib/views/profile/expand/manu-script.dart` + - 在AppBar添加历史记录图标按钮,点击跳转至记录页面 + - 投稿成功后自动保存记录到SharedPreferences + - 最多保存50条记录,超出时自动删除最早的记录 + +--- + +## 软件特性功能 + +### 已开发完成 +- 🎛️ **隐藏次要按钮功能** - 在功能设置页面添加开关、开启后隐藏主页的"上一条"和"分享"悬浮按钮、默认关闭、状态保存到SharedPreferences、使用SecondaryButtonsManager单例管理、实时响应开关状态变化无需重启 + - 优先级:3 +- 📸 **诗词卡片截图分享功能** - 主页点赞按钮上方添加悬浮分享按钮、点击生成诗词卡片高清图片并分享、使用RepaintBoundary和GlobalKey实现Widget截图、集成share_plus库实现跨平台分享、包含生成中/成功/失败提示 + - 优先级:4 +- 📜 **诗词投稿功能** - 新增投稿页面、支持诗词收录申请表单、包含参考语句/分类选择/诗人和标题/关键词/诗词介绍/人机验证、实现相似度检测防止重复提交、平台字段自动获取设备类型 + - 优先级:3 +- ⚡ **离线数据下载优化** - 添加取消下载功能、下载过程中显示取消按钮、优化下载状态显示避免页面卡死、取消下载时显示相应提示 + - 优先级:4 +- 🌐 **网络状态自动检测** - 个人卡片加载时自动检测网络状态、无网络时自动调整为离线状态、避免网络异常导致的错误 + - 优先级:3 +- 📊 **服务器信息显示** - 在离线数据页面添加服务器信息卡片、显示API地址/版本/频率限制等信息 + - 优先级:2 +- 📱 **离线数据下载功能增强** - 新增下载类型选择(诗句和答题)、诗句数量选项(20/30/60/100条)、答题数量选项(20/50/80/100条)、100条下载需加入用户体验计划、实现下载一条写入一条、取消下载时保存已下载数据、实时更新缓存状态、返回上一页继续后台下载、清空缓存时弹窗选择清空内容、缓存状态同时显示诗句和答题数量 + - 优先级:5 +- �� **已知bug列表功能** - 从下到上弹出页面显示已知bug、解决方法和解决时间、支持下拉刷新和滚动查看、显示bug优先级和状态、提供详细解决方案描述、显示影响用户范围和时间信息 +- 📜 **投稿记录功能** - 投稿记录页面显示历史投稿列表、按时间倒序排列、支持展开查看详细信息、提供清空记录功能、投稿成功后自动保存到SharedPreferences、最多保存50条记录 +- 🗳️ **投票功能完整实现** - 用户登录/注册、获取投票列表、投票详情、提交投票、投票结果展示、API服务基础URL修改、登录注册逻辑简化(只需用户名、默认密码123456、自动注册登录、设备标识)、投票页面调试功能、user_identifier增加Flutter后缀、setState调用安全修复(添加mounted检查)、投票登录状态持久化修复(添加Cookie管理器支持PHP Session认证) +- 🎨 **个人卡片标签栏布局优化** - 将标签栏区域一分为二,左侧区域可以点击展开/收起个人卡片 +- 🎲 **题目随机化功能** - 进入答题页面时调用 fetch 接口获取新题,使用 Fisher-Yates 算法打乱题目 ID 顺序 +- 💬 **答对答错反馈信息修复** - 当 API 返回的提示信息为空时,自行添加提示内容 +- 📚 **App 自行管理题目 ID** - 实现题目 ID 管理逻辑,不再随机生成 +- 🔧 **API 接口路径和参数最终修复** - 确认 API 路径,调整随机题目 ID 范围 +- 🔧 **API 接口路径和参数修复** - 修复 API 路径和参数,使用正确的新 API 接口 +- 🐛 **HttpResponse 处理修复** - 修复 HttpResponse 对象处理方式,使用正确的属性访问 +- 🔧 **API 请求参数更新** - 根据新的 API 文档更新所有请求参数 +- 📊 **个人页面统计数字动态化** - 从SharedPreferences读取真实的答题统计数据 +- 📝 **记录页显示问题修复** - 修复答题记录页面显示未知题目和标签的问题 +- 📋 **答题统计弹窗功能** - 显示详细的答题统计数据,支持复制发送给AI评估 +- 📝 **诗词答题功能** - 完整的答题页面,支持题目加载、答案提交、提示获取 +- 🕐 **中国十二时辰制时间显示** - 时间显示改为十二时辰(子丑寅卯辰巳午未申酉戌亥) +- 🌤️ **天气功能集成** - 集成天气API获取城市、天气状态和温度 +- 📚 **朝代信息显示** - 在诗人名称左侧添加朝代信息显示 +- 🎨 **卡片样式优化** - 经典和现代样式颜色统一,毛玻璃样式优化 +- 🐛 **卡片设置页面重复打开问题修复** - 使用 router.replaceUrl 替换当前页面,避免堆叠 +- 📐 **2x2卡片布局优化** - 移除天气按钮组件,保留城市名称显示 +- 🌐 **离线模式支持** - 新增 `OfflineDataManager` 类管理离线数据加载、离线状态时从本地缓存加载诗句、在线状态时从网络加载、支持循环加载本地缓存的诗句、离线模式下隐藏点赞按钮、无缓存时显示网络错误提示、优化数据加载逻辑 +- 🔄 **个人卡片在线/离线状态切换** - 在个人卡片tips卡片内添加在线状态开关、开关状态保存到SharedPreferences、关闭后切换为离线状态、支持点击tips卡片切换祝福语功能、优化开关布局、状态切换时显示气泡消息提示 + +### 开发进度 +- 🏗️ **HarmonyOS桌面小组件** - 开发中,包含2x2布局、天气显示、诗句展示等功能 + - 优先级:3 +getx 加入 +二维码能力 +HarmonyOS HongMeng Kernel \ No newline at end of file diff --git a/android/build/reports/problems/problems-report.html b/android/build/reports/problems/problems-report.html index 98c83f2..d2ad863 100644 --- a/android/build/reports/problems/problems-report.html +++ b/android/build/reports/problems/problems-report.html @@ -650,7 +650,7 @@ code + .copy-button { diff --git a/lib/views/profile/components/login_register_dialog.dart b/lib/views/profile/components/login_register_dialog.dart index 929f18e..ef65b44 100644 --- a/lib/views/profile/components/login_register_dialog.dart +++ b/lib/views/profile/components/login_register_dialog.dart @@ -118,7 +118,7 @@ class _LoginRegisterDialogState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( - '填写投票凭证', + '填写 投票凭证', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), IconButton( @@ -127,7 +127,14 @@ class _LoginRegisterDialogState extends State { ), ], ), - const SizedBox(height: 20), + // const SizedBox(height: 8), + // 副标题 + const Text( + '微信号或手机号或邮箱作为投票凭证,\n任何人都可以填写,限时开放投票,\n投票凭证仅用于投票,不会泄露隐私.\n结束后删除会所有凭证,仅保留投票结果', + style: TextStyle(fontSize: 14, color: Colors.grey), + textAlign: TextAlign.center, + ), + const SizedBox(height: 2), Form( key: _formKey, child: Column( @@ -135,7 +142,7 @@ class _LoginRegisterDialogState extends State { TextFormField( controller: _usernameController, decoration: const InputDecoration( - labelText: '投票凭证', + labelText: '点击填写', hintText: '手机号/邮箱/微信号', border: OutlineInputBorder(), prefixIcon: Icon(Icons.person), diff --git a/lib/views/profile/components/pop-menu.dart b/lib/views/profile/components/pop-menu.dart index b6886ae..4432594 100644 --- a/lib/views/profile/components/pop-menu.dart +++ b/lib/views/profile/components/pop-menu.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import 'package:share_plus/share_plus.dart'; import '../../../constants/app_constants.dart'; import 'package:wakelock_plus/wakelock_plus.dart'; +import 'dart:io' as io; class PopMenu extends StatelessWidget { final VoidCallback? onRefresh; @@ -44,32 +45,38 @@ class PopMenu extends StatelessWidget { static Future toggleScreenWake(BuildContext context) async { try { - // 检查当前状态 - final bool isEnabled = await WakelockPlus.enabled; + // 使用 io.Platform 检测平台 + final String osName = io.Platform.operatingSystem; + final String osVersion = io.Platform.operatingSystemVersion; + print('Current platform: $osName, version: $osVersion'); + + // 直接尝试启用屏幕常亮 + await WakelockPlus.enable(); - // 切换状态 - if (isEnabled) { - await WakelockPlus.disable(); - if (context.mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('屏幕常亮已关闭'))); - } - } else { - await WakelockPlus.enable(); - if (context.mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('屏幕常亮已开启'))); - } - } - } catch (e) { if (context.mounted) { + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('屏幕常亮已开启'))); + } + } catch (e, stackTrace) { + print('WakelockPlus error: $e'); + print('Stack trace: $stackTrace'); + if (context.mounted) { + // 检查错误类型,判断是否是设备不支持 + String errorMessage; + if (e.toString().contains('not supported') || + e.toString().contains('unsupported') || + e.toString().contains('不支持')) { + errorMessage = '该设备不支持屏幕常亮功能'; + } else { + errorMessage = '屏幕常亮功能异常: $e'; + } + showDialog( context: context, builder: (context) => AlertDialog( title: const Text('提示'), - content: const Text('该设备不支持屏幕常亮功能'), + content: Text(errorMessage), actions: [ TextButton( onPressed: () => Navigator.pop(context), @@ -134,9 +141,11 @@ class PopMenu extends StatelessWidget { Icons.screen_lock_rotation, () => toggleScreenWake(context), ), - _buildBottomSheetItem(context, '夜间模式', Icons.dark_mode, onDarkMode), + _buildBottomSheetItem(context, '取消', Icons.settings, onSettings), const SizedBox(height: 20), - _buildBottomSheetItem(context, '设置', Icons.settings, onSettings), + _buildBottomSheetItem(context, '返回桌面', Icons.exit_to_app, () { + SystemNavigator.pop(); + }), ], ), ); diff --git a/lib/views/profile/per_card.dart b/lib/views/profile/per_card.dart index 89ce7df..1c1824c 100644 --- a/lib/views/profile/per_card.dart +++ b/lib/views/profile/per_card.dart @@ -39,6 +39,7 @@ class PersonalCardState extends State { late String _currentTip; bool _isOnline = true; bool _isEditingNickname = false; + bool _isUserPlanJoined = false; late TextEditingController _nicknameController; // 累计数据 @@ -55,6 +56,7 @@ class PersonalCardState extends State { text: widget.userData['nickname'] ?? '诗词爱好者', ); _loadOnlineStatus(); + _loadUserPlanStatus(); _loadTotalStats(); } @@ -78,6 +80,7 @@ class PersonalCardState extends State { // 刷新数据(公共方法,供外部调用) Future refreshData() async { await _loadTotalStats(); + await _loadUserPlanStatus(); } Future _loadOnlineStatus() async { @@ -101,6 +104,13 @@ class PersonalCardState extends State { }); } + Future _loadUserPlanStatus() async { + final prefs = await SharedPreferences.getInstance(); + setState(() { + _isUserPlanJoined = prefs.getBool('user_plan_joined') ?? false; + }); + } + Future _toggleOnlineStatus() async { // 如果当前是离线状态,要切换到在线状态,需要先检测网络 if (!_isOnline) { @@ -502,11 +512,16 @@ class PersonalCardState extends State { GestureDetector( onTap: () { setState(() { - _isEditingNickname = !_isEditingNickname; if (_isEditingNickname) { + // 保存昵称 + widget.userData['nickname'] = + _nicknameController.text; + } else { + // 进入编辑模式,初始化文本 _nicknameController.text = widget.userData['nickname'] ?? '诗词爱好者'; } + _isEditingNickname = !_isEditingNickname; }); }, child: Icon( @@ -516,24 +531,25 @@ class PersonalCardState extends State { ), ), const SizedBox(width: 8), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 2, - ), - decoration: BoxDecoration( - color: Colors.white.withOpacity(0.2), - borderRadius: BorderRadius.circular(12), - ), - child: Text( - widget.userData['level'] ?? 'Lv.1', - style: const TextStyle( - color: Colors.white, - fontSize: 12, - fontWeight: FontWeight.w500, + if (_isUserPlanJoined) + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 2, + ), + decoration: BoxDecoration( + color: Colors.amber.withOpacity(0.8), + borderRadius: BorderRadius.circular(12), + ), + child: const Text( + 'UEP', + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.bold, + ), ), ), - ), ], ), const SizedBox(height: 4), diff --git a/lib/views/profile/profile_page.dart b/lib/views/profile/profile_page.dart index 1b3b097..2e023de 100644 --- a/lib/views/profile/profile_page.dart +++ b/lib/views/profile/profile_page.dart @@ -5,9 +5,11 @@ import 'dart:convert'; import 'dart:math' show Random; +import 'dart:io' as io; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; import '../../constants/app_constants.dart'; import '../../controllers/history_controller.dart'; @@ -44,6 +46,7 @@ class _ProfilePageState extends State int _currentPage = 1; // 默认显示第2页(设置) bool _isCardExpanded = false; // 个人卡片展开状态 bool _isStatsHidden = false; // 统计数据隐藏状态 + bool _isScreenWakeEnabled = false; // 屏幕常亮状态 double _startY = 0.0; // 历史记录相关 List> _poetryHistory = []; @@ -409,7 +412,7 @@ class _ProfilePageState extends State if (!_isStatsHidden) ...[ _buildInfoItem('今日浏览', '$_todayViews 条'), _buildInfoItem('本周浏览', '$_weekViews 条'), - _buildInfoItem('天数', '$_useDays 天'), + _buildInfoItem('已用', '$_useDays 天'), _buildInfoItem('数据', _dataSize), _buildInfoItem('笔记', '$_noteCount 个'), _buildInfoItem('今日答题', '$_todayQuestions 题'), @@ -521,6 +524,12 @@ class _ProfilePageState extends State children: [ // === 账户设置组 === _buildSettingsGroup('软件设置', [ + _buildSettingsItem( + '功能设置', + Icons.verified_user, + () => _navigateToAppFunSettings(), + ), + _buildSettingsItem( '离线使用', Icons.volunteer_activism, @@ -531,11 +540,7 @@ class _ProfilePageState extends State Icons.history, () => _navigateToHistoryPage(), ), - _buildSettingsItem( - '功能设置', - Icons.verified_user, - () => _navigateToAppFunSettings(), - ), + _buildSettingsItem( '主题风格', Icons.palette, @@ -580,11 +585,7 @@ class _ProfilePageState extends State Icons.cleaning_services, () => showBugListBottomSheet(context), ), - _buildSettingsItem( - '关闭退出', - Icons.palette, - () => _showSnackBar('重启 关闭?'), - ), + _buildScreenWakeItem(), ]), ], ); @@ -800,6 +801,173 @@ class _ProfilePageState extends State ); } + Widget _buildScreenWakeItem() { + // === 屏幕常亮设置项:显示图标、标题和开关 === + return ListTile( + leading: Icon( + Icons.screen_lock_rotation, + color: AppConstants.primaryColor, + size: 20, + ), + title: Text( + '屏幕常亮', + style: const TextStyle(fontSize: 14, color: Colors.black87), + ), + trailing: Switch( + value: _isScreenWakeEnabled, + onChanged: (value) async { + if (value) { + // 显示提示对话框 + showDialog( + context: context, + builder: (context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + title: Row( + children: [ + Icon( + Icons.info_outline, + color: AppConstants.primaryColor, + size: 20, + ), + const SizedBox(width: 8), + const Text( + '屏幕常亮提示', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 8), + Text( + '⚠️ 注意事项', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w500, + color: Colors.orange[600], + ), + ), + const SizedBox(height: 8), + Text( + '• OLED屏幕长时间显示相同内容可能会造成不可逆老化', + style: const TextStyle( + fontSize: 14, + color: Colors.black87, + ), + ), + const SizedBox(height: 6), + Text( + '• 开启常亮后,配合自动刷新内容的设置,实现常亮自动加载诗句', + style: const TextStyle( + fontSize: 14, + color: Colors.black87, + ), + ), + const SizedBox(height: 6), + Text( + '• 挂起常亮后,需保持该软件在屏幕中显示,记得关闭常亮哦!', + style: const TextStyle( + fontSize: 14, + color: Colors.black87, + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + style: TextButton.styleFrom( + foregroundColor: Colors.grey[600], + ), + child: const Text('取消'), + ), + TextButton( + onPressed: () async { + Navigator.pop(context); + await _toggleScreenWake(true); + }, + style: TextButton.styleFrom( + foregroundColor: AppConstants.primaryColor, + textStyle: const TextStyle(fontWeight: FontWeight.bold), + ), + child: const Text('确定'), + ), + ], + ), + ); + } else { + await _toggleScreenWake(false); + } + }, + activeColor: AppConstants.primaryColor, + ), + ); + } + + Future _toggleScreenWake(bool enable) async { + try { + // 使用 io.Platform 检测平台 + final String osName = io.Platform.operatingSystem; + final String osVersion = io.Platform.operatingSystemVersion; + print('Current platform: $osName, version: $osVersion'); + + if (enable) { + await WakelockPlus.enable(); + if (mounted) { + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('屏幕常亮已开启'))); + } + } else { + await WakelockPlus.disable(); + if (mounted) { + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('屏幕常亮已关闭'))); + } + } + + setState(() { + _isScreenWakeEnabled = enable; + }); + } catch (e, stackTrace) { + print('WakelockPlus error: $e'); + print('Stack trace: $stackTrace'); + if (mounted) { + // 检查错误类型,判断是否是设备不支持 + String errorMessage; + if (e.toString().contains('not supported') || + e.toString().contains('unsupported') || + e.toString().contains('不支持')) { + errorMessage = '该设备不支持屏幕常亮功能'; + } else { + errorMessage = '屏幕常亮功能异常: $e'; + } + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('提示'), + content: Text(errorMessage), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('确定'), + ), + ], + ), + ); + } + } + } + Widget _buildInteractionItem(String label, String value) { // === 互动统计项:显示标签和数值 === return Expanded( diff --git a/lib/views/profile/settings/app_fun.dart b/lib/views/profile/settings/app_fun.dart index a6430d1..9eea6f2 100644 --- a/lib/views/profile/settings/app_fun.dart +++ b/lib/views/profile/settings/app_fun.dart @@ -561,12 +561,19 @@ class _AppFunSettingsPageState extends State { TextButton( onPressed: () async { Navigator.of(context).pop(); - await _setAutoRefresh(false); - await _setDebugInfo(false); + // 重置所有设置为默认值 + await _setAutoRefresh(false); // 自动刷新:关闭 + await _setDebugInfo(false); // 调试信息:关闭 + await _setPreload(true); // 预加载:开启 + await _setHideSecondaryButtons(false); // 隐藏次要按钮:关闭 + await _setSoundEnabled(false); // 声音反馈:关闭 + // 全局Tips:开启 + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool(_globalTipsKey, true); + // 震动反馈:开启(不需要保存到SharedPreferences,直接更新状态) setState(() { - _soundEnabled = true; _vibrationEnabled = true; - _globalTipsEnabled = true; // 重置全局Tips开关为开启 + _globalTipsEnabled = true; // 全局Tips:开启 }); _showSnackBar('已恢复默认设置'); }, @@ -577,3 +584,10 @@ class _AppFunSettingsPageState extends State { ); } } +// - 自动刷新:关闭 +// - 调试信息:关闭 +// - 预加载:开启 +// - 隐藏次要按钮:关闭 +// - 声音反馈:关闭 +// - 震动反馈:开启 +// - 全局Tips:开启 \ No newline at end of file diff --git a/lib/views/profile/settings/offline-data.dart b/lib/views/profile/settings/offline-data.dart index 590623d..2619419 100644 --- a/lib/views/profile/settings/offline-data.dart +++ b/lib/views/profile/settings/offline-data.dart @@ -902,38 +902,70 @@ class _OfflineDataPageState extends State { children: [ Row( children: [ - Icon(Icons.info_outline, color: Colors.blue[600], size: 16), + Icon(Icons.info_outline, color: Colors.blue[600], size: 20), const SizedBox(width: 8), Text( '温馨提示', style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, + fontSize: 16, + fontWeight: FontWeight.bold, color: Colors.blue[600], ), ), ], ), - const SizedBox(height: 8), - const Text( - '• 开启离线模式后,将会循环加载本地的数据源', - style: TextStyle(fontSize: 12, color: Colors.grey), - ), - const Text( - '• 下载的数据将保存在本地,可在无网络时使用', - style: TextStyle(fontSize: 12, color: Colors.grey), - ), - const Text( - '• 下载过程中请保持网络连接', - style: TextStyle(fontSize: 12, color: Colors.grey), - ), - const Text( - '• 缓存数据不会写入历史记录', - style: TextStyle(fontSize: 12, color: Colors.grey), - ), - const Text( - '• 建议在WiFi环境下下载较多数据', - style: TextStyle(fontSize: 12, color: Colors.grey), + const SizedBox(height: 12), + Padding( + padding: const EdgeInsets.only(left: 4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '• 数据下载后 需手动开启离线状态', + style: TextStyle( + fontSize: 14, + color: Colors.grey[700], + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 4), + Padding( + padding: const EdgeInsets.only(left: 20), + child: Text( + '方法:个人 → 下拉 点击头像下面关闭按钮 头像显示离线', + style: TextStyle( + fontSize: 13, + color: Colors.grey[600], + ), + ), + ), + const SizedBox(height: 8), + Text( + '• 开启离线模式后,将会循环加载本地的数据源', + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + const SizedBox(height: 8), + Text( + '• 下载的数据将保存在本地,可在无网络时使用', + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + const SizedBox(height: 8), + Text( + '• 下载过程中请保持网络连接', + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + const SizedBox(height: 8), + Text( + '• 缓存数据不会写入历史记录', + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + const SizedBox(height: 8), + Text( + '• 建议在WiFi环境下下载较多数据', + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + ], + ), ), ], ), diff --git a/lib/views/profile/settings/user-plan.dart b/lib/views/profile/settings/user-plan.dart index 3fa4e91..cb5517c 100644 --- a/lib/views/profile/settings/user-plan.dart +++ b/lib/views/profile/settings/user-plan.dart @@ -409,8 +409,8 @@ class _UserPlanPageState extends State { {'icon': Icons.how_to_vote, 'title': '参与投票', 'desc': '对产品功能进行投票'}, {'icon': Icons.bar_chart, 'title': '查看统计数据', 'desc': '查看全站使用统计'}, {'icon': Icons.edit_note, 'title': '开放投稿', 'desc': '投稿您的诗词作品'}, - {'icon': Icons.science, 'title': '体验Beta功能', 'desc': '抢先体验新功能'}, - {'icon': Icons.bug_report, 'title': '软件内测版', 'desc': '参与内测版本体验'}, + {'icon': Icons.science, 'title': '体验Beta功能', 'desc': '内测版本抢先体验'}, + {'icon': Icons.bug_report, 'title': '刷新次数', 'desc': '获得更多api调用次数'}, {'icon': Icons.card_giftcard, 'title': '专属显示', 'desc': '获得不同的显示效果'}, ]; diff --git a/ohos/entry/src/main/resources/base/element/string.json b/ohos/entry/src/main/resources/base/element/string.json index 20c0b6e..6678ce1 100644 --- a/ohos/entry/src/main/resources/base/element/string.json +++ b/ohos/entry/src/main/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "module_desc", - "value": "📜 诗词卡片" + "value": "情景诗词" }, { "name": "EntryAbility_desc", @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "📜 诗词卡片" + "value": "情景诗词" }, { "name": "WidgetFormAbility_desc", diff --git a/ohos/entry/src/main/resources/zh_CN/element/string.json b/ohos/entry/src/main/resources/zh_CN/element/string.json index 631d9fe..6b0f18d 100644 --- a/ohos/entry/src/main/resources/zh_CN/element/string.json +++ b/ohos/entry/src/main/resources/zh_CN/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "📜 诗词卡片" + "value": "情景诗词" }, { "name": "WidgetFormAbility_desc",