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
lib/module/env/add_env_page.dart
vendored
8
lib/module/env/add_env_page.dart
vendored
@@ -186,8 +186,12 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
|
||||
envBean.value = _valueController.text;
|
||||
envBean.remarks = _remarkController.text;
|
||||
HttpResponse<NullResponse> response = await Api.addEnv(
|
||||
_nameController.text, _valueController.text, _remarkController.text,
|
||||
id: envBean.id,nId: envBean.nId,);
|
||||
_nameController.text,
|
||||
_valueController.text,
|
||||
_remarkController.text,
|
||||
id: envBean.id,
|
||||
nId: envBean.nId,
|
||||
);
|
||||
|
||||
if (response.success) {
|
||||
(envBean.sId == null) ? "新增成功" : "修改成功".toast();
|
||||
|
||||
13
lib/module/env/env_bean.dart
vendored
13
lib/module/env/env_bean.dart
vendored
@@ -12,7 +12,14 @@ class EnvBean {
|
||||
String? name;
|
||||
String? remarks;
|
||||
|
||||
EnvBean({this.value, this.sId, this.created, this.status, this.timestamp, this.name, this.remarks});
|
||||
EnvBean(
|
||||
{this.value,
|
||||
this.sId,
|
||||
this.created,
|
||||
this.status,
|
||||
this.timestamp,
|
||||
this.name,
|
||||
this.remarks});
|
||||
|
||||
get nId => _id;
|
||||
|
||||
@@ -20,7 +27,9 @@ class EnvBean {
|
||||
value = json['value'];
|
||||
id = json['id'];
|
||||
_id = json['_id'];
|
||||
sId = json.containsKey('_id') ? json['_id'].toString() : (json.containsKey('id') ? json['id'].toString() : "");
|
||||
sId = json.containsKey('_id')
|
||||
? json['_id'].toString()
|
||||
: (json.containsKey('id') ? json['id'].toString() : "");
|
||||
created = int.tryParse(json['created'].toString());
|
||||
status = json['status'];
|
||||
timestamp = json['timestamp'];
|
||||
|
||||
13
lib/module/env/env_detail_page.dart
vendored
13
lib/module/env/env_detail_page.dart
vendored
@@ -36,7 +36,8 @@ class _TaskDetailPageState extends ConsumerState<EnvDetailPage> {
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: widget.envBean);
|
||||
Navigator.of(context)
|
||||
.pushNamed(Routes.routeAddEnv, arguments: widget.envBean);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
@@ -225,7 +226,9 @@ class _TaskDetailPageState extends ConsumerState<EnvDetailPage> {
|
||||
}
|
||||
|
||||
void enableTask() async {
|
||||
await ref.read(envProvider).enableEnv(widget.envBean.sId!, widget.envBean.status!);
|
||||
await ref
|
||||
.read(envProvider)
|
||||
.enableEnv(widget.envBean.sId!, widget.envBean.status!);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -322,14 +325,16 @@ class EnvDetailCell extends ConsumerWidget {
|
||||
}
|
||||
},
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
color:
|
||||
ref.watch(themeProvider).themeColor.descColor(),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
child: Align(alignment: Alignment.centerRight, child: icon!),
|
||||
child:
|
||||
Align(alignment: Alignment.centerRight, child: icon!),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
71
lib/module/env/env_page.dart
vendored
71
lib/module/env/env_page.dart
vendored
@@ -83,7 +83,8 @@ class _EnvPageState extends State<EnvPage> {
|
||||
],
|
||||
)
|
||||
: ReorderableListView(
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
header: searchCell(context, ref),
|
||||
onReorder: (int oldIndex, int newIndex) {
|
||||
if (list.length != model.list.length) {
|
||||
@@ -97,9 +98,11 @@ class _EnvPageState extends State<EnvPage> {
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
final EnvBean item = model.list.removeAt(oldIndex);
|
||||
final EnvBean item =
|
||||
model.list.removeAt(oldIndex);
|
||||
model.list.insert(newIndex, item);
|
||||
model.update(item.sId ?? "", newIndex, oldIndex);
|
||||
model.update(
|
||||
item.sId ?? "", newIndex, oldIndex);
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -145,7 +148,9 @@ class _EnvPageState extends State<EnvPage> {
|
||||
child: Text(
|
||||
EnvViewModel.allStr,
|
||||
style: TextStyle(
|
||||
color: currentState == EnvViewModel.allStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||
color: currentState == EnvViewModel.allStr
|
||||
? ref.watch(themeProvider).primaryColor
|
||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
@@ -155,7 +160,9 @@ class _EnvPageState extends State<EnvPage> {
|
||||
child: Text(
|
||||
EnvViewModel.enabledStr,
|
||||
style: TextStyle(
|
||||
color: currentState == EnvViewModel.enabledStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||
color: currentState == EnvViewModel.enabledStr
|
||||
? ref.watch(themeProvider).primaryColor
|
||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
@@ -165,8 +172,9 @@ class _EnvPageState extends State<EnvPage> {
|
||||
child: Text(
|
||||
EnvViewModel.disabledStr,
|
||||
style: TextStyle(
|
||||
color:
|
||||
currentState == EnvViewModel.disabledStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||
color: currentState == EnvViewModel.disabledStr
|
||||
? ref.watch(themeProvider).primaryColor
|
||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
@@ -199,7 +207,8 @@ class EnvItemCell extends StatelessWidget {
|
||||
final int index;
|
||||
final WidgetRef ref;
|
||||
|
||||
const EnvItemCell(this.bean, this.index, this.ref, {Key? key}) : super(key: key);
|
||||
const EnvItemCell(this.bean, this.index, this.ref, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -212,7 +221,8 @@ class EnvItemCell extends StatelessWidget {
|
||||
SlidableAction(
|
||||
backgroundColor: const Color(0xff5D5E70),
|
||||
onPressed: (_) {
|
||||
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: bean);
|
||||
Navigator.of(context)
|
||||
.pushNamed(Routes.routeAddEnv, arguments: bean);
|
||||
},
|
||||
foregroundColor: Colors.white,
|
||||
icon: CupertinoIcons.pencil_outline,
|
||||
@@ -223,7 +233,9 @@ class EnvItemCell extends StatelessWidget {
|
||||
enableEnv(context);
|
||||
},
|
||||
foregroundColor: Colors.white,
|
||||
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||
icon: bean.status == 0
|
||||
? Icons.dnd_forwardslash
|
||||
: Icons.check_circle_outline_sharp,
|
||||
),
|
||||
SlidableAction(
|
||||
backgroundColor: const Color(0xffEA4D3E),
|
||||
@@ -245,7 +257,8 @@ class EnvItemCell extends StatelessWidget {
|
||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.routeEnvDetail, arguments: bean);
|
||||
Navigator.of(context)
|
||||
.pushNamed(Routes.routeEnvDetail, arguments: bean);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
@@ -272,13 +285,22 @@ class EnvItemCell extends StatelessWidget {
|
||||
horizontal: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
border: Border.all(color: ref.watch(themeProvider).themeColor.descColor(), width: 1),
|
||||
borderRadius:
|
||||
BorderRadius.circular(3),
|
||||
border: Border.all(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.descColor(),
|
||||
width: 1),
|
||||
),
|
||||
child: Text(
|
||||
"${getIndexByIndex(context, index)}",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.descColor(),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
@@ -299,7 +321,10 @@ class EnvItemCell extends StatelessWidget {
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
@@ -315,7 +340,8 @@ class EnvItemCell extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Visibility(
|
||||
visible: bean.remarks != null && bean.remarks!.isNotEmpty,
|
||||
visible: bean.remarks != null &&
|
||||
bean.remarks!.isNotEmpty,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Text(
|
||||
@@ -324,7 +350,10 @@ class EnvItemCell extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.descColor(),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
@@ -358,7 +387,10 @@ class EnvItemCell extends StatelessWidget {
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.descColor(),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
@@ -375,7 +407,8 @@ class EnvItemCell extends StatelessWidget {
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
color:
|
||||
ref.watch(themeProvider).themeColor.descColor(),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
|
||||
5
lib/module/env/env_viewmodel.dart
vendored
5
lib/module/env/env_viewmodel.dart
vendored
@@ -15,7 +15,6 @@ class EnvViewModel extends BaseViewModel {
|
||||
List<EnvBean> disabledList = [];
|
||||
List<EnvBean> enabledList = [];
|
||||
|
||||
|
||||
Future<void> loadData([isLoading = true]) async {
|
||||
if (isLoading && list.isEmpty) {
|
||||
loading(notify: true);
|
||||
@@ -23,12 +22,12 @@ class EnvViewModel extends BaseViewModel {
|
||||
|
||||
HttpResponse<List<EnvBean>> result = await Api.envs("");
|
||||
|
||||
|
||||
if (result.success && result.bean != null) {
|
||||
list.clear();
|
||||
list.addAll(result.bean!);
|
||||
disabledList.clear();
|
||||
disabledList.addAll(list.where((element) => element.status == 1).toList());
|
||||
disabledList
|
||||
.addAll(list.where((element) => element.status == 1).toList());
|
||||
enabledList.clear();
|
||||
enabledList.addAll(list.where((element) => element.status == 0).toList());
|
||||
success();
|
||||
|
||||
Reference in New Issue
Block a user