mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add login log
This commit is contained in:
@@ -1,17 +1,18 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:qinglong_app/base/http/http.dart';
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
import 'package:qinglong_app/module/config/config_bean.dart';
|
import 'package:qinglong_app/module/config/config_bean.dart';
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
import 'package:qinglong_app/module/login/login_bean.dart';
|
import 'package:qinglong_app/module/login/login_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/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
||||||
|
|
||||||
import 'url.dart';
|
import 'url.dart';
|
||||||
|
|
||||||
class Api {
|
class Api {
|
||||||
static Future<HttpResponse<LoginBean>> login(
|
static Future<HttpResponse<LoginBean>> login(String userName, String passWord) async {
|
||||||
String userName, String passWord) async {
|
|
||||||
return await Http.post<LoginBean>(
|
return await Http.post<LoginBean>(
|
||||||
Url.login,
|
Url.login,
|
||||||
{
|
{
|
||||||
@@ -22,104 +23,240 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<TaskBean>>> crons() async {
|
static Future<HttpResponse<List<TaskBean>>> crons() async {
|
||||||
return await Http.get<List<TaskBean>>(Url.tasks, {"searchValue": ""});
|
return await Http.get<List<TaskBean>>(
|
||||||
|
Url.tasks,
|
||||||
|
{"searchValue": ""},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> startTasks(
|
static Future<HttpResponse<NullResponse>> startTasks(List<String> crons) async {
|
||||||
List<String> crons) async {
|
return await Http.put<NullResponse>(
|
||||||
return await Http.put<NullResponse>(Url.runTasks, crons);
|
Url.runTasks,
|
||||||
|
crons,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> stopTasks(
|
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
||||||
List<String> crons) async {
|
return await Http.put<NullResponse>(
|
||||||
return await Http.put<NullResponse>(Url.runTasks, crons);
|
Url.runTasks,
|
||||||
|
crons,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> inTimeLog(String cron) async {
|
static Future<HttpResponse<String>> inTimeLog(String cron) async {
|
||||||
return await Http.get<String>(Url.intimeLog(cron), null);
|
return await Http.get<String>(
|
||||||
|
Url.intimeLog(cron),
|
||||||
|
null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<TaskDetailBean>> taskDetail(String cron) async {
|
static Future<HttpResponse<TaskDetailBean>> taskDetail(String cron) async {
|
||||||
return await Http.get<TaskDetailBean>(Url.taskDetail + cron, null);
|
return await Http.get<TaskDetailBean>(
|
||||||
|
Url.taskDetail + cron,
|
||||||
|
null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<TaskDetailBean>> addTask(
|
static Future<HttpResponse<TaskDetailBean>> addTask(String name, String command, String cron, {String? id}) async {
|
||||||
String name, String command, String cron,
|
|
||||||
{String? id}) async {
|
|
||||||
var data = {"name": name, "command": command, "schedule": cron};
|
var data = {"name": name, "command": command, "schedule": cron};
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
data["_id"] = id;
|
data["_id"] = id;
|
||||||
return await Http.put<TaskDetailBean>(Url.addTask, data);
|
return await Http.put<TaskDetailBean>(
|
||||||
|
Url.addTask,
|
||||||
|
data,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return await Http.post<TaskDetailBean>(Url.addTask, data);
|
return await Http.post<TaskDetailBean>(
|
||||||
|
Url.addTask,
|
||||||
|
data,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> delTask(String cron) async {
|
static Future<HttpResponse<NullResponse>> delTask(String cron) async {
|
||||||
return await Http.delete<NullResponse>(Url.addTask, [cron]);
|
return await Http.delete<NullResponse>(
|
||||||
|
Url.addTask,
|
||||||
|
[cron],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> pinTask(String cron) async {
|
static Future<HttpResponse<NullResponse>> pinTask(String cron) async {
|
||||||
return await Http.put<NullResponse>(Url.pinTask, [cron]);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.pinTask,
|
||||||
|
[cron],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> unpinTask(String cron) async {
|
static Future<HttpResponse<NullResponse>> unpinTask(String cron) async {
|
||||||
return await Http.put<NullResponse>(Url.unpinTask, [cron]);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.unpinTask,
|
||||||
|
[cron],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> enableTask(String cron) async {
|
static Future<HttpResponse<NullResponse>> enableTask(String cron) async {
|
||||||
return await Http.put<NullResponse>(Url.enableTask, [cron]);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.enableTask,
|
||||||
|
[cron],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> disableTask(String cron) async {
|
static Future<HttpResponse<NullResponse>> disableTask(String cron) async {
|
||||||
return await Http.put<NullResponse>(Url.disableTask, [cron]);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.disableTask,
|
||||||
|
[cron],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<ConfigBean>>> files() async {
|
static Future<HttpResponse<List<ConfigBean>>> files() async {
|
||||||
return await Http.get<List<ConfigBean>>(Url.files, null);
|
return await Http.get<List<ConfigBean>>(
|
||||||
|
Url.files,
|
||||||
|
null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> content(String name) async {
|
static Future<HttpResponse<String>> content(String name) async {
|
||||||
return await Http.get<String>(Url.configContent + name, null);
|
return await Http.get<String>(
|
||||||
|
Url.configContent + name,
|
||||||
|
null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> saveFile(
|
static Future<HttpResponse<NullResponse>> saveFile(String name, String content) async {
|
||||||
String name, String content) async {
|
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.saveFile, {"content": content, "name": name});
|
Url.saveFile,
|
||||||
|
{"content": content, "name": name},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<EnvBean>>> envs(String search) async {
|
static Future<HttpResponse<List<EnvBean>>> envs(String search) async {
|
||||||
return await Http.get<List<EnvBean>>(Url.envs, {"searchValue": search});
|
return await Http.get<List<EnvBean>>(
|
||||||
|
Url.envs,
|
||||||
|
{"searchValue": search},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> enableEnv(String id) async {
|
static Future<HttpResponse<NullResponse>> enableEnv(String id) async {
|
||||||
return await Http.put<NullResponse>(Url.enableEnvs, [id]);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.enableEnvs,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> disableEnv(String id) async {
|
static Future<HttpResponse<NullResponse>> disableEnv(String id) async {
|
||||||
return await Http.put<NullResponse>(Url.disableEnvs, [id]);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.disableEnvs,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> delEnv(String id) async {
|
static Future<HttpResponse<NullResponse>> delEnv(String id) async {
|
||||||
return await Http.delete<NullResponse>(Url.delEnv, [id]);
|
return await Http.delete<NullResponse>(
|
||||||
|
Url.delEnv,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addEnv(
|
static Future<HttpResponse<NullResponse>> addEnv(String name, String value, String remarks, {String? id}) async {
|
||||||
String name, String value, String remarks,
|
var data = {
|
||||||
{String? id}) async {
|
"value": value,
|
||||||
var data = {"value": value, "remarks": remarks, "name": name};
|
"remarks": remarks,
|
||||||
|
"name": name,
|
||||||
|
};
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
data["_id"] = id;
|
data["_id"] = id;
|
||||||
return await Http.put<NullResponse>(Url.addEnv, data);
|
return await Http.put<NullResponse>(
|
||||||
|
Url.addEnv,
|
||||||
|
data,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return await Http.post<NullResponse>(Url.addEnv, [data]);
|
return await Http.post<NullResponse>(
|
||||||
|
Url.addEnv,
|
||||||
|
[data],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> moveEnv(
|
static Future<HttpResponse<NullResponse>> moveEnv(String id, int fromIndex, int toIndex) async {
|
||||||
String id, int fromIndex, int toIndex) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.envMove(id), {"fromIndex": fromIndex, "toIndex": toIndex});
|
Url.envMove(id),
|
||||||
|
{"fromIndex": fromIndex, "toIndex": toIndex},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<List<LoginLogBean>>> loginLog() async {
|
||||||
|
return await Http.get<List<LoginLogBean>>(
|
||||||
|
Url.loginLog,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
||||||
|
return await Http.get<List<TaskLogBean>>(Url.taskLog, null, serializationName: "dirs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<String>> taskLogDetail(String name) async {
|
||||||
|
return await Http.get<String>(
|
||||||
|
Url.taskLogDetail + name,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<List<ScriptBean>>> scripts() async {
|
||||||
|
return await Http.get<List<ScriptBean>>(
|
||||||
|
Url.scripts,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<String>> scriptDetail(String name, String path) async {
|
||||||
|
return await Http.get<String>(
|
||||||
|
Url.scriptDetail + name,
|
||||||
|
{
|
||||||
|
"path": path,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<List<DependencyBean>>> dependencies(String type) async {
|
||||||
|
return await Http.get<List<DependencyBean>>(
|
||||||
|
Url.dependencies,
|
||||||
|
{
|
||||||
|
"type": type,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<NullResponse>> dependencyReinstall(String id) async {
|
||||||
|
return await Http.put<NullResponse>(
|
||||||
|
Url.dependencies,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<String>> dependencyLog(String id) async {
|
||||||
|
return await Http.get<String>(
|
||||||
|
Url.dependencies + "/" + id,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<NullResponse>> addDependency(String name, int type) async {
|
||||||
|
return await Http.post<NullResponse>(
|
||||||
|
Url.dependencies,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": name,
|
||||||
|
"type": type,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<NullResponse>> delDependency(String id) async {
|
||||||
|
return await Http.delete<NullResponse>(
|
||||||
|
Url.dependencies,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,74 +38,90 @@ class Http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<T>> get<T>(String uri, Map<String, String>? json,
|
static Future<HttpResponse<T>> get<T>(
|
||||||
{bool compute = true}) async {
|
String uri,
|
||||||
|
Map<String, String>? json, {
|
||||||
|
bool compute = true,
|
||||||
|
String serializationName = "data",
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
_init();
|
_init();
|
||||||
var response = await _dio!.get(uri, queryParameters: json);
|
var response = await _dio!.get(uri, queryParameters: json);
|
||||||
|
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(response, serializationName, compute);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
if (e.response?.statusCode == 401) {
|
if (e.response?.statusCode == 401) {
|
||||||
exitLogin();
|
exitLogin();
|
||||||
}
|
}
|
||||||
return HttpResponse(
|
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||||
success: false,
|
|
||||||
message: e.response?.statusMessage ?? e.message,
|
|
||||||
code: 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<T>> post<T>(String uri, dynamic json,
|
static Future<HttpResponse<T>> post<T>(
|
||||||
{bool compute = true}) async {
|
String uri,
|
||||||
|
dynamic json, {
|
||||||
|
bool compute = true,
|
||||||
|
String serializationName = "data",
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
_init();
|
_init();
|
||||||
var response = await _dio!.post(uri, data: json);
|
var response = await _dio!.post(uri, data: json);
|
||||||
|
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(
|
||||||
|
response,
|
||||||
|
serializationName,
|
||||||
|
compute,
|
||||||
|
);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
if (e.response?.statusCode == 401) {
|
if (e.response?.statusCode == 401) {
|
||||||
exitLogin();
|
exitLogin();
|
||||||
}
|
}
|
||||||
return HttpResponse(
|
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||||
success: false,
|
|
||||||
message: e.response?.statusMessage ?? e.message,
|
|
||||||
code: 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<T>> delete<T>(String uri, dynamic json,
|
static Future<HttpResponse<T>> delete<T>(
|
||||||
{bool compute = true}) async {
|
String uri,
|
||||||
|
dynamic json, {
|
||||||
|
bool compute = true,
|
||||||
|
String serializationName = "data",
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
_init();
|
_init();
|
||||||
var response = await _dio!.delete(uri, data: json);
|
var response = await _dio!.delete(uri, data: json);
|
||||||
|
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(
|
||||||
|
response,
|
||||||
|
serializationName,
|
||||||
|
compute,
|
||||||
|
);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
if (e.response?.statusCode == 401) {
|
if (e.response?.statusCode == 401) {
|
||||||
exitLogin();
|
exitLogin();
|
||||||
}
|
}
|
||||||
return HttpResponse(
|
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||||
success: false,
|
|
||||||
message: e.response?.statusMessage ?? e.message,
|
|
||||||
code: 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<T>> put<T>(String uri, dynamic json,
|
static Future<HttpResponse<T>> put<T>(
|
||||||
{bool compute = true}) async {
|
String uri,
|
||||||
|
dynamic json, {
|
||||||
|
bool compute = true,
|
||||||
|
String serializationName = "data",
|
||||||
|
}) async {
|
||||||
try {
|
try {
|
||||||
_init();
|
_init();
|
||||||
var response = await _dio!.put(uri, data: json);
|
var response = await _dio!.put(uri, data: json);
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(
|
||||||
|
response,
|
||||||
|
serializationName,
|
||||||
|
compute,
|
||||||
|
);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
if (e.response?.statusCode == 401) {
|
if (e.response?.statusCode == 401) {
|
||||||
exitLogin();
|
exitLogin();
|
||||||
}
|
}
|
||||||
return HttpResponse(
|
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||||
success: false,
|
|
||||||
message: e.response?.statusMessage ?? e.message,
|
|
||||||
code: 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,13 +136,14 @@ class Http {
|
|||||||
|
|
||||||
static HttpResponse<T> decodeResponse<T>(
|
static HttpResponse<T> decodeResponse<T>(
|
||||||
Response<dynamic> response,
|
Response<dynamic> response,
|
||||||
|
String serializationName,
|
||||||
bool compute,
|
bool compute,
|
||||||
) {
|
) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
if (response.data["code"] == 200) {
|
if (response.data["code"] == 200) {
|
||||||
if (response.data["data"] != null) {
|
if (response.data[serializationName] != null) {
|
||||||
if (T == NullResponse) {
|
if (T == NullResponse) {
|
||||||
return HttpResponse<T>(
|
return HttpResponse<T>(
|
||||||
success: true,
|
success: true,
|
||||||
@@ -134,7 +151,7 @@ class Http {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic data = response.data["data"];
|
dynamic data = response.data[serializationName];
|
||||||
T t;
|
T t;
|
||||||
if (T == String) {
|
if (T == String) {
|
||||||
if (data is String) {
|
if (data is String) {
|
||||||
@@ -198,8 +215,7 @@ class HttpResponse<T> {
|
|||||||
late int code;
|
late int code;
|
||||||
T? bean;
|
T? bean;
|
||||||
|
|
||||||
HttpResponse(
|
HttpResponse({required this.success, this.message, required this.code, this.bean});
|
||||||
{required this.success, this.message, required this.code, this.bean});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeserializeAction<T> {
|
class DeserializeAction<T> {
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ class Url {
|
|||||||
static const delEnv = "/api/envs";
|
static const delEnv = "/api/envs";
|
||||||
static const disableEnvs = "/api/envs/disable";
|
static const disableEnvs = "/api/envs/disable";
|
||||||
static const enableEnvs = "/api/envs/enable";
|
static const enableEnvs = "/api/envs/enable";
|
||||||
|
static const loginLog = "/api/user/login-log";
|
||||||
|
static const taskLog = "/api/logs";
|
||||||
|
static const taskLogDetail = "/api/logs/code/";
|
||||||
|
static const scripts = "/api/scripts/files";
|
||||||
|
static const scriptDetail = "/api/scripts/";
|
||||||
|
static const dependencies = "/api/dependencies";
|
||||||
|
static const dependencyReinstall = "/api/dependencies/reinstall";
|
||||||
|
|
||||||
static intimeLog(String cronId) {
|
static intimeLog(String cronId) {
|
||||||
return "/api/crons/$cronId/log";
|
return "/api/crons/$cronId/log";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:qinglong_app/module/env/add_env_page.dart';
|
|||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
import 'package:qinglong_app/module/home/home_page.dart';
|
import 'package:qinglong_app/module/home/home_page.dart';
|
||||||
import 'package:qinglong_app/module/login/login_page.dart';
|
import 'package:qinglong_app/module/login/login_page.dart';
|
||||||
|
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
|
||||||
import 'package:qinglong_app/module/task/add_task_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_bean.dart';
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ class Routes {
|
|||||||
static const String routeAddTask = "/task/add";
|
static const String routeAddTask = "/task/add";
|
||||||
static const String routeAddEnv = "/env/add";
|
static const String routeAddEnv = "/env/add";
|
||||||
static const String routeConfigEdit = "/config/edit";
|
static const String routeConfigEdit = "/config/edit";
|
||||||
|
static const String routeLoginLog = "/log/login";
|
||||||
|
|
||||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
@@ -46,6 +48,10 @@ class Routes {
|
|||||||
(settings.arguments as Map)["content"],
|
(settings.arguments as Map)["content"],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
case routeLoginLog:
|
||||||
|
return CupertinoPageRoute(
|
||||||
|
builder: (context) => const LoginLogPage(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import 'package:qinglong_app/utils/sp_utils.dart';
|
|||||||
var themeProvider = ChangeNotifierProvider((ref) => ThemeViewModel());
|
var themeProvider = ChangeNotifierProvider((ref) => ThemeViewModel());
|
||||||
const Color _primaryColor = Color(0xFF299343);
|
const Color _primaryColor = Color(0xFF299343);
|
||||||
|
|
||||||
|
get primaryColor => _primaryColor;
|
||||||
|
|
||||||
class ThemeViewModel extends ChangeNotifier {
|
class ThemeViewModel extends ChangeNotifier {
|
||||||
ThemeData currentTheme = lightTheme;
|
ThemeData currentTheme = lightTheme;
|
||||||
|
|
||||||
@@ -221,7 +223,7 @@ class DartThemeColors extends ThemeColors {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Color settingBgColor() {
|
Color settingBgColor() {
|
||||||
return Colors.black;
|
return Colors.black12;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -3,11 +3,17 @@
|
|||||||
import 'package:qinglong_app/module/config/config_bean.dart';
|
import 'package:qinglong_app/module/config/config_bean.dart';
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
import 'package:qinglong_app/module/login/login_bean.dart';
|
import 'package:qinglong_app/module/login/login_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/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
||||||
|
|
||||||
|
|
||||||
class JsonConversion$Json {
|
class JsonConversion$Json {
|
||||||
static M fromJson<M>(dynamic json) {
|
|
||||||
|
static M fromJson<M>(dynamic json) {
|
||||||
if (json is List) {
|
if (json is List) {
|
||||||
return _getListChildType<M>(json);
|
return _getListChildType<M>(json);
|
||||||
} else {
|
} else {
|
||||||
@@ -16,55 +22,83 @@ class JsonConversion$Json {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static M _fromJsonSingle<M>(dynamic json) {
|
static M _fromJsonSingle<M>(dynamic json) {
|
||||||
|
|
||||||
String type = M.toString();
|
String type = M.toString();
|
||||||
|
|
||||||
if (type == (ConfigBean).toString()) {
|
if(type == (ConfigBean).toString()){
|
||||||
return ConfigBean.jsonConversion(json) as M;
|
return ConfigBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == (EnvBean).toString()) {
|
if(type == (EnvBean).toString()){
|
||||||
return EnvBean.jsonConversion(json) as M;
|
return EnvBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == (LoginBean).toString()) {
|
if(type == (LoginBean).toString()){
|
||||||
return LoginBean.jsonConversion(json) as M;
|
return LoginBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == (TaskBean).toString()) {
|
if(type == (DependencyBean).toString()){
|
||||||
return TaskBean.jsonConversion(json) as M;
|
return DependencyBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == (TaskDetailBean).toString()) {
|
if(type == (LoginLogBean).toString()){
|
||||||
return TaskDetailBean.jsonConversion(json) as M;
|
return LoginLogBean.jsonConversion(json) as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == (ScriptBean).toString()){
|
||||||
|
return ScriptBean.jsonConversion(json) as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == (TaskLogBean).toString()){
|
||||||
|
return TaskLogBean.jsonConversion(json) as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == (TaskBean).toString()){
|
||||||
|
return TaskBean.jsonConversion(json) as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == (TaskDetailBean).toString()){
|
||||||
|
return TaskDetailBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Exception("not found");
|
throw Exception("not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
static M _getListChildType<M>(List<dynamic> data) {
|
static M _getListChildType<M>(List<dynamic> data) {
|
||||||
if (<ConfigBean>[] is M) {
|
if(<ConfigBean>[] is M){
|
||||||
return data.map<ConfigBean>((e) => ConfigBean.jsonConversion(e)).toList()
|
return data.map<ConfigBean>((e) => ConfigBean.jsonConversion(e)).toList() as M;
|
||||||
as M;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (<EnvBean>[] is M) {
|
if(<EnvBean>[] is M){
|
||||||
return data.map<EnvBean>((e) => EnvBean.jsonConversion(e)).toList() as M;
|
return data.map<EnvBean>((e) => EnvBean.jsonConversion(e)).toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (<LoginBean>[] is M) {
|
if(<LoginBean>[] is M){
|
||||||
return data.map<LoginBean>((e) => LoginBean.jsonConversion(e)).toList()
|
return data.map<LoginBean>((e) => LoginBean.jsonConversion(e)).toList() as M;
|
||||||
as M;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (<TaskBean>[] is M) {
|
if(<DependencyBean>[] is M){
|
||||||
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList()
|
return data.map<DependencyBean>((e) => DependencyBean.jsonConversion(e)).toList() as M;
|
||||||
as M;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (<TaskDetailBean>[] is M) {
|
if(<LoginLogBean>[] is M){
|
||||||
return data
|
return data.map<LoginLogBean>((e) => LoginLogBean.jsonConversion(e)).toList() as M;
|
||||||
.map<TaskDetailBean>((e) => TaskDetailBean.jsonConversion(e))
|
}
|
||||||
.toList() as M;
|
|
||||||
|
if(<ScriptBean>[] is M){
|
||||||
|
return data.map<ScriptBean>((e) => ScriptBean.jsonConversion(e)).toList() as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(<TaskLogBean>[] is M){
|
||||||
|
return data.map<TaskLogBean>((e) => TaskLogBean.jsonConversion(e)).toList() as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(<TaskBean>[] is M){
|
||||||
|
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList() as M;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(<TaskDetailBean>[] is M){
|
||||||
|
return data.map<TaskDetailBean>((e) => TaskDetailBean.jsonConversion(e)).toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Exception("not found");
|
throw Exception("not found");
|
||||||
|
|||||||
51
lib/module/others/dependencies/dependency_bean.dart
Normal file
51
lib/module/others/dependencies/dependency_bean.dart
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
@JsonConversion()
|
||||||
|
class DependencyBean {
|
||||||
|
String? sId;
|
||||||
|
int? created;
|
||||||
|
int? status;
|
||||||
|
int? type;
|
||||||
|
String? timestamp;
|
||||||
|
String? name;
|
||||||
|
List<String>? log;
|
||||||
|
String? remark;
|
||||||
|
|
||||||
|
DependencyBean(
|
||||||
|
{this.sId,
|
||||||
|
this.created,
|
||||||
|
this.status,
|
||||||
|
this.type,
|
||||||
|
this.timestamp,
|
||||||
|
this.name,
|
||||||
|
this.log,
|
||||||
|
this.remark});
|
||||||
|
|
||||||
|
DependencyBean.fromJson(Map<String, dynamic> json) {
|
||||||
|
sId = json['_id'];
|
||||||
|
created = json['created'];
|
||||||
|
status = json['status'];
|
||||||
|
type = json['type'];
|
||||||
|
timestamp = json['timestamp'];
|
||||||
|
name = json['name'];
|
||||||
|
log = json['log'].cast<String>();
|
||||||
|
remark = json['remark'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['_id'] = this.sId;
|
||||||
|
data['created'] = this.created;
|
||||||
|
data['status'] = this.status;
|
||||||
|
data['type'] = this.type;
|
||||||
|
data['timestamp'] = this.timestamp;
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['log'] = this.log;
|
||||||
|
data['remark'] = this.remark;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
static DependencyBean jsonConversion(Map<String, dynamic> json) {
|
||||||
|
return DependencyBean.fromJson(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
lib/module/others/login_log/login_log_bean.dart
Normal file
35
lib/module/others/login_log/login_log_bean.dart
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
@JsonConversion()
|
||||||
|
class LoginLogBean {
|
||||||
|
int? timestamp;
|
||||||
|
String? address;
|
||||||
|
String? ip;
|
||||||
|
String? platform;
|
||||||
|
int? status; //0代表成功,1代表失败
|
||||||
|
|
||||||
|
LoginLogBean({this.timestamp, this.address, this.ip, this.platform, this.status});
|
||||||
|
|
||||||
|
LoginLogBean.fromJson(Map<String, dynamic> json) {
|
||||||
|
timestamp = json['timestamp'];
|
||||||
|
address = json['address'];
|
||||||
|
ip = json['ip'];
|
||||||
|
platform = json['platform'];
|
||||||
|
status = json['status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['timestamp'] = this.timestamp;
|
||||||
|
data['address'] = this.address;
|
||||||
|
data['ip'] = this.ip;
|
||||||
|
data['platform'] = this.platform;
|
||||||
|
data['status'] = this.status;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LoginLogBean jsonConversion(Map<String, dynamic> json) {
|
||||||
|
return LoginLogBean.fromJson(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
112
lib/module/others/login_log/login_log_page.dart
Normal file
112
lib/module/others/login_log/login_log_page.dart
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:qinglong_app/base/http/api.dart';
|
||||||
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
import 'package:qinglong_app/utils/utils.dart';
|
||||||
|
|
||||||
|
import 'login_log_bean.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
class LoginLogPage extends ConsumerStatefulWidget {
|
||||||
|
const LoginLogPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_LoginLogPageState createState() => _LoginLogPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginLogPageState extends ConsumerState<LoginLogPage> {
|
||||||
|
List<LoginLogBean> list = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: "任务日志",
|
||||||
|
),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
LoginLogBean item = list[index];
|
||||||
|
|
||||||
|
return ColoredBox(
|
||||||
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
|
child: ListTile(
|
||||||
|
isThreeLine: true,
|
||||||
|
title: Text(
|
||||||
|
Utils.formatMessageTime(item.timestamp ?? 0),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"${item.address}",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"${item.ip}",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: item.status == 0
|
||||||
|
? Icon(
|
||||||
|
CupertinoIcons.checkmark_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
size: 16,
|
||||||
|
)
|
||||||
|
: const Icon(
|
||||||
|
CupertinoIcons.clear_circled,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: list.length,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadData() async {
|
||||||
|
HttpResponse<List<LoginLogBean>> response = await Api.loginLog();
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
list.clear();
|
||||||
|
list.addAll(response.bean ?? []);
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
response.message?.toast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,10 +50,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"脚本管理",
|
"脚本管理",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
.watch(themeProvider)
|
|
||||||
.themeColor
|
|
||||||
.taskTitleColor(),
|
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -78,10 +75,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"依赖管理",
|
"依赖管理",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
.watch(themeProvider)
|
|
||||||
.themeColor
|
|
||||||
.taskTitleColor(),
|
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -106,10 +100,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"任务日志",
|
"任务日志",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
.watch(themeProvider)
|
|
||||||
.themeColor
|
|
||||||
.taskTitleColor(),
|
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -124,29 +115,35 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
const Divider(
|
const Divider(
|
||||||
indent: 15,
|
indent: 15,
|
||||||
),
|
),
|
||||||
Padding(
|
GestureDetector(
|
||||||
padding: const EdgeInsets.symmetric(
|
behavior: HitTestBehavior.opaque,
|
||||||
vertical: 10,
|
onTap: () {
|
||||||
horizontal: 15,
|
Navigator.of(context).pushNamed(
|
||||||
),
|
Routes.routeLoginLog,
|
||||||
child: Row(
|
);
|
||||||
children: [
|
},
|
||||||
Text(
|
child: Padding(
|
||||||
"登录日志",
|
padding: const EdgeInsets.symmetric(
|
||||||
style: TextStyle(
|
vertical: 10,
|
||||||
color: ref
|
horizontal: 15,
|
||||||
.watch(themeProvider)
|
),
|
||||||
.themeColor
|
child: Row(
|
||||||
.taskTitleColor(),
|
mainAxisSize: MainAxisSize.max,
|
||||||
fontSize: 16,
|
children: [
|
||||||
|
Text(
|
||||||
|
"登录日志",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const Spacer(),
|
||||||
const Spacer(),
|
const Icon(
|
||||||
const Icon(
|
CupertinoIcons.right_chevron,
|
||||||
CupertinoIcons.right_chevron,
|
size: 16,
|
||||||
size: 16,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -181,10 +178,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"夜间模式",
|
"夜间模式",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
.watch(themeProvider)
|
|
||||||
.themeColor
|
|
||||||
.taskTitleColor(),
|
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -204,7 +198,9 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width - 40,
|
width: MediaQuery.of(context).size.width - 40,
|
||||||
child: CupertinoButton(
|
child: CupertinoButton(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 5,),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 5,
|
||||||
|
),
|
||||||
color: ref.watch(themeProvider).themeColor.buttonBgColor(),
|
color: ref.watch(themeProvider).themeColor.buttonBgColor(),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
"退出登录",
|
"退出登录",
|
||||||
@@ -214,8 +210,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
getIt<UserInfoViewModel>().updateToken("");
|
getIt<UserInfoViewModel>().updateToken("");
|
||||||
Navigator.of(context)
|
Navigator.of(context).pushReplacementNamed(Routes.routeLogin);
|
||||||
.pushReplacementNamed(Routes.routeLogin);
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
79
lib/module/others/scripts/script_bean.dart
Normal file
79
lib/module/others/scripts/script_bean.dart
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
@JsonConversion()
|
||||||
|
class ScriptBean {
|
||||||
|
String? title;
|
||||||
|
String? value;
|
||||||
|
String? key;
|
||||||
|
double? mtime;
|
||||||
|
bool? disabled;
|
||||||
|
List<ScriptChildren>? children;
|
||||||
|
|
||||||
|
ScriptBean(
|
||||||
|
{this.title,
|
||||||
|
this.value,
|
||||||
|
this.key,
|
||||||
|
this.mtime,
|
||||||
|
this.disabled,
|
||||||
|
this.children});
|
||||||
|
|
||||||
|
ScriptBean.fromJson(Map<String, dynamic> json) {
|
||||||
|
title = json['title'];
|
||||||
|
value = json['value'];
|
||||||
|
key = json['key'];
|
||||||
|
mtime = json['mtime'];
|
||||||
|
disabled = json['disabled'];
|
||||||
|
if (json['children'] != null) {
|
||||||
|
children = <ScriptChildren>[];
|
||||||
|
json['children'].forEach((v) {
|
||||||
|
children!.add(new ScriptChildren.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['title'] = this.title;
|
||||||
|
data['value'] = this.value;
|
||||||
|
data['key'] = this.key;
|
||||||
|
data['mtime'] = this.mtime;
|
||||||
|
data['disabled'] = this.disabled;
|
||||||
|
if (this.children != null) {
|
||||||
|
data['children'] = this.children!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
static ScriptBean jsonConversion(Map<String, dynamic> json) {
|
||||||
|
return ScriptBean.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScriptChildren {
|
||||||
|
String? title;
|
||||||
|
String? value;
|
||||||
|
String? key;
|
||||||
|
double? mtime;
|
||||||
|
String? parent;
|
||||||
|
|
||||||
|
ScriptChildren({this.title, this.value, this.key, this.mtime, this.parent});
|
||||||
|
|
||||||
|
ScriptChildren.fromJson(Map<String, dynamic> json) {
|
||||||
|
title = json['title'];
|
||||||
|
value = json['value'];
|
||||||
|
key = json['key'];
|
||||||
|
mtime = json['mtime'];
|
||||||
|
parent = json['parent'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['title'] = this.title;
|
||||||
|
data['value'] = this.value;
|
||||||
|
data['key'] = this.key;
|
||||||
|
data['mtime'] = this.mtime;
|
||||||
|
data['parent'] = this.parent;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
lib/module/others/scripts/script_page.dart
Normal file
26
lib/module/others/scripts/script_page.dart
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
class ScriptPage extends StatefulWidget {
|
||||||
|
const ScriptPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ScriptPageState createState() => _ScriptPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ScriptPageState extends State<ScriptPage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: "脚本管理",
|
||||||
|
),
|
||||||
|
body: Container(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
lib/module/others/task_log/task_log_bean.dart
Normal file
29
lib/module/others/task_log/task_log_bean.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
@JsonConversion()
|
||||||
|
class TaskLogBean {
|
||||||
|
String? name;
|
||||||
|
bool? isDir;
|
||||||
|
List<String>? files;
|
||||||
|
|
||||||
|
TaskLogBean({this.name, this.isDir, this.files});
|
||||||
|
|
||||||
|
TaskLogBean.fromJson(Map<String, dynamic> json) {
|
||||||
|
name = json['name'];
|
||||||
|
isDir = json['isDir'];
|
||||||
|
files = json['files'].cast<String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['isDir'] = this.isDir;
|
||||||
|
data['files'] = this.files;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static TaskLogBean jsonConversion(Map<String, dynamic> json) {
|
||||||
|
return TaskLogBean.fromJson(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
39
lib/module/others/task_log/task_log_page.dart
Normal file
39
lib/module/others/task_log/task_log_page.dart
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:qinglong_app/base/http/api.dart';
|
||||||
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
||||||
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
import 'package:qinglong_app/utils/utils.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
class TaskLogPage extends ConsumerStatefulWidget {
|
||||||
|
const TaskLogPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_TaskLogPageState createState() => _TaskLogPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TaskLogPageState extends ConsumerState<TaskLogPage> {
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: "任务日志",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,7 +8,13 @@ class Utils {
|
|||||||
|
|
||||||
static String formatMessageTime(int time) {
|
static String formatMessageTime(int time) {
|
||||||
DateTime current = DateTime.now();
|
DateTime current = DateTime.now();
|
||||||
DateTime chatTime = DateTime.fromMillisecondsSinceEpoch(time * 1000);
|
DateTime chatTime;
|
||||||
|
if (time.toString().length == 10) {
|
||||||
|
chatTime = DateTime.fromMillisecondsSinceEpoch(time * 1000);
|
||||||
|
} else {
|
||||||
|
chatTime = DateTime.fromMillisecondsSinceEpoch(time);
|
||||||
|
}
|
||||||
|
|
||||||
if (current.year == chatTime.year) {
|
if (current.year == chatTime.year) {
|
||||||
if (current.day == chatTime.day) {
|
if (current.day == chatTime.day) {
|
||||||
if (chatTime.hour <= 12) {
|
if (chatTime.hour <= 12) {
|
||||||
|
|||||||
Reference in New Issue
Block a user