mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Add import task
This commit is contained in:
@@ -163,9 +163,13 @@ class _CreateRootUserPage extends State<CreateRootUserPage>
|
||||
_log.warning(
|
||||
"Failed to set skipCreateRootUser.");
|
||||
} else {
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
if (context.mounted) {
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
}
|
||||
}).catchError((e) {
|
||||
_log.warning(
|
||||
@@ -183,42 +187,58 @@ class _CreateRootUserPage extends State<CreateRootUserPage>
|
||||
_createRootUser(_username, _password)
|
||||
.then((re) {
|
||||
if (re) {
|
||||
clearAllStates(context);
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
} else {
|
||||
if (!_createdUser) {
|
||||
if (context.mounted) {
|
||||
clearAllStates(context);
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
} else {
|
||||
if (!_createdUser) {
|
||||
if (context.mounted) {
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
final snackBar = SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context)!
|
||||
.incorrectUserPassword));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isCreated = false;
|
||||
});
|
||||
if (context.mounted) {
|
||||
final snackBar = SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context)!
|
||||
.incorrectUserPassword));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isCreated = false;
|
||||
});
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
}
|
||||
}).catchError((e) {
|
||||
_log.severe(
|
||||
"Failed to create root user:", e);
|
||||
final isNetworkError = e is! (int, String);
|
||||
final snackBar = SnackBar(
|
||||
content: Text(isNetworkError
|
||||
? AppLocalizations.of(context)!
|
||||
.networkError
|
||||
: AppLocalizations.of(context)!
|
||||
.internalError));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isCreated = false;
|
||||
});
|
||||
if (context.mounted) {
|
||||
final snackBar = SnackBar(
|
||||
content: Text(isNetworkError
|
||||
? AppLocalizations.of(context)!
|
||||
.networkError
|
||||
: AppLocalizations.of(context)!
|
||||
.internalError));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isCreated = false;
|
||||
});
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
});
|
||||
}
|
||||
: null,
|
||||
|
||||
@@ -108,7 +108,11 @@ class _LoginPageState extends State<LoginPage>
|
||||
auth.checkAuth().then((re) {
|
||||
_checkAuth = false;
|
||||
if (re) {
|
||||
build.go("/");
|
||||
if (build.mounted) {
|
||||
build.go("/");
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
}
|
||||
}).catchError((e) {
|
||||
_log.severe("Failed to check auth info:", e);
|
||||
@@ -190,33 +194,45 @@ class _LoginPageState extends State<LoginPage>
|
||||
});
|
||||
login(_username, _password).then((re) {
|
||||
if (re) {
|
||||
clearAllStates(context);
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
if (context.mounted) {
|
||||
clearAllStates(context);
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
} else {
|
||||
final snackBar = SnackBar(
|
||||
content: Text(
|
||||
i18n.incorrectUserPassword));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isLogin = false;
|
||||
});
|
||||
if (context.mounted) {
|
||||
final snackBar = SnackBar(
|
||||
content: Text(
|
||||
i18n.incorrectUserPassword));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isLogin = false;
|
||||
});
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
}
|
||||
}).catchError((e) {
|
||||
_log.severe("Failed to login:", e);
|
||||
final isNetworkError =
|
||||
e is! (int, String);
|
||||
final snackBar = SnackBar(
|
||||
content: Text(isNetworkError
|
||||
? i18n.networkError
|
||||
: i18n.internalError));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isLogin = false;
|
||||
});
|
||||
if (context.mounted) {
|
||||
final snackBar = SnackBar(
|
||||
content: Text(isNetworkError
|
||||
? i18n.networkError
|
||||
: i18n.internalError));
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(snackBar);
|
||||
setState(() {
|
||||
_isLogin = false;
|
||||
});
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
});
|
||||
}
|
||||
: null,
|
||||
|
||||
@@ -131,10 +131,14 @@ class _ServerUrlSettingsPage extends State<ServerUrlSettingsPage>
|
||||
.setString('baseUrl', _serverUrl + _apiPath)
|
||||
.then((re) {
|
||||
if (re) {
|
||||
tryInitApi(context);
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
if (context.mounted) {
|
||||
tryInitApi(context);
|
||||
context.canPop()
|
||||
? context.pop()
|
||||
: context.go("/");
|
||||
} else {
|
||||
_log.warning("Context not mounted.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -217,6 +217,10 @@ class _TaskManagerPage extends State<TaskManagerPage>
|
||||
value: TaskType.exportZip,
|
||||
child: Text(i18n.createExportZipTask),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: TaskType.import,
|
||||
child: Text(i18n.createImportTask),
|
||||
),
|
||||
];
|
||||
},
|
||||
onSelected: (TaskType type) {
|
||||
@@ -224,6 +228,8 @@ class _TaskManagerPage extends State<TaskManagerPage>
|
||||
context.push("/dialog/new_download_task");
|
||||
} else if (type == TaskType.exportZip) {
|
||||
context.push("/dialog/new_export_zip_task");
|
||||
} else if (type == TaskType.import) {
|
||||
context.push("/dialog/new_import_task");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user