Skip to content

Commit 9a19f66

Browse files
committed
🐛 fix export pdf
1 parent 1bfa463 commit 9a19f66

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

ci/version.info.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ v1.8.11
77
- [x] ♻️ 批量选择时,点击返回键会取消选择状态, 而不是直接返回上一页
88
- [x] ♻️ 增加长按删除下载,优化删除下载时的体验(不刷页面)
99
- [x] ♻️ 修改一些assets的命名
10+
- [x] 🐛 修复PDF不能导出
1011

1112
v1.8.18 ~ 1.8.10
1213

lib/basic/Method.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,19 @@ class Method {
622622
});
623623
}
624624

625+
/// 导出下载的图片到PDF文件夹
626+
Future<dynamic> exportComicDownloadToPDFFolder(
627+
String comicId,
628+
String dir,
629+
String name,
630+
) {
631+
return _flatInvoke("exportComicDownloadToPDFFolder", {
632+
"comicId": comicId,
633+
"dir": dir,
634+
"name": name,
635+
});
636+
}
637+
625638
/// 导出下载的图片到HTML+JPG
626639
Future<dynamic> exportComicDownloadJpegZip(
627640
String comicId,

lib/screens/DownloadExportToFileScreen.dart

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ class _DownloadExportToFileScreenState
114114
Container(height: 10),
115115
_exportToHtmlPdfButton(),
116116
Container(height: 10),
117+
_exportToHtmlPdfFolderButton(),
118+
Container(height: 10),
117119
_exportToJPEGSZIPButton(),
118120
Container(height: 10),
119121
_exportToHtmlJPEGNotDownOverButton(),
@@ -395,6 +397,57 @@ class _DownloadExportToFileScreenState
395397
);
396398
}
397399

400+
Widget _exportToHtmlPdfFolderButton() {
401+
return MaterialButton(
402+
onPressed: () async {
403+
if (!isPro) {
404+
defaultToast(context, "请先发电鸭");
405+
return;
406+
}
407+
var name = "";
408+
if (currentExportRename()) {
409+
var rename = await inputString(
410+
context,
411+
"请输入保存后的名称",
412+
defaultValue: _task.title,
413+
);
414+
if (rename != null && rename.isNotEmpty) {
415+
name = rename;
416+
} else {
417+
return;
418+
}
419+
} else {
420+
if (!await confirmDialog(
421+
context, "导出确认", "将您所选的漫画导出到文件夹, 每个章节一个PDF${showExportPath()}")) {
422+
return;
423+
}
424+
}
425+
try {
426+
setState(() {
427+
exporting = true;
428+
});
429+
await method.exportComicDownloadToPDFFolder(
430+
widget.comicId,
431+
await attachExportPath(),
432+
name,
433+
);
434+
setState(() {
435+
exportResult = "导出成功";
436+
});
437+
} catch (e) {
438+
setState(() {
439+
exportResult = "导出失败 $e";
440+
});
441+
} finally {
442+
setState(() {
443+
exporting = false;
444+
});
445+
}
446+
},
447+
child: _buildButtonInner('导出到文件夹, 每个章节一个PDF\n(可直接在相册中打开观看)'),
448+
);
449+
}
450+
398451
Widget _exportToJPEGSZIPButton() {
399452
return MaterialButton(
400453
onPressed: () async {

lib/screens/DownloadExportingGroupScreen.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ class _DownloadExportingGroupScreenState
9898
),
9999
),
100100
Container(height: 20),
101+
MaterialButton(
102+
onPressed: _exportToPdfFolder,
103+
child: _buildButtonInner(
104+
"每部漫画都导出到文件夹, 每个章节一个PDF" + (!isPro ? "\n(发电后使用)" : ""),
105+
),
106+
),
107+
Container(height: 20),
101108
MaterialButton(
102109
onPressed: _exportComicDownloadToCbzsZip,
103110
child: _buildButtonInner(
@@ -296,6 +303,38 @@ class _DownloadExportingGroupScreenState
296303
}
297304
}
298305

306+
_exportToPdfFolder() async {
307+
if (!isPro) {
308+
defaultToast(context, "请先发电鸭");
309+
return;
310+
}
311+
if (!await confirmDialog(
312+
context, "导出确认", "将您所选的漫画分别导出到文件夹, 每个章节一个PDF${showExportPath()}")) {
313+
return;
314+
}
315+
try {
316+
setState(() {
317+
exporting = true;
318+
});
319+
final path = await attachExportPath();
320+
for (var id in widget.idList) {
321+
await method.exportComicDownloadToPDFFolder(
322+
id,
323+
path,
324+
"",
325+
);
326+
}
327+
exported = true;
328+
} catch (err) {
329+
e = err;
330+
exportFail = true;
331+
} finally {
332+
setState(() {
333+
exporting = false;
334+
});
335+
}
336+
}
337+
299338
_exportComicDownloadToCbzsZip() async {
300339
if (!isPro) {
301340
defaultToast(context, "请先发电鸭");

0 commit comments

Comments
 (0)