mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
format code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:qinglong_app/base/common_dialog.dart';
|
||||
import 'package:qinglong_app/utils/extension.dart';
|
||||
import 'base_viewmodel.dart';
|
||||
|
||||
class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
||||
@@ -21,7 +21,8 @@ class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
||||
_BaseStateWidgetState<T> createState() => _BaseStateWidgetState<T>();
|
||||
}
|
||||
|
||||
class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseStateWidget<T>> {
|
||||
class _BaseStateWidgetState<T extends BaseViewModel>
|
||||
extends ConsumerState<BaseStateWidget<T>> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -39,7 +40,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
|
||||
var viewModel = ref.watch<T>(widget.model);
|
||||
if (viewModel.failedToast != null) {
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
failDialog(context, viewModel.failedToast!);
|
||||
(viewModel.failedToast ?? "").toast();
|
||||
viewModel.clearToast();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// @author newtab on 2021/7/16
|
||||
///常用loading,fail,success对话框
|
||||
class CommonDialog extends StatelessWidget {
|
||||
final String? text;
|
||||
final CommonDialogState? commonDialogState;
|
||||
|
||||
const CommonDialog({Key? key, this.text, this.commonDialogState}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget loading;
|
||||
|
||||
if (commonDialogState == CommonDialogState.FAILED) {
|
||||
loading = const Icon(
|
||||
CupertinoIcons.clear_circled,
|
||||
size: 50,
|
||||
);
|
||||
} else if (commonDialogState == CommonDialogState.SUCCESS) {
|
||||
loading = const Icon(
|
||||
CupertinoIcons.checkmark_alt,
|
||||
size: 50,
|
||||
);
|
||||
} else {
|
||||
loading = LoadingIcon();
|
||||
}
|
||||
|
||||
Widget result = Material(
|
||||
color: Colors.transparent,
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: Color.fromRGBO(17, 17, 17, 0.7), borderRadius: BorderRadius.circular(5)),
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width / 2,
|
||||
minWidth: 122,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 15.0),
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 40,
|
||||
),
|
||||
child: IconTheme(
|
||||
data: const IconThemeData(
|
||||
color: Colors.white,
|
||||
size: 40.0,
|
||||
),
|
||||
child: loading),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
if (text != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15,
|
||||
right: 15,
|
||||
bottom: 15,
|
||||
),
|
||||
child: DefaultTextStyle(
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
child: Text(text!),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingIcon extends StatefulWidget {
|
||||
final double size;
|
||||
|
||||
LoadingIcon({this.size = 50.0});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => LoadingIconState();
|
||||
}
|
||||
|
||||
class LoadingIconState extends State<LoadingIcon> with SingleTickerProviderStateMixin {
|
||||
AnimationController? _controller;
|
||||
Animation<double>? _doubleAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(vsync: this, duration: const Duration(milliseconds: 1000))..repeat();
|
||||
_doubleAnimation = Tween(begin: 0.0, end: 360.0).animate(_controller!)
|
||||
..addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Transform.rotate(
|
||||
angle: _doubleAnimation!.value ~/ 30 * 30.0 * 0.0174533, child: Image.asset("assets/images/loading.png", width: widget.size, height: widget.size));
|
||||
}
|
||||
}
|
||||
|
||||
enum CommonDialogState {
|
||||
LOADING,
|
||||
SUCCESS,
|
||||
FAILED,
|
||||
}
|
||||
|
||||
typedef HideCallback = Future Function();
|
||||
|
||||
int backButtonIndex = 2;
|
||||
|
||||
OverlayEntry? overlay;
|
||||
|
||||
HideCallback showCommonDialog(
|
||||
BuildContext context, {
|
||||
String? text,
|
||||
bool backButtonClose = false,
|
||||
CommonDialogState commonDialogState = CommonDialogState.LOADING,
|
||||
}) {
|
||||
Completer<VoidCallback> result = Completer<VoidCallback>();
|
||||
var backButtonName = 'QL_Toast$backButtonIndex';
|
||||
BackButtonInterceptor.add((stopDefaultButtonEvent, _) {
|
||||
if (backButtonClose) {
|
||||
result.future.then((hide) {
|
||||
hide();
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}, zIndex: backButtonIndex, name: backButtonName);
|
||||
backButtonIndex++;
|
||||
|
||||
if (overlay != null && overlay!.mounted) {
|
||||
overlay?.remove();
|
||||
overlay = null;
|
||||
}
|
||||
overlay = OverlayEntry(
|
||||
maintainState: true,
|
||||
builder: (_) => WillPopScope(
|
||||
onWillPop: () async {
|
||||
var hide = await result.future;
|
||||
hide();
|
||||
return false;
|
||||
},
|
||||
child: CommonDialog(
|
||||
text: text,
|
||||
commonDialogState: commonDialogState,
|
||||
),
|
||||
),
|
||||
);
|
||||
result.complete(() {
|
||||
overlay?.remove();
|
||||
overlay = null;
|
||||
BackButtonInterceptor.removeByName(backButtonName);
|
||||
});
|
||||
if (overlay != null) {
|
||||
Overlay.of(context)?.insert(overlay!);
|
||||
}
|
||||
|
||||
return () async {
|
||||
var hide = await result.future;
|
||||
hide();
|
||||
};
|
||||
}
|
||||
|
||||
Future successDialog(BuildContext context, String text) {
|
||||
HideCallback hideCallback = showCommonDialog(
|
||||
context,
|
||||
text: text,
|
||||
commonDialogState: CommonDialogState.SUCCESS,
|
||||
backButtonClose: true,
|
||||
);
|
||||
return Future.delayed(
|
||||
Duration(
|
||||
milliseconds: 1000,
|
||||
), () {
|
||||
hideCallback();
|
||||
});
|
||||
}
|
||||
|
||||
Future failDialog(BuildContext context, String text) {
|
||||
HideCallback hideCallback = showCommonDialog(
|
||||
context,
|
||||
text: text,
|
||||
commonDialogState: CommonDialogState.FAILED,
|
||||
backButtonClose: true,
|
||||
);
|
||||
return Future.delayed(
|
||||
Duration(
|
||||
milliseconds: 1000,
|
||||
), () {
|
||||
hideCallback();
|
||||
});
|
||||
}
|
||||
|
||||
HideCallback loadingDialog(BuildContext context, {String? text}) {
|
||||
return showCommonDialog(
|
||||
context,
|
||||
text: text,
|
||||
commonDialogState: CommonDialogState.LOADING,
|
||||
backButtonClose: true,
|
||||
);
|
||||
}
|
||||
@@ -10,9 +10,10 @@ import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
||||
import 'url.dart';
|
||||
|
||||
class Api {
|
||||
static Future<HttpResponse<LoginBean>> login(String userName, String passWord) async {
|
||||
static Future<HttpResponse<LoginBean>> login(
|
||||
String userName, String passWord) async {
|
||||
return await Http.post<LoginBean>(
|
||||
Url.LOGIN,
|
||||
Url.login,
|
||||
{
|
||||
"username": userName,
|
||||
"password": passWord,
|
||||
@@ -21,90 +22,104 @@ class Api {
|
||||
}
|
||||
|
||||
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(List<String> crons) async {
|
||||
return await Http.put<NullResponse>(Url.RUN_TASKS, crons);
|
||||
static Future<HttpResponse<NullResponse>> startTasks(
|
||||
List<String> crons) async {
|
||||
return await Http.put<NullResponse>(Url.runTasks, crons);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
||||
return await Http.put<NullResponse>(Url.RUN_TASKS, crons);
|
||||
static Future<HttpResponse<NullResponse>> stopTasks(
|
||||
List<String> crons) async {
|
||||
return await Http.put<NullResponse>(Url.runTasks, crons);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<String>> inTimeLog(String cron) async {
|
||||
return await Http.get<String>(Url.INTIME_LOG(cron), null);
|
||||
return await Http.get<String>(Url.intimeLog(cron), null);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<TaskDetailBean>> taskDetail(String cron) async {
|
||||
return await Http.get<TaskDetailBean>(Url.TASK_DETAIL + cron, null);
|
||||
return await Http.get<TaskDetailBean>(Url.taskDetail + cron, null);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<TaskDetailBean>> addTask(String name, String command, String cron, {String? id}) async {
|
||||
static Future<HttpResponse<TaskDetailBean>> addTask(
|
||||
String name, String command, String cron,
|
||||
{String? id}) async {
|
||||
var data = {"name": name, "command": command, "schedule": cron};
|
||||
|
||||
if (id != null) {
|
||||
data["_id"] = id;
|
||||
return await Http.put<TaskDetailBean>(Url.ADD_TASK, data);
|
||||
return await Http.put<TaskDetailBean>(Url.addTask, data);
|
||||
}
|
||||
return await Http.post<TaskDetailBean>(Url.ADD_TASK, data);
|
||||
return await Http.post<TaskDetailBean>(Url.addTask, data);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> delTask(String cron) async {
|
||||
return await Http.delete<NullResponse>(Url.ADD_TASK, [cron]);
|
||||
return await Http.delete<NullResponse>(Url.addTask, [cron]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> pinTask(String cron) async {
|
||||
return await Http.put<NullResponse>(Url.PIN_TASK, [cron]);
|
||||
return await Http.put<NullResponse>(Url.pinTask, [cron]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> unpinTask(String cron) async {
|
||||
return await Http.put<NullResponse>(Url.UNPIN_TASK, [cron]);
|
||||
return await Http.put<NullResponse>(Url.unpinTask, [cron]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> enableTask(String cron) async {
|
||||
return await Http.put<NullResponse>(Url.ENABLE_TASK, [cron]);
|
||||
return await Http.put<NullResponse>(Url.enableTask, [cron]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> disableTask(String cron) async {
|
||||
return await Http.put<NullResponse>(Url.DISABLE_TASK, [cron]);
|
||||
return await Http.put<NullResponse>(Url.disableTask, [cron]);
|
||||
}
|
||||
|
||||
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 {
|
||||
return await Http.get<String>(Url.CONFIG_CONTENT + name, null);
|
||||
return await Http.get<String>(Url.configContent + name, null);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> saveFile(String name, String content) async {
|
||||
return await Http.post<NullResponse>(Url.SAVE_FILE, {"content": content, "name": name});
|
||||
static Future<HttpResponse<NullResponse>> saveFile(
|
||||
String name, String content) async {
|
||||
return await Http.post<NullResponse>(
|
||||
Url.saveFile, {"content": content, "name": name});
|
||||
}
|
||||
|
||||
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 {
|
||||
return await Http.put<NullResponse>(Url.ENABLE_ENVS, [id]);
|
||||
return await Http.put<NullResponse>(Url.enableEnvs, [id]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> disableEnv(String id) async {
|
||||
return await Http.put<NullResponse>(Url.DISABLE_ENVS, [id]);
|
||||
return await Http.put<NullResponse>(Url.disableEnvs, [id]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> delEnv(String id) async {
|
||||
return await Http.delete<NullResponse>(Url.DEL_ENV, [id]);
|
||||
return await Http.delete<NullResponse>(Url.delEnv, [id]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> addEnv(String name, String value, String remarks, {String? id}) async {
|
||||
static Future<HttpResponse<NullResponse>> addEnv(
|
||||
String name, String value, String remarks,
|
||||
{String? id}) async {
|
||||
var data = {"value": value, "remarks": remarks, "name": name};
|
||||
|
||||
if (id != null) {
|
||||
data["_id"] = id;
|
||||
return await Http.put<NullResponse>(Url.ADD_ENV, data);
|
||||
return await Http.put<NullResponse>(Url.addEnv, data);
|
||||
}
|
||||
return await Http.post<NullResponse>(Url.ADD_ENV, [data]);
|
||||
return await Http.post<NullResponse>(Url.addEnv, [data]);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> moveEnv(
|
||||
String id, int fromIndex, int toIndex) async {
|
||||
return await Http.put<NullResponse>(
|
||||
Url.envMove(id), {"fromIndex": fromIndex, "toIndex": toIndex});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ class Http {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<HttpResponse<T>> get<T>(String uri, Map<String, String>? json, {bool compute = true}) async {
|
||||
static Future<HttpResponse<T>> get<T>(String uri, Map<String, String>? json,
|
||||
{bool compute = true}) async {
|
||||
try {
|
||||
_init();
|
||||
var response = await _dio!.get(uri, queryParameters: json);
|
||||
@@ -48,11 +49,15 @@ class Http {
|
||||
if (e.response?.statusCode == 401) {
|
||||
exitLogin();
|
||||
}
|
||||
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||
return HttpResponse(
|
||||
success: false,
|
||||
message: e.response?.statusMessage ?? e.message,
|
||||
code: 0);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<HttpResponse<T>> post<T>(String uri, dynamic json, {bool compute = true}) async {
|
||||
static Future<HttpResponse<T>> post<T>(String uri, dynamic json,
|
||||
{bool compute = true}) async {
|
||||
try {
|
||||
_init();
|
||||
var response = await _dio!.post(uri, data: json);
|
||||
@@ -62,11 +67,15 @@ class Http {
|
||||
if (e.response?.statusCode == 401) {
|
||||
exitLogin();
|
||||
}
|
||||
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||
return HttpResponse(
|
||||
success: false,
|
||||
message: e.response?.statusMessage ?? e.message,
|
||||
code: 0);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<HttpResponse<T>> delete<T>(String uri, dynamic json, {bool compute = true}) async {
|
||||
static Future<HttpResponse<T>> delete<T>(String uri, dynamic json,
|
||||
{bool compute = true}) async {
|
||||
try {
|
||||
_init();
|
||||
var response = await _dio!.delete(uri, data: json);
|
||||
@@ -76,11 +85,15 @@ class Http {
|
||||
if (e.response?.statusCode == 401) {
|
||||
exitLogin();
|
||||
}
|
||||
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||
return HttpResponse(
|
||||
success: false,
|
||||
message: e.response?.statusMessage ?? e.message,
|
||||
code: 0);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<HttpResponse<T>> put<T>(String uri, dynamic json, {bool compute = true}) async {
|
||||
static Future<HttpResponse<T>> put<T>(String uri, dynamic json,
|
||||
{bool compute = true}) async {
|
||||
try {
|
||||
_init();
|
||||
var response = await _dio!.put(uri, data: json);
|
||||
@@ -89,7 +102,10 @@ class Http {
|
||||
if (e.response?.statusCode == 401) {
|
||||
exitLogin();
|
||||
}
|
||||
return HttpResponse(success: false, message: e.response?.statusMessage ?? e.message, code: 0);
|
||||
return HttpResponse(
|
||||
success: false,
|
||||
message: e.response?.statusMessage ?? e.message,
|
||||
code: 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +114,7 @@ class Http {
|
||||
static void exitLogin() {
|
||||
if (!pushedLoginPage) {
|
||||
pushedLoginPage = true;
|
||||
navigatorState.currentState?.pushReplacementNamed(Routes.route_LOGIN);
|
||||
navigatorState.currentState?.pushReplacementNamed(Routes.routeLogin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +198,8 @@ class HttpResponse<T> {
|
||||
late int code;
|
||||
T? bean;
|
||||
|
||||
HttpResponse({required this.success, this.message, required this.code, this.bean});
|
||||
HttpResponse(
|
||||
{required this.success, this.message, required this.code, this.bean});
|
||||
}
|
||||
|
||||
class DeserializeAction<T> {
|
||||
|
||||
@@ -6,13 +6,17 @@ import '../userinfo_viewmodel.dart';
|
||||
class TokenInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
if (getIt<UserInfoViewModel>().token != null && getIt<UserInfoViewModel>().token!.isNotEmpty) {
|
||||
options.headers["Authorization"] = "Bearer " + getIt<UserInfoViewModel>().token!;
|
||||
if (getIt<UserInfoViewModel>().token != null &&
|
||||
getIt<UserInfoViewModel>().token!.isNotEmpty) {
|
||||
options.headers["Authorization"] =
|
||||
"Bearer " + getIt<UserInfoViewModel>().token!;
|
||||
}
|
||||
|
||||
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";
|
||||
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";
|
||||
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
||||
options.queryParameters["t"] = (DateTime.now().millisecondsSinceEpoch~/1000).toString();
|
||||
options.queryParameters["t"] =
|
||||
(DateTime.now().millisecondsSinceEpoch ~/ 1000).toString();
|
||||
return handler.next(options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
class Url {
|
||||
static const LOGIN = "/api/user/login";
|
||||
static const TASKS = "/api/crons";
|
||||
static const RUN_TASKS = "/api/crons/run";
|
||||
static const STOP_TASKS = "/api/crons/stop";
|
||||
static const TASK_DETAIL = "/api/crons/";
|
||||
static const ADD_TASK = "/api/crons";
|
||||
static const PIN_TASK = "/api/crons/pin";
|
||||
static const UNPIN_TASK = "/api/crons/unpin";
|
||||
static const ENABLE_TASK = "/api/crons/enable";
|
||||
static const DISABLE_TASK = "/api/crons/disable";
|
||||
static const FILES = "/api/configs/files";
|
||||
static const CONFIG_CONTENT = "/api/configs/";
|
||||
static const SAVE_FILE = "/api/configs/save";
|
||||
static const ENVS = "/api/envs";
|
||||
static const ADD_ENV = "/api/envs";
|
||||
static const DEL_ENV = "/api/envs";
|
||||
static const DISABLE_ENVS = "/api/envs/disable";
|
||||
static const ENABLE_ENVS = "/api/envs/enable";
|
||||
static const login = "/api/user/login";
|
||||
static const tasks = "/api/crons";
|
||||
static const runTasks = "/api/crons/run";
|
||||
static const stopTasks = "/api/crons/stop";
|
||||
static const taskDetail = "/api/crons/";
|
||||
static const addTask = "/api/crons";
|
||||
static const pinTask = "/api/crons/pin";
|
||||
static const unpinTask = "/api/crons/unpin";
|
||||
static const enableTask = "/api/crons/enable";
|
||||
static const disableTask = "/api/crons/disable";
|
||||
static const files = "/api/configs/files";
|
||||
static const configContent = "/api/configs/";
|
||||
static const saveFile = "/api/configs/save";
|
||||
static const envs = "/api/envs";
|
||||
static const addEnv = "/api/envs";
|
||||
static const delEnv = "/api/envs";
|
||||
static const disableEnvs = "/api/envs/disable";
|
||||
static const enableEnvs = "/api/envs/enable";
|
||||
|
||||
static INTIME_LOG(String cronId) {
|
||||
static intimeLog(String cronId) {
|
||||
return "/api/crons/$cronId/log";
|
||||
}
|
||||
|
||||
static envMove(String envId) {
|
||||
return "/api/envs/$envId/move";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,19 +9,19 @@ import 'package:qinglong_app/module/task/add_task_page.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
|
||||
class Routes {
|
||||
static const String route_HomePage = "/home/homepage";
|
||||
static const String route_LOGIN = "/login";
|
||||
static const String route_AddTask = "/task/add";
|
||||
static const String route_AddEnv = "/env/add";
|
||||
static const String route_ConfigEdit = "/config/edit";
|
||||
static const String routeHomePage = "/home/homepage";
|
||||
static const String routeLogin = "/login";
|
||||
static const String routeAddTask = "/task/add";
|
||||
static const String routeAddEnv = "/env/add";
|
||||
static const String routeConfigEdit = "/config/edit";
|
||||
|
||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case route_HomePage:
|
||||
case routeHomePage:
|
||||
return MaterialPageRoute(builder: (context) => const HomePage());
|
||||
case route_LOGIN:
|
||||
case routeLogin:
|
||||
return MaterialPageRoute(builder: (context) => const LoginPage());
|
||||
case route_AddTask:
|
||||
case routeAddTask:
|
||||
if (settings.arguments != null) {
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => AddTaskPage(
|
||||
@@ -30,7 +30,7 @@ class Routes {
|
||||
} else {
|
||||
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
||||
}
|
||||
case route_AddEnv:
|
||||
case routeAddEnv:
|
||||
if (settings.arguments != null) {
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => AddEnvPage(
|
||||
@@ -39,7 +39,7 @@ class Routes {
|
||||
} else {
|
||||
return CupertinoPageRoute(builder: (context) => const AddEnvPage());
|
||||
}
|
||||
case route_ConfigEdit:
|
||||
case routeConfigEdit:
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => ConfigEditPage(
|
||||
(settings.arguments as Map)["title"],
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
String sp_UserINfo = "userinfo";
|
||||
String sp_Host = "host";
|
||||
String sp_Theme = "dart_mode";
|
||||
String sp_Theme = "dart_mode";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
///tabbar样式下方横条固定宽度
|
||||
class AbsUnderlineTabIndicator extends Decoration {
|
||||
const AbsUnderlineTabIndicator({
|
||||
@@ -44,7 +43,8 @@ class AbsUnderlineTabIndicator extends Decoration {
|
||||
}
|
||||
|
||||
class _UnderlinePainter extends BoxPainter {
|
||||
_UnderlinePainter(this.decoration, VoidCallback? onChanged) : super(onChanged);
|
||||
_UnderlinePainter(this.decoration, VoidCallback? onChanged)
|
||||
: super(onChanged);
|
||||
|
||||
final AbsUnderlineTabIndicator decoration;
|
||||
|
||||
@@ -56,7 +56,11 @@ class _UnderlinePainter extends BoxPainter {
|
||||
final Rect indicator = insets!.resolve(textDirection).deflateRect(rect);
|
||||
//取中间坐标
|
||||
double cw = (indicator.left + indicator.right) / 2;
|
||||
return Rect.fromLTWH(cw - decoration.wantWidth! / 2, indicator.bottom - borderSide!.width, decoration.wantWidth!, borderSide!.width);
|
||||
return Rect.fromLTWH(
|
||||
cw - decoration.wantWidth! / 2,
|
||||
indicator.bottom - borderSide!.width,
|
||||
decoration.wantWidth!,
|
||||
borderSide!.width);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -64,8 +68,9 @@ class _UnderlinePainter extends BoxPainter {
|
||||
assert(configuration.size != null);
|
||||
final Rect rect = offset & configuration.size!;
|
||||
final TextDirection textDirection = configuration.textDirection!;
|
||||
final Rect indicator = _indicatorRectFor(rect, textDirection).deflate(borderSide!.width / 2.0);
|
||||
final Rect indicator =
|
||||
_indicatorRectFor(rect, textDirection).deflate(borderSide!.width / 2.0);
|
||||
final Paint paint = borderSide!.toPaint()..strokeCap = StrokeCap.round;
|
||||
canvas.drawLine(indicator.bottomLeft, indicator.bottomRight, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class EmptyWidget extends ConsumerWidget {
|
||||
const EmptyWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context,WidgetRef ref) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -16,7 +16,7 @@ class EmptyWidget extends ConsumerWidget {
|
||||
"暂无数据",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color:ref.watch(themeProvider).themeColor.descColor(),
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -19,7 +19,7 @@ class QLCupertinoContextMenuAction extends StatefulWidget {
|
||||
this.isDestructiveAction = false,
|
||||
this.onPressed,
|
||||
this.trailingIcon,
|
||||
}) : assert(child != null),
|
||||
}) : assert(child != null),
|
||||
assert(isDefaultAction != null),
|
||||
assert(isDestructiveAction != null),
|
||||
super(key: key);
|
||||
@@ -45,10 +45,12 @@ class QLCupertinoContextMenuAction extends StatefulWidget {
|
||||
final IconData? trailingIcon;
|
||||
|
||||
@override
|
||||
State<QLCupertinoContextMenuAction> createState() => _QLCupertinoContextMenuActionState();
|
||||
State<QLCupertinoContextMenuAction> createState() =>
|
||||
_QLCupertinoContextMenuActionState();
|
||||
}
|
||||
|
||||
class _QLCupertinoContextMenuActionState extends State<QLCupertinoContextMenuAction> {
|
||||
class _QLCupertinoContextMenuActionState
|
||||
extends State<QLCupertinoContextMenuAction> {
|
||||
static const Color _kBackgroundColor = Color(0xFFEEEEEE);
|
||||
static const Color _kBackgroundColorPressed = Color(0xFFDDDDDD);
|
||||
static const double _kButtonHeight = 30.0;
|
||||
@@ -96,7 +98,6 @@ class _QLCupertinoContextMenuActionState extends State<QLCupertinoContextMenuAct
|
||||
return _kActionSheetActionStyle;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
|
||||
@@ -8,7 +8,7 @@ class UserInfoViewModel {
|
||||
|
||||
UserInfoViewModel() {
|
||||
String userInfoJson = SpUtil.getString(sp_UserINfo);
|
||||
_host = SpUtil.getString(sp_Host,defValue: "http://49.234.59.95:5700");
|
||||
_host = SpUtil.getString(sp_Host, defValue: "http://49.234.59.95:5700");
|
||||
if (userInfoJson.isNotEmpty) {
|
||||
_token = userInfoJson;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user