format code

This commit is contained in:
jyuesong
2022-01-18 09:29:45 +08:00
parent 917425c5de
commit 074580952f
40 changed files with 414 additions and 568 deletions

View File

@@ -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();
});
}

View File

@@ -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,
);
}

View File

@@ -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});
}
}

View File

@@ -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> {

View File

@@ -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);
}
}

View File

@@ -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";
}
}

View File

@@ -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"],

View File

@@ -1,3 +1,3 @@
String sp_UserINfo = "userinfo";
String sp_Host = "host";
String sp_Theme = "dart_mode";
String sp_Theme = "dart_mode";

View File

@@ -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);
}
}
}

View File

@@ -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(),
),
),
],

View File

@@ -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(

View File

@@ -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;
}

View File

@@ -1,4 +1,4 @@
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
@JsonConversionTarget()
class Json{}
class Json {}

View File

@@ -6,10 +6,8 @@ import 'package:qinglong_app/module/login/login_bean.dart';
import 'package:qinglong_app/module/task/task_bean.dart';
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
class JsonConversion$Json {
static M fromJson<M>(dynamic json) {
static M fromJson<M>(dynamic json) {
if (json is List) {
return _getListChildType<M>(json);
} else {
@@ -18,53 +16,57 @@ class JsonConversion$Json {
}
static M _fromJsonSingle<M>(dynamic json) {
String type = M.toString();
if(type == (ConfigBean).toString()){
return ConfigBean.jsonConversion(json) as M;
if (type == (ConfigBean).toString()) {
return ConfigBean.jsonConversion(json) as M;
}
if(type == (EnvBean).toString()){
return EnvBean.jsonConversion(json) as M;
if (type == (EnvBean).toString()) {
return EnvBean.jsonConversion(json) as M;
}
if(type == (LoginBean).toString()){
return LoginBean.jsonConversion(json) as M;
if (type == (LoginBean).toString()) {
return LoginBean.jsonConversion(json) as M;
}
if(type == (TaskBean).toString()){
return TaskBean.jsonConversion(json) as M;
if (type == (TaskBean).toString()) {
return TaskBean.jsonConversion(json) as M;
}
if(type == (TaskDetailBean).toString()){
return TaskDetailBean.jsonConversion(json) as M;
if (type == (TaskDetailBean).toString()) {
return TaskDetailBean.jsonConversion(json) as M;
}
throw Exception("not found");
}
static M _getListChildType<M>(List<dynamic> data) {
if(<ConfigBean>[] is M){
return data.map<ConfigBean>((e) => ConfigBean.jsonConversion(e)).toList() as M;
if (<ConfigBean>[] is M) {
return data.map<ConfigBean>((e) => ConfigBean.jsonConversion(e)).toList()
as M;
}
if(<EnvBean>[] is M){
if (<EnvBean>[] is M) {
return data.map<EnvBean>((e) => EnvBean.jsonConversion(e)).toList() as M;
}
if(<LoginBean>[] is M){
return data.map<LoginBean>((e) => LoginBean.jsonConversion(e)).toList() as M;
if (<LoginBean>[] is M) {
return data.map<LoginBean>((e) => LoginBean.jsonConversion(e)).toList()
as M;
}
if(<TaskBean>[] is M){
return data.map<TaskBean>((e) => TaskBean.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;
if (<TaskDetailBean>[] is M) {
return data
.map<TaskDetailBean>((e) => TaskDetailBean.jsonConversion(e))
.toList() as M;
}
throw Exception("not found");
}
}

View File

@@ -35,7 +35,8 @@ void main() async {
),
);
if (Platform.isAndroid) {
SystemUiOverlayStyle style = const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemUiOverlayStyle style =
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(style);
}
}
@@ -60,7 +61,9 @@ class MyApp extends ConsumerWidget {
home: Builder(
builder: (context) {
showDebugBtn(context, btnColor: Colors.blue);
return getIt<UserInfoViewModel>().isLogined() ? const HomePage() : LoginPage();
return getIt<UserInfoViewModel>().isLogined()
? const HomePage()
: LoginPage();
},
),
// home: LoginPage(),

View File

@@ -0,0 +1 @@

View File

@@ -2,7 +2,6 @@ import 'package:json_conversion_annotation/json_conversion_annotation.dart';
@JsonConversion()
class ConfigBean {
String? title;
String? value;
@@ -19,6 +18,7 @@ class ConfigBean {
data['value'] = this.value;
return data;
}
static ConfigBean jsonConversion(Map<String, dynamic> json) {
return ConfigBean.fromJson(json);
}

View File

@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qinglong_app/base/common_dialog.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/config/config_viewmodel.dart';
import 'package:qinglong_app/utils/extension.dart';
class ConfigEditPage extends ConsumerStatefulWidget {
final String content;
@@ -41,15 +41,16 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
InkWell(
onTap: () async {
if (value == null) {
failDialog(context, "请先点击保存");
"请先点击保存".toast();
return;
}
HttpResponse<NullResponse> response = await Api.saveFile(widget.title, _controller.text);
HttpResponse<NullResponse> response =
await Api.saveFile(widget.title, _controller.text);
if (response.success) {
ref.read(configProvider).loadContent(widget.title);
Navigator.of(context).pop();
} else {
failDialog(context, response.message ?? "");
(response.message ?? "").toast();
}
},
child: const Padding(

View File

@@ -16,7 +16,8 @@ class ConfigPage extends StatefulWidget {
ConfigPageState createState() => ConfigPageState();
}
class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMixin {
class ConfigPageState extends State<ConfigPage>
with SingleTickerProviderStateMixin {
TabController? _tabController;
@override
@@ -28,7 +29,8 @@ class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMi
Widget build(BuildContext context) {
return BaseStateWidget<ConfigViewModel>(
builder: (ref, model, child) {
_tabController ??= TabController(length: model.list.length, vsync: this);
_tabController ??=
TabController(length: model.list.length, vsync: this);
return Column(
children: [
@@ -60,7 +62,10 @@ class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMi
padding: const EdgeInsets.symmetric(
horizontal: 15,
),
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
theme: ref
.watch(themeProvider)
.themeColor
.codeEditorTheme(),
tabSize: 14,
),
),
@@ -80,9 +85,10 @@ class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMi
void editMe(WidgetRef ref) {
if (_tabController == null || _tabController!.length == 0) return;
navigatorState.currentState?.pushNamed(Routes.route_ConfigEdit, arguments: {
navigatorState.currentState?.pushNamed(Routes.routeConfigEdit, arguments: {
"title": ref.read(configProvider).list[_tabController?.index ?? 0].title,
"content": ref.read(configProvider).content[ref.read(configProvider).list[_tabController?.index ?? 0].title]
"content": ref.read(configProvider).content[
ref.read(configProvider).list[_tabController?.index ?? 0].title]
});
}
}

View File

@@ -1,14 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qinglong_app/base/common_dialog.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/env/env_bean.dart';
import 'package:qinglong_app/module/env/env_viewmodel.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_viewmodel.dart';
import 'package:qinglong_app/utils/extension.dart';
class AddEnvPage extends ConsumerStatefulWidget {
final EnvBean? taskBean;
@@ -180,11 +177,11 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
void submit() async {
if (_nameController.text.isEmpty) {
failDialog(context, "名称不能为空");
"名称不能为空".toast();
return;
}
if (_valueController.text.isEmpty) {
failDialog(context, "值不能为空");
"值不能为空".toast();
return;
}
@@ -196,12 +193,11 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
id: envBean.sId);
if (response.success) {
successDialog(context, "操作成功").then((value) {
ref.read(envProvider).updateEnv(envBean);
Navigator.of(context).pop();
});
"操作成功".toast();
ref.read(envProvider).updateEnv(envBean);
Navigator.of(context).pop();
} else {
failDialog(context, response.message ?? "");
(response.message ?? "").toast();
}
}
}

View File

@@ -12,12 +12,12 @@ class EnvBean {
EnvBean(
{this.value,
this.sId,
this.created,
this.status,
this.timestamp,
this.name,
this.remarks});
this.sId,
this.created,
this.status,
this.timestamp,
this.name,
this.remarks});
EnvBean.fromJson(Map<String, dynamic> json) {
value = json['value'];
@@ -40,7 +40,8 @@ class EnvBean {
data['remarks'] = this.remarks;
return data;
}
static EnvBean jsonConversion(Map<String, dynamic> json) {
return EnvBean.fromJson(json);
}
}
}

View File

@@ -1,17 +1,16 @@
import 'dart:io';
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:qinglong_app/base/base_state_widget.dart';
import 'package:qinglong_app/base/common_dialog.dart';
import 'package:qinglong_app/base/routes.dart';
import 'package:qinglong_app/base/theme.dart';
import 'package:qinglong_app/base/ui/empty_widget.dart';
import 'package:qinglong_app/module/env/env_bean.dart';
import 'package:qinglong_app/module/env/env_viewmodel.dart';
import 'package:qinglong_app/utils/extension.dart';
class EnvPage extends StatefulWidget {
const EnvPage({Key? key}) : super(key: key);
@@ -50,14 +49,12 @@ class _EnvPageState extends State<EnvPage> {
return model.loadData(false);
},
child: ReorderableListView(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
header: searchCell(ref),
onReorder: (int oldIndex, int newIndex) {
if (list.length != model.list.length) {
WidgetsBinding.instance
?.addPostFrameCallback((timeStamp) {
failDialog(context, "请先清空搜索关键词");
});
"请先清空搜索关键词".toast();
return;
}
@@ -68,7 +65,7 @@ class _EnvPageState extends State<EnvPage> {
}
final EnvBean item = model.list.removeAt(oldIndex);
model.list.insert(newIndex, item);
model.update();
model.update(item.sId ?? "", newIndex, oldIndex);
});
},
children: list,
@@ -146,7 +143,7 @@ class EnvItemCell extends StatelessWidget {
flex: 1,
onPressed: (_) {
Navigator.of(context)
.pushNamed(Routes.route_AddEnv, arguments: bean);
.pushNamed(Routes.routeAddEnv, arguments: bean);
},
foregroundColor: Colors.white,
icon: CupertinoIcons.pencil,

View File

@@ -19,7 +19,6 @@ class EnvViewModel extends BaseViewModel {
if (result.success && result.bean != null) {
list.clear();
list.addAll(result.bean!);
sortList();
success();
} else {
list.clear();
@@ -27,12 +26,6 @@ class EnvViewModel extends BaseViewModel {
}
}
void sortList() {
list.sort((a, b) {
return a.status!.compareTo(b.status!);
});
}
Future<void> delEnv(String id) async {
HttpResponse<NullResponse> result = await Api.delEnv(id);
if (result.success) {
@@ -61,7 +54,6 @@ class EnvViewModel extends BaseViewModel {
if (response.success) {
list.firstWhere((element) => element.sId == sId).status = 0;
sortList();
success();
} else {
failToast(response.message, notify: true);
@@ -71,14 +63,15 @@ class EnvViewModel extends BaseViewModel {
if (response.success) {
list.firstWhere((element) => element.sId == sId).status = 1;
sortList();
success();
} else {
failToast(response.message, notify: true);
}
}
}
void update(){
// update
void update(String id, int newIndex, int oldIndex) async {
await Api.moveEnv(id, oldIndex, newIndex);
loadData(false);
}
}

View File

@@ -38,7 +38,7 @@ class _HomePageState extends ConsumerState<HomePage> {
actions.add(InkWell(
onTap: () {
Navigator.of(context).pushNamed(
Routes.route_AddTask,
Routes.routeAddTask,
);
},
child: const Padding(
@@ -58,7 +58,7 @@ class _HomePageState extends ConsumerState<HomePage> {
actions.add(InkWell(
onTap: () {
Navigator.of(context).pushNamed(
Routes.route_AddEnv,
Routes.routeAddEnv,
);
},
child: const Padding(

View File

@@ -11,11 +11,11 @@ class LoginBean {
LoginBean(
{this.token,
this.lastip,
this.lastaddr,
this.lastlogon,
this.retries,
this.platform});
this.lastip,
this.lastaddr,
this.lastlogon,
this.retries,
this.platform});
LoginBean.fromJson(Map<String, dynamic> json) {
token = json['token'];
@@ -36,6 +36,7 @@ class LoginBean {
data['platform'] = this.platform;
return data;
}
static LoginBean jsonConversion(Map<String, dynamic> json) {
return LoginBean.fromJson(json);
}

View File

@@ -1,13 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qinglong_app/base/common_dialog.dart';
import 'package:qinglong_app/base/http/api.dart';
import 'package:qinglong_app/base/http/http.dart';
import 'package:qinglong_app/base/routes.dart';
import 'package:qinglong_app/base/theme.dart';
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
import 'package:qinglong_app/main.dart';
import 'package:qinglong_app/utils/extension.dart';
import 'package:qinglong_app/utils/utils.dart';
import 'login_bean.dart';
@@ -180,24 +180,24 @@ class _LoginPageState extends ConsumerState<LoginPage> {
isLoading,
child: CupertinoButton(
color: (_hostController.text.isNotEmpty &&
_userNameController.text.isNotEmpty &&
_passwordController.text.isNotEmpty &&
!isLoading)
_userNameController.text.isNotEmpty &&
_passwordController.text.isNotEmpty &&
!isLoading)
? ref
.watch(themeProvider)
.themeColor
.buttonBgColor()
.watch(themeProvider)
.themeColor
.buttonBgColor()
: Theme.of(context)
.primaryColor
.withOpacity(0.4),
.primaryColor
.withOpacity(0.4),
child: isLoading
? const CupertinoActivityIndicator()
: const Text(
"登 录",
style: TextStyle(
fontSize: 16,
),
),
"登 录",
style: TextStyle(
fontSize: 16,
),
),
onPressed: () {
Http.pushedLoginPage = false;
Utils.hideKeyBoard(context);
@@ -227,9 +227,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
HttpResponse<LoginBean> response = await Api.login(userName, password);
if (response.success) {
getIt<UserInfoViewModel>().updateToken(response.bean?.token ?? "");
Navigator.of(context).pushReplacementNamed(Routes.route_HomePage);
Navigator.of(context).pushReplacementNamed(Routes.routeHomePage);
} else {
failDialog(context, response.message ?? "请检查网络情况");
(response.message ?? "请检查网络情况").toast();
isLoading = false;
setState(() {});
}

View File

@@ -213,7 +213,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
),
onPressed: () {
getIt<UserInfoViewModel>().updateToken("");
Navigator.of(context).pushReplacementNamed(Routes.route_LOGIN);
Navigator.of(context)
.pushReplacementNamed(Routes.routeLogin);
}),
),
),

View File

@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qinglong_app/base/common_dialog.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/task/task_bean.dart';
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
import 'package:qinglong_app/module/task/task_viewmodel.dart';
import 'package:qinglong_app/utils/extension.dart';
class AddTaskPage extends ConsumerStatefulWidget {
final TaskBean? taskBean;
@@ -180,15 +180,15 @@ class _AddTaskPageState extends ConsumerState<AddTaskPage> {
void submit() async {
if (_nameController.text.isEmpty) {
failDialog(context, "任务名称不能为空");
"任务名称不能为空".toast();
return;
}
if (_commandController.text.isEmpty) {
failDialog(context, "命令不能为空");
"命令不能为空".toast();
return;
}
if (_cronController.text.isEmpty) {
failDialog(context, "定时不能为空");
"定时不能为空".toast();
return;
}
@@ -200,12 +200,11 @@ class _AddTaskPageState extends ConsumerState<AddTaskPage> {
id: taskBean.sId);
if (response.success) {
successDialog(context, "操作成功").then((value) {
ref.read(taskProvider).updateBean(taskBean);
Navigator.of(context).pop();
});
"操作成功".toast();
ref.read(taskProvider).updateBean(taskBean);
Navigator.of(context).pop();
} else {
failDialog(context, response.message ?? "");
response.message.toast();
}
}
}

View File

@@ -9,7 +9,8 @@ class InTimeLogPage extends StatefulWidget {
final String cronId;
final bool needTimer;
const InTimeLogPage(this.cronId, this.needTimer, {Key? key}) : super(key: key);
const InTimeLogPage(this.cronId, this.needTimer, {Key? key})
: super(key: key);
@override
_InTimeLogPageState createState() => _InTimeLogPageState();

View File

@@ -17,17 +17,17 @@ class TaskDetailBean {
TaskDetailBean(
{this.name,
this.command,
this.schedule,
this.saved,
this.sId,
this.created,
this.status,
this.timestamp,
this.isSystem,
this.isDisabled,
this.logPath,
this.isPinned});
this.command,
this.schedule,
this.saved,
this.sId,
this.created,
this.status,
this.timestamp,
this.isSystem,
this.isDisabled,
this.logPath,
this.isPinned});
TaskDetailBean.fromJson(Map<String, dynamic> json) {
name = json['name'];

View File

@@ -27,7 +27,7 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
builder: (WidgetRef context, TaskDetailViewModel value, Widget? child) {
return Container();
},
onReady: (model){
onReady: (model) {
model.loadDetail(widget.taskBean.sId!);
},
),

View File

@@ -4,7 +4,8 @@ import 'package:qinglong_app/base/http/api.dart';
import 'package:qinglong_app/base/http/http.dart';
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
var taskDetailProvider = AutoDisposeChangeNotifierProvider<TaskDetailViewModel>((ref) {
var taskDetailProvider =
AutoDisposeChangeNotifierProvider<TaskDetailViewModel>((ref) {
return TaskDetailViewModel();
});

View File

@@ -196,7 +196,7 @@ class TaskItemCell extends StatelessWidget {
onPressed: () {
Navigator.of(context).pop();
Navigator.of(context)
.pushNamed(Routes.route_AddTask, arguments: bean);
.pushNamed(Routes.routeAddTask, arguments: bean);
},
trailingIcon: CupertinoIcons.pencil_outline,
),
@@ -435,7 +435,7 @@ class TaskItemCell extends StatelessWidget {
onPressed: () {
Navigator.pop(context);
Navigator.of(context)
.pushNamed(Routes.route_AddTask, arguments: bean);
.pushNamed(Routes.routeAddTask, arguments: bean);
},
),
CupertinoActionSheetAction(

View File

@@ -7,7 +7,7 @@ class QlNavigatorObserver extends NavigatorObserver {
@override
void didPush(Route route, Route? previousRoute) {
super.didPush(route, previousRoute);
if (Routes.route_LOGIN == route.settings.name) {
if (Routes.routeLogin == route.settings.name) {
isInLoginPage = true;
} else {
isInLoginPage = false;

View File

@@ -1,14 +1,13 @@
import 'package:flutter/material.dart';
const qinglongLightTheme = {
'root':
TextStyle(color: Color(0xff333333), backgroundColor: Color(0xffffffff)),
TextStyle(color: Color(0xff333333), backgroundColor: Color(0xffffffff)),
'comment': TextStyle(color: Color(0xff999988), fontStyle: FontStyle.italic),
'quote': TextStyle(color: Color(0xff999988), fontStyle: FontStyle.italic),
'keyword': TextStyle(color: Color(0xff333333), fontWeight: FontWeight.bold),
'selector-tag':
TextStyle(color: Color(0xff333333), fontWeight: FontWeight.bold),
TextStyle(color: Color(0xff333333), fontWeight: FontWeight.bold),
'subst': TextStyle(color: Color(0xff333333), fontWeight: FontWeight.normal),
'number': TextStyle(color: Color(0xff008080)),
'literal': TextStyle(color: Color(0xff008080)),
@@ -19,12 +18,12 @@ const qinglongLightTheme = {
'title': TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
'section': TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
'selector-id':
TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
'type': TextStyle(color: Color(0xff445588), fontWeight: FontWeight.bold),
'tag': TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
'name': TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
'attribute':
TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
'regexp': TextStyle(color: Color(0xff009926)),
'link': TextStyle(color: Color(0xff009926)),
'symbol': TextStyle(color: Color(0xff990073)),
@@ -39,13 +38,12 @@ const qinglongLightTheme = {
};
const qinglongDarkTheme = {
'root':
TextStyle(color: Color(0xff333333), backgroundColor: Colors.black),
'root': TextStyle(color: Color(0xff333333), backgroundColor: Colors.black),
'comment': TextStyle(color: Color(0xff999988), fontStyle: FontStyle.italic),
'quote': TextStyle(color: Color(0xff999988), fontStyle: FontStyle.italic),
'keyword': TextStyle(color: Color(0xff333333), fontWeight: FontWeight.bold),
'selector-tag':
TextStyle(color: Color(0xff333333), fontWeight: FontWeight.bold),
TextStyle(color: Color(0xff333333), fontWeight: FontWeight.bold),
'subst': TextStyle(color: Color(0xff333333), fontWeight: FontWeight.normal),
'number': TextStyle(color: Color(0xff008080)),
'literal': TextStyle(color: Color(0xff008080)),
@@ -56,12 +54,12 @@ const qinglongDarkTheme = {
'title': TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
'section': TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
'selector-id':
TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
TextStyle(color: Color(0xff990000), fontWeight: FontWeight.bold),
'type': TextStyle(color: Color(0xff445588), fontWeight: FontWeight.bold),
'tag': TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
'name': TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
'attribute':
TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
TextStyle(color: Color(0xff000080), fontWeight: FontWeight.normal),
'regexp': TextStyle(color: Color(0xff009926)),
'link': TextStyle(color: Color(0xff009926)),
'symbol': TextStyle(color: Color(0xff990073)),

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fluttertoast/fluttertoast.dart';
extension ContextExt on BuildContext {
T read<T>(ProviderBase<T> provider) {
@@ -10,3 +11,15 @@ extension ContextExt on BuildContext {
return (this as WidgetRef).watch<T>(provider);
}
}
extension StringExt on String? {
void toast() {
if (this == null || this!.isEmpty) return;
Fluttertoast.showToast(
msg: this!,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
);
}
}

View File

@@ -56,7 +56,8 @@ class SpUtil {
}
/// get obj list.
static List<T>? getObjList<T>(String key, T f(Map v), {List<T> defValue = const []}) {
static List<T>? getObjList<T>(String key, T f(Map v),
{List<T> defValue = const []}) {
List<Map>? dataList = getObjectList(key);
List<T>? list = dataList?.map((value) {
return f(value);
@@ -123,7 +124,8 @@ class SpUtil {
}
/// get string list.
static List<String> getStringList(String key, {List<String> defValue = const []}) {
static List<String> getStringList(String key,
{List<String> defValue = const []}) {
if (_prefs == null) return defValue;
return _prefs!.getStringList(key) ?? defValue;
}
@@ -168,4 +170,4 @@ class SpUtil {
static bool isInitialized() {
return _prefs != null;
}
}
}

View File

@@ -5,238 +5,238 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "22.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.2"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.8"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.8.2"
back_button_interceptor:
dependency: "direct main"
description:
name: back_button_interceptor
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.1"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.4"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.7"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.2.3"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.1.1"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "8.1.3"
version: "8.1.4"
change_app_package_name:
dependency: "direct dev"
description:
name: change_app_package_name
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.3"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.5"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.4"
dio_log:
dependency: "direct main"
description:
name: dio_log
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
drag_and_drop_lists:
dependency: "direct main"
description:
name: drag_and_drop_lists
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.2+2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.1.2"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
flutter:
@@ -248,49 +248,49 @@ packages:
dependency: "direct dev"
description:
name: flutter_app_name
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.1"
flutter_highlight:
dependency: "direct main"
description:
name: flutter_highlight
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.0"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.2"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
flutter_native_splash:
dependency: "direct dev"
description:
name: flutter_native_splash
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.3"
flutter_riverpod:
dependency: "direct main"
description:
name: flutter_riverpod
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
flutter_slidable:
dependency: "direct main"
description:
name: flutter_slidable
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
flutter_test:
@@ -303,312 +303,319 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
url: "https://pub.flutter-io.cn"
source: hosted
version: "8.0.8"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.2"
get_it:
dependency: "direct main"
description:
name: get_it
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.2.0"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
highlight:
dependency: transitive
description:
name: highlight
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.0"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.1"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.17.0"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.3"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.4.0"
json_conversion:
dependency: "direct dev"
description:
name: json_conversion
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.4"
json_conversion_annotation:
dependency: "direct main"
description:
name: json_conversion_annotation
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.4"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
logger:
dependency: "direct main"
description:
name: logger
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.2"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.5"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.5"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.11.1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.4.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.2"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.0"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.2.4"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
riverpod:
dependency: transitive
description:
name: riverpod
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.12"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.10"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.9"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.4"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.4"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
sky_engine:
@@ -620,140 +627,140 @@ packages:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0"
state_notifier:
dependency: transitive
description:
name: state_notifier
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.1"
version: "0.7.2+1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
synchronized:
dependency: "direct main"
description:
name: synchronized
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
universal_io:
dependency: transitive
description:
name: universal_io
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.4"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.3"
version: "2.3.6"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.3.1"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
sdks:

View File

@@ -25,6 +25,7 @@ dependencies:
get_it: ^7.2.0
flutter_highlight: ^0.7.0
drag_and_drop_lists: ^0.3.2+2
fluttertoast: ^8.0.8
dev_dependencies:
flutter_native_splash: ^1.3.3

View File

@@ -14,7 +14,4 @@ import 'package:qinglong_app/main.dart';
import 'package:qinglong_app/module/login/login_bean.dart';
import 'package:qinglong_app/module/login/login_viewmodel.dart';
void main() {
}
void main() {}