支持脚本的编辑删除

This commit is contained in:
jyuesong
2022-01-20 10:25:10 +08:00
parent 89ad8e38e5
commit 22f66d36a2
11 changed files with 703 additions and 147 deletions

View File

@@ -66,6 +66,16 @@ class Api {
);
}
static Future<HttpResponse<NullResponse>> updatePassword(String name, String password) async {
return await Http.put<NullResponse>(
Url.updatePassword,
{
"username": name,
"password": password,
},
);
}
static Future<HttpResponse<String>> inTimeLog(String cron) async {
return await Http.get<String>(
Url.intimeLog(cron),
@@ -225,6 +235,27 @@ class Api {
);
}
static Future<HttpResponse<NullResponse>> updateScript(String name, String path, String content) async {
return await Http.put<NullResponse>(
Url.scriptDetail,
{
"filename": name,
"path": path,
"content": content,
},
);
}
static Future<HttpResponse<NullResponse>> delScript(String name, String path) async {
return await Http.delete<NullResponse>(
Url.scriptDetail,
{
"filename": name,
"path": path,
},
);
}
static Future<HttpResponse<String>> scriptDetail(String name, String? path) async {
return await Http.get<String>(
Url.scriptDetail + name,

View File

@@ -117,7 +117,7 @@ class Http {
if (!pushedLoginPage) {
"身份已过期,请重新登录".toast();
pushedLoginPage = true;
navigatorState.currentState?.pushReplacementNamed(Routes.routeLogin);
navigatorState.currentState?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
}
}

View File

@@ -6,6 +6,8 @@ class Url {
static const loginByClientId = "/open/auth/token";
static const user = "/api/user";
static const updatePassword = "/api/user";
static get tasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons" : "/api/crons";
static get runTasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/run" : "/api/crons/run";
@@ -47,6 +49,7 @@ class Url {
static get taskLogDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs/" : "/api/logs/";
static get scripts => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts/files" : "/api/scripts/files";
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
static get scriptDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts/" : "/api/scripts/";
@@ -54,6 +57,9 @@ class Url {
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined ? "/open/dependencies/reinstall" : "/api/dependencies/reinstall";
static intimeLog(String cronId) {
return getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/$cronId/log" : "/api/crons/$cronId/log";
}

View File

@@ -10,9 +10,11 @@ import 'package:qinglong_app/module/others/dependencies/add_dependency_page.dart
import 'package:qinglong_app/module/others/dependencies/dependency_page.dart';
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
import 'package:qinglong_app/module/others/scripts/script_detail_page.dart';
import 'package:qinglong_app/module/others/scripts/script_edit_page.dart';
import 'package:qinglong_app/module/others/scripts/script_page.dart';
import 'package:qinglong_app/module/others/task_log/task_log_detail_page.dart';
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
import 'package:qinglong_app/module/others/update_password_page.dart';
import 'package:qinglong_app/module/task/add_task_page.dart';
import 'package:qinglong_app/module/task/task_bean.dart';
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
@@ -31,7 +33,10 @@ class Routes {
static const String routeTaskLogDetail = "/log/taskDetail";
static const String routeScript = "/script";
static const String routeScriptDetail = "/script/detail";
static const String routeScriptUpdate = "/script/update";
static const String routeScriptAdd = "/script/add";
static const String routeDependency = "/Dependency";
static const String routeUpdatePassword = "/updatePassword";
static Route<dynamic>? generateRoute(RouteSettings settings) {
switch (settings.name) {
@@ -100,12 +105,25 @@ class Routes {
builder: (context) => TaskDetailPage(
settings.arguments as TaskBean,
),
); case routeEnvDetail:
);
case routeEnvDetail:
return CupertinoPageRoute(
builder: (context) => EnvDetailPage(
settings.arguments as EnvBean,
),
);
case routeUpdatePassword:
return CupertinoPageRoute(
builder: (context) => const UpdatePasswordPage(),
);
case routeScriptUpdate:
return CupertinoPageRoute(
builder: (context) => ScriptEditPage(
(settings.arguments as Map)["title"],
(settings.arguments as Map)["path"],
(settings.arguments as Map)["content"],
),
);
}
return null;