mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
task log
This commit is contained in:
@@ -29,7 +29,7 @@ class QlAppBar extends StatelessWidget with PreferredSizeWidget {
|
|||||||
child: const Center(
|
child: const Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
CupertinoIcons.left_chevron,
|
CupertinoIcons.left_chevron,
|
||||||
size: 20,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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/others/login_log/login_log_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/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';
|
||||||
|
|
||||||
@@ -16,6 +18,8 @@ class Routes {
|
|||||||
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 const String routeLoginLog = "/log/login";
|
||||||
|
static const String routeTaskLog = "/log/task";
|
||||||
|
static const String routeTaskLogDetail = "/log/taskDetail";
|
||||||
|
|
||||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
@@ -52,6 +56,15 @@ class Routes {
|
|||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
builder: (context) => const LoginLogPage(),
|
builder: (context) => const LoginLogPage(),
|
||||||
);
|
);
|
||||||
|
case routeTaskLog:
|
||||||
|
return CupertinoPageRoute(
|
||||||
|
builder: (context) => const TaskLogPage(),
|
||||||
|
);
|
||||||
|
case routeTaskLogDetail:
|
||||||
|
return CupertinoPageRoute(
|
||||||
|
builder: (context) => TaskLogDetailPage(
|
||||||
|
title: settings.arguments as String,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -90,26 +90,34 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
const Divider(
|
const Divider(
|
||||||
indent: 15,
|
indent: 15,
|
||||||
),
|
),
|
||||||
Padding(
|
GestureDetector(
|
||||||
padding: const EdgeInsets.symmetric(
|
behavior: HitTestBehavior.opaque,
|
||||||
vertical: 8,
|
onTap: () {
|
||||||
horizontal: 15,
|
Navigator.of(context).pushNamed(
|
||||||
),
|
Routes.routeTaskLog,
|
||||||
child: Row(
|
);
|
||||||
children: [
|
},
|
||||||
Text(
|
child: Padding(
|
||||||
"任务日志",
|
padding: const EdgeInsets.symmetric(
|
||||||
style: TextStyle(
|
vertical: 8,
|
||||||
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
horizontal: 15,
|
||||||
fontSize: 16,
|
),
|
||||||
|
child: Row(
|
||||||
|
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,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(
|
||||||
|
|||||||
65
lib/module/others/task_log/task_log_detail_page.dart
Normal file
65
lib/module/others/task_log/task_log_detail_page.dart
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
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/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
class TaskLogDetailPage extends ConsumerStatefulWidget {
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
const TaskLogDetailPage({
|
||||||
|
Key? key,
|
||||||
|
required this.title,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_TaskLogDetailPageState createState() => _TaskLogDetailPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TaskLogDetailPageState extends ConsumerState<TaskLogDetailPage> {
|
||||||
|
String? content;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: "任务日志详情",
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: SelectableText(
|
||||||
|
(content == null || content!.isEmpty)?"暂无数据":content!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadData() async {
|
||||||
|
HttpResponse<String> response = await Api.taskLogDetail(
|
||||||
|
widget.title,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
content = response.bean;
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
response.message?.toast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:qinglong_app/base/http/api.dart';
|
import 'package:qinglong_app/base/http/api.dart';
|
||||||
import 'package:qinglong_app/base/http/http.dart';
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
import 'package:qinglong_app/base/ql_app_bar.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/base/routes.dart';
|
||||||
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/utils/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
import 'package:qinglong_app/utils/utils.dart';
|
|
||||||
|
|
||||||
/// @author NewTab
|
/// @author NewTab
|
||||||
class TaskLogPage extends ConsumerStatefulWidget {
|
class TaskLogPage extends ConsumerStatefulWidget {
|
||||||
@@ -16,11 +17,12 @@ class TaskLogPage extends ConsumerStatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TaskLogPageState extends ConsumerState<TaskLogPage> {
|
class _TaskLogPageState extends ConsumerState<TaskLogPage> {
|
||||||
|
List<TaskLogBean> list = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -33,7 +35,64 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> {
|
|||||||
},
|
},
|
||||||
title: "任务日志",
|
title: "任务日志",
|
||||||
),
|
),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
TaskLogBean item = list[index];
|
||||||
|
|
||||||
|
return ColoredBox(
|
||||||
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
|
child: (item.isDir ?? false)
|
||||||
|
? ExpansionTile(
|
||||||
|
title: Text(
|
||||||
|
item.name ?? "",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
children: item.files!
|
||||||
|
.map((e) => ListTile(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: e);
|
||||||
|
},
|
||||||
|
title: Text(
|
||||||
|
e ?? "",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
)
|
||||||
|
: ListTile(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: item.name);
|
||||||
|
},
|
||||||
|
title: Text(
|
||||||
|
item.name ?? "",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: list.length,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> loadData() async {
|
||||||
|
HttpResponse<List<TaskLogBean>> response = await Api.taskLog();
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
list.clear();
|
||||||
|
list.addAll(response.bean ?? []);
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
response.message?.toast();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user