Template
chore: 初始化脚手架 — sunny_mochi 企业级 Flutter 模板
Core 基础设施:Flavor 三包体系、Drift+SQLCipher 加密数据库 7 拦截器 Dio 网络栈、CrashReporter 崩溃日志、Sealed Failure 错误体系 5 色板主题系统、Auth 认证骨架(Clean Architecture)、Dev Panel、Mock Adapter 通过验证:flutter analyze(0 errors)、flutter test(全绿)、staging APK 74.8MB
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:sunny_mochi/core/config/api_paths.dart';
|
||||
import 'package:sunny_mochi/core/crash/pending_crash_report.dart';
|
||||
import 'package:sunny_mochi/core/network/api_response.dart';
|
||||
import 'package:sunny_mochi/core/network/dio_client.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'crash_datasource.g.dart';
|
||||
|
||||
@riverpod
|
||||
CrashDatasource crashDatasource(Ref ref) =>
|
||||
CrashDatasource(ref.watch(dioClientProvider));
|
||||
|
||||
/// 崩溃报告上报接口。
|
||||
///
|
||||
/// **后端接口规范(待后端实现)**:
|
||||
/// ```
|
||||
/// POST /sys/crash-report
|
||||
/// Headers: satoken: <token>(可选,未登录也应接受)
|
||||
/// Body: { "kind", "error", "stackTrace", "occurredAt", "deviceModel", ... }
|
||||
/// Response: { "retCode": "00000", "retMsg": "ok", "retData": null }
|
||||
/// ```
|
||||
// TODO(backend): 实现 POST /sys/crash-report 接口(接收客户端崩溃日志)
|
||||
class CrashDatasource {
|
||||
const CrashDatasource(this._dio);
|
||||
final Dio _dio;
|
||||
|
||||
Future<void> sendCrashReport(PendingCrashReport report) async {
|
||||
final resp = await _dio.post<Map<String, dynamic>>(
|
||||
ApiPaths.crashReport,
|
||||
data: report.toJson(),
|
||||
);
|
||||
parseEnvelope(resp.data, (j) => j).unwrapVoid();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user