mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
优化使用体验
This commit is contained in:
@ -8,7 +8,7 @@ class TokenInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
options.headers["User-Agent"] =
|
||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
|
||||
"qinglong_client";
|
||||
|
||||
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ class UserInfoViewModel {
|
||||
|
||||
historyAccounts.insert(0, UserInfoBean(userName: _userName, password: _passWord, useSecretLogined: _useSecertLogined, host: _host));
|
||||
|
||||
while (historyAccounts.length > 5) {
|
||||
while (historyAccounts.length > 3) {
|
||||
historyAccounts.removeLast();
|
||||
}
|
||||
|
||||
|
||||
@ -74,111 +74,113 @@ class _AddTaskPageState extends ConsumerState<AddTaskPage> {
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"名称:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
focusNode: focusNode,
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入名称",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"名称:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
focusNode: focusNode,
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入名称",
|
||||
const Text(
|
||||
"命令:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
],
|
||||
TextField(
|
||||
controller: _commandController,
|
||||
maxLines: 4,
|
||||
minLines: 1,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入命令",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"定时:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: _cronController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入定时",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
const Text(
|
||||
"定时的cron不校验是否正确",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"命令:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: _commandController,
|
||||
maxLines: 4,
|
||||
minLines: 1,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入命令",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Text(
|
||||
"定时:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: _cronController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入定时",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
const Text(
|
||||
"定时的cron不校验是否正确",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -6,13 +6,6 @@ import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
import 'package:qinglong_app/utils/extension.dart';
|
||||
|
||||
var taskProvider = ChangeNotifierProvider((ref) => TaskViewModel());
|
||||
Map<int, int> sort = {
|
||||
0: 0,
|
||||
5: 1,
|
||||
3: 2,
|
||||
1: 3,
|
||||
4: 4,
|
||||
};
|
||||
|
||||
class TaskViewModel extends BaseViewModel {
|
||||
static const String allStr = "全部脚本";
|
||||
@ -45,27 +38,81 @@ class TaskViewModel extends BaseViewModel {
|
||||
}
|
||||
|
||||
void sortList() {
|
||||
list.sort((TaskBean a, TaskBean b) {
|
||||
int? sortA = (a.isPinned == 1 && a.status != 0)
|
||||
? 5
|
||||
: (a.isDisabled == 1 && a.status != 0)
|
||||
? 4
|
||||
: a.status;
|
||||
int? sortB = (b.isPinned == 1 && b.status != 0)
|
||||
? 5
|
||||
: (b.isDisabled == 1 && b.status != 0)
|
||||
? 4
|
||||
: b.status;
|
||||
|
||||
return sort[sortA!]! - sort[sortB!]!;
|
||||
});
|
||||
List<TaskBean> p = [];
|
||||
List<TaskBean> r = [];
|
||||
List<TaskBean> d = [];
|
||||
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (list[i].isPinned == 1) {
|
||||
list.insert(0, list.removeAt(i));
|
||||
p.add(list.removeAt(i));
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (list[i].status == 0) {
|
||||
r.add(list.removeAt(i));
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (list[i].isDisabled == 1) {
|
||||
d.add(list.removeAt(i));
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
p.sort((TaskBean a, TaskBean b) {
|
||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||
if (c == true) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
p.sort((a, b) {
|
||||
return (a.isDisabled ?? 0) - (b.isDisabled ?? 0);
|
||||
});
|
||||
|
||||
p.sort((a, b) {
|
||||
if (a.status == 0 && b.status == 0) {
|
||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||
if (c == true) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
return (a.status ?? 0) - (b.status ?? 0);
|
||||
}
|
||||
});
|
||||
|
||||
r.sort((a, b) {
|
||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||
if (c == true) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
d.sort((a, b) {
|
||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||
if (c == true) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
list.sort((a, b) {
|
||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||
if (c == true) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
list.insertAll(0, r);
|
||||
list.insertAll(0, p);
|
||||
list.addAll(d);
|
||||
|
||||
running.clear();
|
||||
running.addAll(list.where((element) => element.status == 0));
|
||||
neverRunning.clear();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
name: qinglong_app
|
||||
description: A new Flutter project.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.0.8+10
|
||||
version: 1.0.9+11
|
||||
|
||||
environment:
|
||||
sdk: ">=2.15.1 <3.0.0"
|
||||
|
||||
Reference in New Issue
Block a user