refactor: 完成v6.5.28版本迭代,修复多项体验问题

主要变更:
1. 重构多处Provider初始化逻辑,使用Future.microtask避免build阶段修改state
2. 重命名"灵感"模块为"工作流","天气诗词"改为"情景诗词"
3. 新增插件系统页面与路由,添加speech_to_text_windows插件支持
4. 优化玻璃容器性能,添加性能节流与模糊值适配
5. 新增离线横幅、阅读体验控制器、手势控制器等组件
6. 完善头像审核状态展示与缓存管理
7. 修复键盘弹出与页面路由问题
8. 更新依赖与项目配置,优化widget默认数据
This commit is contained in:
Developer
2026-05-26 01:47:47 +08:00
parent 6da28be851
commit d2bd53f3bc
120 changed files with 19882 additions and 4713 deletions

View File

@@ -1,9 +1,9 @@
// ============================================================
// ============================================================
// 闲言APP — 性能调度中心
// 创建时间: 2026-05-22
// 更新时间: 2026-05-22
// 更新时间: 2026-05-25
// 作用: 统一管理帧率节流/性能级别/电量联动/前后台切换
// 上次更新: 初始创建
// 上次更新: 增强前后台暂停 — 后台时通知所有动画停止,前台恢复
// ============================================================
import 'dart:async';
@@ -13,7 +13,6 @@ import 'package:xianyan/core/services/device/battery_info_service.dart';
import 'package:xianyan/core/storage/kv_storage.dart';
import 'package:xianyan/core/utils/logger.dart';
/// 性能级别
enum PerformanceLevel {
full('完整', 1, 1),
balanced('平衡', 2, 30),
@@ -25,14 +24,8 @@ enum PerformanceLevel {
final int targetFps;
}
/// 帧率节流回调类型 — 返回 true 表示本帧需要更新
typedef FrameThrottleCallback = bool Function();
/// 性能调度中心单例
///
/// 统一管理帧率节流、性能级别、电量联动、前后台切换。
/// 各动画组件通过注册回调感知前后台状态变化,
/// 通过 createFrameThrottle() 获取节流函数控制帧率。
class PerformanceOrchestrator {
PerformanceOrchestrator._();
static final PerformanceOrchestrator instance = PerformanceOrchestrator._();
@@ -44,6 +37,7 @@ class PerformanceOrchestrator {
StreamSubscription<BatteryInfo>? _batterySub;
final List<VoidCallback> _onForegroundCallbacks = [];
final List<VoidCallback> _onBackgroundCallbacks = [];
final List<ValueChanged<bool>> _onPauseStateChangedCallbacks = [];
PerformanceLevel get level => _level;
bool get isAppForeground => _isAppForeground;
@@ -51,7 +45,8 @@ class PerformanceOrchestrator {
bool get shouldPauseAnimations =>
!_isAppForeground || _level == PerformanceLevel.saver;
/// 初始化 — 在 main() 中调用
bool get isPaused => !_isAppForeground;
Future<void> init() async {
final stored = KvStorage.getString(_keyLevel);
_level = _resolveLevel(stored);
@@ -65,7 +60,6 @@ class PerformanceOrchestrator {
});
}
/// 设置性能级别
void setLevel(PerformanceLevel newLevel) {
if (_level == newLevel) return;
_level = newLevel;
@@ -73,44 +67,53 @@ class PerformanceOrchestrator {
Log.i('PerformanceOrchestrator: 级别切换为 ${newLevel.label}');
}
/// App 进入前台
void onAppResumed() {
if (_isAppForeground) return;
_isAppForeground = true;
Log.i('PerformanceOrchestrator: App 回到前台');
_notifyPauseState(false);
for (final cb in _onForegroundCallbacks) {
cb();
}
}
/// App 进入后台
void onAppPaused() {
if (!_isAppForeground) return;
_isAppForeground = false;
Log.i('PerformanceOrchestrator: App 进入后台');
_notifyPauseState(true);
for (final cb in _onBackgroundCallbacks) {
cb();
}
}
/// 注册前台回调
void _notifyPauseState(bool paused) {
for (final cb in _onPauseStateChangedCallbacks) {
cb(paused);
}
}
void onForeground(VoidCallback callback) {
_onForegroundCallbacks.add(callback);
}
/// 注册后台回调
void onBackground(VoidCallback callback) {
_onBackgroundCallbacks.add(callback);
}
/// 移除回调
void onPauseStateChanged(ValueChanged<bool> callback) {
_onPauseStateChangedCallbacks.add(callback);
}
void removeCallbacks(VoidCallback callback) {
_onForegroundCallbacks.remove(callback);
_onBackgroundCallbacks.remove(callback);
}
/// 创建节流帧计数器 — 返回每 N 帧触发一次的判断函数
/// full: 每1帧, balanced: 每2帧, saver: 每3帧
void removePauseStateCallback(ValueChanged<bool> callback) {
_onPauseStateChangedCallbacks.remove(callback);
}
FrameThrottleCallback createFrameThrottle() {
int frameCount = 0;
return () {
@@ -137,5 +140,6 @@ class PerformanceOrchestrator {
_batterySub?.cancel();
_onForegroundCallbacks.clear();
_onBackgroundCallbacks.clear();
_onPauseStateChangedCallbacks.clear();
}
}