feat:增加查询朋友朋友圈功能

This commit is contained in:
2025-11-25 19:16:53 +08:00
parent 8cff5228ae
commit ed0ceb29d3
10 changed files with 374 additions and 135 deletions

View File

@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
class AppProvider with ChangeNotifier {
String appVersion = '1.0.0';
String buildNumber = '1';
String get fullVersion => '$appVersion+$buildNumber';
}

View File

@@ -1,11 +1,14 @@
import 'package:flutter/material.dart';
import 'package:food_hub_app/apis/moment.dart';
import 'package:food_hub_app/apis/user.dart';
import 'package:food_hub_app/models/moment.dart';
import 'package:food_hub_app/models/session.dart';
class UserProvider with ChangeNotifier {
late User currentUser = User.getEmpty();
bool isLoading = false;
String error = '';
List<Moment> momentList = [];
Future<void> refreshUser(int id) async {
if (isLoading) return;
@@ -25,4 +28,24 @@ class UserProvider with ChangeNotifier {
notifyListeners();
}
}
Future<void> queryMomentByUserId(int userId) async {
if (isLoading) return;
try {
isLoading = true;
error = '';
notifyListeners();
final result = await queryMomentListByUserIdApi(userId);
momentList = result;
notifyListeners();
} catch (e) {
error = '加载数据失败: $e';
debugPrint('加载数据失败: $e');
} finally {
isLoading = false;
notifyListeners();
}
}
}