Export comics to cbzs.zip

This commit is contained in:
niuhuan 2023-07-04 11:34:28 +08:00
parent 60beaba9ad
commit 3d3f452c40
5 changed files with 106 additions and 0 deletions

View File

@ -1,2 +1,3 @@
v1.7.6 v1.7.6
- [x] ♻️ 优化发电 - [x] ♻️ 优化发电
- [x] ✨ 导出多个cbz的zip

View File

@ -641,6 +641,15 @@ class Method {
}); });
} }
/// cbzs.zip
Future<dynamic> exportComicDownloadToCbzsZip(String comicId, String dir, String name) {
return _flatInvoke("exportComicDownloadToCbzsZip", {
"comicId": comicId,
"dir": dir,
"name": name,
});
}
/// ///
Future<dynamic> importComicDownloadDir( Future<dynamic> importComicDownloadDir(
String dir, String dir,

View File

@ -116,6 +116,8 @@ class _DownloadExportToFileScreenState
Container(height: 10), Container(height: 10),
_exportToHtmlJPEGNotDownOverButton(), _exportToHtmlJPEGNotDownOverButton(),
Container(height: 10), Container(height: 10),
_exportComicDownloadToCbzsZipButton(),
Container(height: 10),
MaterialButton( MaterialButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).push( Navigator.of(context).push(
@ -446,6 +448,59 @@ class _DownloadExportToFileScreenState
); );
} }
Widget _exportComicDownloadToCbzsZipButton() {
return MaterialButton(
onPressed: () async {
if (!isPro) {
defaultToast(context, "请先发电鸭");
return;
}
var name = "";
if (currentExportRename()) {
var rename = await inputString(
context,
"请输入保存后的名称",
defaultValue: _task.title,
);
if (rename != null && rename.isNotEmpty) {
name = rename;
} else {
return;
}
} else {
if (!await confirmDialog(
context, "导出确认", "将您所选的漫画导出cbk.zip${showExportPath()}")) {
return;
}
}
try {
setState(() {
exporting = true;
});
await method.exportComicDownloadToCbzsZip(
widget.comicId,
await attachExportPath(),
name,
);
setState(() {
exportResult = "导出成功";
});
} catch (e) {
setState(() {
exportResult = "导出失败 $e";
});
} finally {
setState(() {
exporting = false;
});
}
},
child: _buildButtonInner(
'导出阅读器用cbk.zip\n(暂时不能导入)' + (!isPro ? "\n(发电后使用)" : ""),
),
);
}
Widget _buildButtonInner(String text) { Widget _buildButtonInner(String text) {
return LayoutBuilder( return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {

View File

@ -91,6 +91,13 @@ class _DownloadExportingGroupScreenState
), ),
), ),
Container(height: 20), Container(height: 20),
MaterialButton(
onPressed: _exportComicDownloadToCbzsZip,
child: _buildButtonInner(
"每部漫画都导出成cbz.zip" + (!isPro ? "\n(发电后使用)" : ""),
),
),
Container(height: 20),
], ],
); );
} }
@ -250,6 +257,38 @@ class _DownloadExportingGroupScreenState
} }
} }
_exportComicDownloadToCbzsZip() async {
if (!isPro) {
defaultToast(context, "请先发电鸭");
return;
}
if (!await confirmDialog(
context, "导出确认", "将您所选的漫画分别导出cbz.zip${showExportPath()}")) {
return;
}
try {
setState(() {
exporting = true;
});
final path = await attachExportPath();
for (var id in widget.idList) {
await method.exportComicDownloadToCbzsZip(
id,
path,
"",
);
}
exported = true;
} catch (err) {
e = err;
exportFail = true;
} finally {
setState(() {
exporting = false;
});
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return WillPopScope( return WillPopScope(

View File

@ -71,6 +71,8 @@ class _ProScreenState extends State<ProScreen> {
"\"关于\"界面找到维护地址可获得发电指引\n" "\"关于\"界面找到维护地址可获得发电指引\n"
"\n \"我曾经发过电\"可同步相应发电状态" "\n \"我曾经发过电\"可同步相应发电状态"
"\n \"我刚才发了电\"兑换神秘代码" "\n \"我刚才发了电\"兑换神秘代码"
"\n \"发电方式\"可以在网络不通时尝试更换"
"\n \"PAT入会\"是独立的发电方式"
"\n\n发电小功能: 多线程下载 / 批量导入导出下载", "\n\n发电小功能: 多线程下载 / 批量导入导出下载",
), ),
), ),