mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-14 04:13:43 +00:00
cgo invoke params
This commit is contained in:
1 parent
4b4c03fd90
commit
63296f6950
5 files changed
+29
-36
No files matched your search
@@ -62,14 +62,7 @@ class LibgopeedBootNative
|
||||
List<dynamic> params,
|
||||
T Function(dynamic json)? fromJsonT,
|
||||
) async {
|
||||
final invokeRequest = InvokeRequest(
|
||||
method: method,
|
||||
params: params.map((e) {
|
||||
if (e.toJson != null) {
|
||||
return jsonEncode(e.toJson());
|
||||
}
|
||||
return jsonEncode(e);
|
||||
}).toList());
|
||||
final invokeRequest = InvokeRequest(method: method, params: params);
|
||||
final resp = await _libgopeedAbi.invoke(jsonEncode(invokeRequest));
|
||||
final result =
|
||||
Result<T>.fromJson(jsonDecode(resp), fromJsonT ??= (json) => null as T);
|
||||
@@ -172,7 +165,7 @@ class LibgopeedBootNative
|
||||
@override
|
||||
Future<List<Task>> getTasks(TaskFilter? filter) async {
|
||||
return _invoke<List<Task>>("GetTasks", _parseTaskFilter(filter),
|
||||
(json) => json.map((e) => Task.fromJson(e)).toList());
|
||||
(json) => (json as List).map((e) => Task.fromJson(e)).toList());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -200,7 +193,7 @@ class LibgopeedBootNative
|
||||
@override
|
||||
Future<List<Extension>> getExtensions() async {
|
||||
return _invoke<List<Extension>>("GetExtensions", [],
|
||||
(json) => json.map((e) => Extension.fromJson(e)).toList());
|
||||
(json) => (json as List).map((e) => Extension.fromJson(e)).toList());
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -125,8 +125,7 @@ class LibgopeedBootWeb
|
||||
|
||||
@override
|
||||
Future<void> pauseTask(String id) async {
|
||||
await _fetch<void>(
|
||||
() => _dio.put("$_apiPrefix/tasks/$id/pause", data: {}), null);
|
||||
await _fetch<void>(() => _dio.put("$_apiPrefix/tasks/$id/pause"), null);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -139,8 +138,7 @@ class LibgopeedBootWeb
|
||||
|
||||
@override
|
||||
Future<void> continueTask(String id) async {
|
||||
await _fetch<void>(
|
||||
() => _dio.put("$_apiPrefix/tasks/$id/continue", data: {}), null);
|
||||
await _fetch<void>(() => _dio.put("$_apiPrefix/tasks/$id/continue"), null);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,7 +5,7 @@ part 'invoke_request.g.dart';
|
||||
@JsonSerializable()
|
||||
class InvokeRequest {
|
||||
String method;
|
||||
List<String> params;
|
||||
List<dynamic> params;
|
||||
|
||||
InvokeRequest({
|
||||
this.method = '',
|
||||
|
||||
Reference in new issue
Block a user