diff --git a/lib/base/http/api.dart b/lib/base/http/api.dart index 805bba1..7fa55b3 100644 --- a/lib/base/http/api.dart +++ b/lib/base/http/api.dart @@ -89,24 +89,21 @@ class Api { ); } - static Future> startTasks( - List crons) async { + static Future> startTasks(List crons) async { return await Http.put( Url.runTasks, crons, ); } - static Future> stopTasks( - List crons) async { + static Future> stopTasks(List crons) async { return await Http.put( Url.stopTasks, crons, ); } - static Future> updatePassword( - String name, String password) async { + static Future> updatePassword(String name, String password) async { return await Http.put( Url.updatePassword, { @@ -130,11 +127,7 @@ class Api { int? id, String? nId, }) async { - var data = { - "name": name, - "command": command, - "schedule": cron - }; + var data = {"name": name, "command": command, "schedule": cron}; if (id != null || nId != null) { if (id != null) { @@ -202,8 +195,7 @@ class Api { ); } - static Future> saveFile( - String name, String content) async { + static Future> saveFile(String name, String content) async { return await Http.post( Url.saveFile, {"content": content, "name": name}, @@ -268,8 +260,7 @@ class Api { ); } - static Future> moveEnv( - String id, int fromIndex, int toIndex) async { + static Future> moveEnv(String id, int fromIndex, int toIndex) async { return await Http.put( Url.envMove(id), {"fromIndex": fromIndex, "toIndex": toIndex}, @@ -284,12 +275,10 @@ class Api { } static Future>> taskLog() async { - return await Http.get>(Url.taskLog, null, - serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs"); + return await Http.get>(Url.taskLog, null, serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs"); } - static Future> taskLogDetail( - String name, String path) async { + static Future> taskLogDetail(String name, String path) async { if (Utils.isUpperVersion2_13_0()) { return await Http.get( Url.taskLogDetail + name + "?path=" + path, @@ -311,8 +300,7 @@ class Api { ); } - static Future> updateScript( - String name, String path, String content) async { + static Future> updateScript(String name, String path, String content) async { return await Http.put( Url.scriptDetail, { @@ -323,8 +311,7 @@ class Api { ); } - static Future> delScript( - String name, String path) async { + static Future> delScript(String name, String path) async { return await Http.delete( Url.scriptDetail, { @@ -334,8 +321,7 @@ class Api { ); } - static Future> scriptDetail( - String name, String? path) async { + static Future> scriptDetail(String name, String? path) async { return await Http.get( Url.scriptDetail + name, { @@ -344,8 +330,7 @@ class Api { ); } - static Future>> dependencies( - String type) async { + static Future>> dependencies(String type) async { return await Http.get>( Url.dependencies, { @@ -354,8 +339,7 @@ class Api { ); } - static Future> dependencyReinstall( - String id) async { + static Future> dependencyReinstall(String id) async { return await Http.put( Url.dependencies, [id], @@ -369,21 +353,14 @@ class Api { ); } - static Future> addDependency( - String name, int type) async { + static Future> addDependency(List> list) async { return await Http.post( Url.dependencies, - [ - { - "name": name, - "type": type, - } - ], + list, ); } - static Future> addScript( - String name, String path, String content) async { + static Future> addScript(String name, String path, String content) async { return await Http.post( Url.addScript, { diff --git a/lib/module/others/dependencies/add_dependency_page.dart b/lib/module/others/dependencies/add_dependency_page.dart index e762532..82fc7e0 100644 --- a/lib/module/others/dependencies/add_dependency_page.dart +++ b/lib/module/others/dependencies/add_dependency_page.dart @@ -129,6 +129,8 @@ class _AddDependencyPageState extends ConsumerState { ), TextField( controller: _nameController, + maxLines: 10, + minLines: 1, decoration: const InputDecoration( contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), hintText: "请输入名称", @@ -149,10 +151,18 @@ class _AddDependencyPageState extends ConsumerState { return; } - HttpResponse response = await Api.addDependency( - _nameController.text, - depedencyType.index, - ); + List> list = []; + + List names = _nameController.text.split("\n"); + list.addAll(names + .map( + (e) => { + "name": e, + "type": depedencyType.index, + }, + ) + .toList()); + HttpResponse response = await Api.addDependency(list); if (response.success) { "新增成功".toast();