mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
新增订阅管理
新增环境变量导入和导出
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:qinglong_app/module/login/user_bean.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/dependency_bean.dart';
|
||||
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
|
||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
import 'package:qinglong_app/utils/utils.dart';
|
||||
@@ -377,4 +378,89 @@ class Api {
|
||||
[id],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 获取订阅
|
||||
static Future<HttpResponse<List<Subscription>>> getSubscription()async{
|
||||
return await Http.get<List<Subscription>>(
|
||||
Url.subscriptions,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// 新增订阅
|
||||
static Future<HttpResponse<Subscription>> postSubscription(Subscription subscription)async{
|
||||
var data = subscription.toJson();
|
||||
data.remove("id");
|
||||
data.remove("status");
|
||||
data.remove("pid");
|
||||
data.remove("log_path");
|
||||
data.remove("is_disabled");
|
||||
data.remove("createdAt");
|
||||
data.remove("updatedAt");
|
||||
data.remove("pullType");
|
||||
data.remove("pullOption");
|
||||
return await Http.post<Subscription>(
|
||||
Url.subscriptions,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
// 修改订阅
|
||||
static Future<HttpResponse<Subscription>> putSubscription(Subscription subscription)async{
|
||||
return await Http.put<Subscription>(
|
||||
Url.subscriptions,
|
||||
subscription.toJson()
|
||||
);
|
||||
}
|
||||
|
||||
// 删除订阅 参数未一个id数组
|
||||
static Future<HttpResponse<NullResponse>> deleteSubscription(List<int> ids)async{
|
||||
return await Http.delete<NullResponse>(
|
||||
Url.subscriptions,
|
||||
ids
|
||||
);
|
||||
}
|
||||
|
||||
// 删除订阅 参数未一个id数组
|
||||
static Future<HttpResponse<NullResponse>> disableSubscription(List<int> ids)async{
|
||||
return await Http.put<NullResponse>(
|
||||
Url.disableSubscriptions,
|
||||
ids
|
||||
);
|
||||
}
|
||||
|
||||
// 删除订阅 参数未一个id数组
|
||||
static Future<HttpResponse<NullResponse>> enableSubscription(List<int> ids)async{
|
||||
return await Http.put<NullResponse>(
|
||||
Url.enableSubscriptions,
|
||||
ids
|
||||
);
|
||||
}
|
||||
|
||||
// 开始执行订阅
|
||||
static Future<HttpResponse<NullResponse>> startSubscription(
|
||||
List<int> subscriptions) async {
|
||||
return await Http.put<NullResponse>(
|
||||
Url.runSubscriptions,
|
||||
subscriptions,
|
||||
);
|
||||
}
|
||||
|
||||
// 暂停订阅执行
|
||||
static Future<HttpResponse<NullResponse>> stopSubscription(
|
||||
List<int> subscriptions) async {
|
||||
return await Http.put<NullResponse>(
|
||||
Url.stopSubscriptions,
|
||||
subscriptions,
|
||||
);
|
||||
}
|
||||
|
||||
// 获取订阅的日志
|
||||
static Future<HttpResponse<String>> subTimeLog(int subId) async {
|
||||
return await Http.get<String>(
|
||||
Url.subtimeLog(subId),
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,38 @@ class Url {
|
||||
: "/api/envs/$envId/move";
|
||||
}
|
||||
|
||||
// 运行订阅
|
||||
static get runSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/run"
|
||||
: "/api/subscriptions/run";
|
||||
|
||||
// 停止订阅
|
||||
static get stopSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/stop"
|
||||
: "/api/subscriptions/stop";
|
||||
|
||||
// 启用订阅
|
||||
static get enableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/enable"
|
||||
: "/api/subscriptions/enable";
|
||||
|
||||
// 禁用订阅
|
||||
static get disableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/disable"
|
||||
: "/api/subscriptions/disable";
|
||||
|
||||
// GET 获取订阅 POST 提交订阅 PUT 修改订阅 DELETE 删除订阅
|
||||
static get subscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions"
|
||||
: "/api/subscriptions";
|
||||
|
||||
// 获取订阅日志
|
||||
static subtimeLog(int cronId) {
|
||||
return getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/$cronId/log"
|
||||
: "/api/subscriptions/$cronId/log";
|
||||
}
|
||||
|
||||
static bool inWhiteList(String path) {
|
||||
if (path == login ||
|
||||
path == loginByClientId ||
|
||||
|
||||
Reference in New Issue
Block a user