import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../constant/api_const.dart'; import '../http/http_util.dart'; import '../http/model_parser.dart'; import '../model/topic_item_model.dart'; import '../util/toast_util.dart'; /// @author: bo.zeng /// @email: cnhbwds@gmail.com /// @date: 2025 2025/4/20 23:08 /// @description: class TopicDetailProvider extends Notifier { @override TopicRecordModel build() { return TopicRecordModel(); } Future fetchTopicDetail(String aid) async { var jsonData = await HttpUtil().get( apiTopicDetail, queryParameters: {"aid": aid}, //"665168438702149" ); final response = ModelParser.parseObject( jsonData, TopicRecordModel.fromJson, ); state = response; } Future fetchTopicShare({required String? contentId}) async { if (contentId == null || contentId.isEmpty) { return; } await HttpUtil().get( apiTopicShare, queryParameters: {"contentId": contentId}, ); } Future reportComment(String type, String resourceId) async { final jsonData = await HttpUtil().post( apiCommentReport, data: {"type": type, "resourceId": resourceId}, ); if (jsonData != null) { showToast("举报成功"); } } Future updateLike() async { state = state.copyWith( isLiked: state.isLiked == true ? false : true, likeNum: state.isLiked == true ? state.likeNum! - 1 : state.likeNum! + 1, ); } Future updateFavorite() async { state = state.copyWith(isFavorite: state.isFavorite == true ? false : true); } }