feat: 新增我的报告模块,集成inappwebview支持H5详情页
1. 添加flutter_inappwebview依赖并配置各平台插件注册 2. 新增我的报告列表页、详情WebView页 3. 新增报告模块API和数据模型 4. 配置路由跳转,修复我的菜单跳转逻辑 5. 添加AGP9兼容补丁修复插件构建问题 6. 注释掉登录成功的SnackBar提示
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:new_learn/core/api/my_report/model.dart';
|
||||
import 'package:new_learn/core/network/dio_client.dart';
|
||||
|
||||
/// ============================================================
|
||||
/// 【my_report 模块接口】我的报告 —— 对标 Vue3 端 api/myReport/index.ts
|
||||
///
|
||||
/// getReportPage —— 报告列表分页(页码分页)
|
||||
/// GET /api/v1/UserReport/GetUserReportList
|
||||
/// 参数:pageIndex / pageSize / reportType(可选)
|
||||
/// ============================================================
|
||||
class UserReportApi {
|
||||
UserReportApi._();
|
||||
|
||||
static final UserReportApi instance = UserReportApi._();
|
||||
|
||||
/// 报告列表分页(页码分页:pageIndex / pageSize)
|
||||
/// [reportType] 可选筛选条件,Vue 端默认不传
|
||||
Future<UserReportPage> getReportPage({
|
||||
int pageIndex = 1,
|
||||
int pageSize = 10,
|
||||
int? reportType,
|
||||
}) async {
|
||||
final query = <String, dynamic>{
|
||||
'pageIndex': pageIndex,
|
||||
'pageSize': pageSize,
|
||||
};
|
||||
if (reportType != null) query['reportType'] = reportType;
|
||||
|
||||
final data = await DioClient.instance.get(
|
||||
'/api/v1/UserReport/GetUserReportList',
|
||||
query: query,
|
||||
);
|
||||
return UserReportPage.fromJson(data as Map<String, dynamic>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/// ============================================================
|
||||
/// 【my_report 模块模型】我的报告 —— 对标 Vue3 端 api/myReport/type.ts
|
||||
///
|
||||
/// UserReportDto(单条报告)/ UserReportPage(分页响应)
|
||||
///
|
||||
/// 字段说明:
|
||||
/// id 报告 ID(后端大整数,返回 string 类型,前端也用 String 存)
|
||||
/// reportName 报告名称(如"数学分析报告")
|
||||
/// reportType 报告类型
|
||||
/// createTime 创建时间字符串(如 "2026-08-28 15:24:39" 或 ISO "T" 分隔)
|
||||
/// reportUrl 报告详情 H5 页面 URL(点击列表项后 WebView 加载这个)
|
||||
///
|
||||
/// 序列化:手动 fromJson,做了类型兼容(后端 id 有时 string 有时 number,
|
||||
/// 统一转 String;reportUrl 清理首尾空白和反引号)。
|
||||
/// 与 my_point/model.dart 保持一致,不依赖 build_runner。
|
||||
/// ============================================================
|
||||
library;
|
||||
|
||||
/// 辅助:id 字段兼容 string / num 两种后端返回,统一转 String
|
||||
String _asStringId(dynamic value) {
|
||||
if (value == null) return '';
|
||||
if (value is String) return value.trim();
|
||||
if (value is num) return value.toInt().toString();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/// 辅助:清理 reportUrl 首尾可能的反引号 / 空白(后端可能包了一层引号)
|
||||
String _cleanUrl(String raw) {
|
||||
final cleaned = raw.trim();
|
||||
// 去掉首尾反引号(用户粘贴时可能加的,或后端真返回了)
|
||||
if (cleaned.startsWith('`') && cleaned.endsWith('`')) {
|
||||
return cleaned.substring(1, cleaned.length - 1).trim();
|
||||
}
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
/// 单条报告
|
||||
class UserReportDto {
|
||||
const UserReportDto({
|
||||
this.id = '',
|
||||
this.reportName = '',
|
||||
this.reportType = 0,
|
||||
this.createTime = '',
|
||||
this.reportUrl = '',
|
||||
});
|
||||
|
||||
final String id; // 后端大整数 ID,用 String 存避免精度丢失
|
||||
final String reportName;
|
||||
final int reportType;
|
||||
final String createTime;
|
||||
final String reportUrl;
|
||||
|
||||
factory UserReportDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserReportDto(
|
||||
id: _asStringId(json['id']),
|
||||
reportName: (json['reportName'] as String?) ?? '',
|
||||
reportType: (json['reportType'] as num?)?.toInt() ?? 0,
|
||||
createTime: (json['createTime'] as String?) ?? '',
|
||||
reportUrl: _cleanUrl((json['reportUrl'] as String?) ?? ''),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 报告分页响应
|
||||
class UserReportPage {
|
||||
const UserReportPage({
|
||||
this.data = const [],
|
||||
this.total = 0,
|
||||
this.pageIndex = 1,
|
||||
this.pageSize = 10,
|
||||
});
|
||||
|
||||
final List<UserReportDto> data;
|
||||
final int total;
|
||||
final int pageIndex;
|
||||
final int pageSize;
|
||||
|
||||
/// 兼容业务响应壳 {code, message, data: {...}}:data 存在就取 data
|
||||
factory UserReportPage.fromJson(Map<String, dynamic> json) {
|
||||
final payload = (json['data'] as Map<String, dynamic>?) ?? json;
|
||||
return UserReportPage(
|
||||
data: (payload['data'] as List<dynamic>? ?? const [])
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(UserReportDto.fromJson)
|
||||
.toList(),
|
||||
total: (payload['total'] as num?)?.toInt() ?? 0,
|
||||
pageIndex: (payload['pageIndex'] as num?)?.toInt() ?? 1,
|
||||
pageSize: (payload['pageSize'] as num?)?.toInt() ?? 10,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user