feat: M1.1 完成 + M1.2 启动 — 全量更新
M1.1 收尾: - 24项 P0/P1/P2 bug 修复 (Rust 107 tests + Flutter 15 tests) - Flutter App v0.3: cupertino_icons 修复, 单元测试, 调试面板, APK 52.6MB - 示例插件完善: manifest.json + 请求/响应示范 + 7个测试 - API 文档重写 (以 routes.rs 为唯一权威) - MILESTONES.md 更新至 100% M1.2 启动: - P0: 插件管理 API 闭环 (handle_manager_message Custom 分支 + broadcast_plugin_states) - ServiceManager 集成测试 8/8 (tests/m1_2_service_manager.rs) - M1.2 测试计划 (docs/M1.2_TEST_PLAN.md, 18个E2E场景) - 动态插件系统: auto_rollback + version_manager GC + 路径穿越防护 总计: Rust 115/115 测试, Flutter 15/15 测试, 零 warning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,29 +5,36 @@ import 'package:flutter/foundation.dart';
|
||||
import '../models/player_status.dart';
|
||||
import '../services/http_api_service.dart';
|
||||
import '../services/web_socket_service.dart';
|
||||
import 'debug_provider.dart';
|
||||
|
||||
class PlayerProvider extends ChangeNotifier {
|
||||
PlayerProvider({
|
||||
required HttpApiService httpApiService,
|
||||
required WebSocketService webSocketService,
|
||||
required DebugProvider debugProvider,
|
||||
}) : _httpApiService = httpApiService,
|
||||
_webSocketService = webSocketService {
|
||||
_webSocketService = webSocketService,
|
||||
_debugProvider = debugProvider {
|
||||
_statusSubscription = _webSocketService.onStatusUpdate.listen((payload) {
|
||||
_status = PlayerStatus.fromJson(payload);
|
||||
_debugProvider.addWsLog('Player status update', details: payload);
|
||||
notifyListeners();
|
||||
});
|
||||
_stateSubscription = _webSocketService.onStateUpdate.listen((payload) {
|
||||
_currentState = payload['new_state']?.toString() ?? _currentState;
|
||||
_debugProvider.addWsLog('Player state update', details: payload);
|
||||
notifyListeners();
|
||||
});
|
||||
_configSubscription = _webSocketService.onConfigUpdate.listen((payload) {
|
||||
_updateSceneOptions(payload);
|
||||
_debugProvider.addWsLog('Player config update', details: payload);
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
final HttpApiService _httpApiService;
|
||||
final WebSocketService _webSocketService;
|
||||
final DebugProvider _debugProvider;
|
||||
late final StreamSubscription<Map<String, dynamic>> _statusSubscription;
|
||||
late final StreamSubscription<Map<String, dynamic>> _stateSubscription;
|
||||
late final StreamSubscription<Map<String, dynamic>> _configSubscription;
|
||||
@@ -48,6 +55,7 @@ class PlayerProvider extends ChangeNotifier {
|
||||
|
||||
Future<void> bootstrap() async {
|
||||
_setLoading(true);
|
||||
_debugProvider.addHttpLog('Bootstrap player provider');
|
||||
try {
|
||||
final results = await Future.wait<dynamic>([
|
||||
_httpApiService.getPlaybackStatus(),
|
||||
@@ -58,31 +66,45 @@ class PlayerProvider extends ChangeNotifier {
|
||||
_playlist = results[1] as List<String>;
|
||||
_updateSceneOptions(results[2] as Map<String, dynamic>);
|
||||
_errorMessage = null;
|
||||
_debugProvider.addHttpLog(
|
||||
'Player provider bootstrapped',
|
||||
details: <String, Object>{'playlist': _playlist.length},
|
||||
);
|
||||
} catch (error) {
|
||||
_errorMessage = error.toString();
|
||||
_debugProvider.addHttpLog('Bootstrap player provider failed', details: error);
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchStatus() async {
|
||||
_debugProvider.addHttpLog('Fetch playback status');
|
||||
try {
|
||||
_status = await _httpApiService.getPlaybackStatus();
|
||||
_errorMessage = null;
|
||||
_debugProvider.addHttpLog('Playback status fetched');
|
||||
notifyListeners();
|
||||
} catch (error) {
|
||||
_errorMessage = error.toString();
|
||||
_debugProvider.addHttpLog('Fetch playback status failed', details: error);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchPlaylist() async {
|
||||
_debugProvider.addHttpLog('Fetch playlist');
|
||||
try {
|
||||
_playlist = await _httpApiService.getPlaylist();
|
||||
_errorMessage = null;
|
||||
_debugProvider.addHttpLog(
|
||||
'Playlist fetched',
|
||||
details: <String, Object>{'items': _playlist.length},
|
||||
);
|
||||
notifyListeners();
|
||||
} catch (error) {
|
||||
_errorMessage = error.toString();
|
||||
_debugProvider.addHttpLog('Fetch playlist failed', details: error);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -119,6 +141,7 @@ class PlayerProvider extends ChangeNotifier {
|
||||
|
||||
Future<void> _runCommand(Future<dynamic> Function() action) async {
|
||||
_setLoading(true);
|
||||
_debugProvider.addHttpLog('Run player command');
|
||||
try {
|
||||
await action();
|
||||
await Future.wait<void>([
|
||||
@@ -126,8 +149,10 @@ class PlayerProvider extends ChangeNotifier {
|
||||
fetchPlaylist(),
|
||||
]);
|
||||
_errorMessage = null;
|
||||
_debugProvider.addHttpLog('Player command completed');
|
||||
} catch (error) {
|
||||
_errorMessage = error.toString();
|
||||
_debugProvider.addHttpLog('Player command failed', details: error);
|
||||
notifyListeners();
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user