fix download path settings

This commit is contained in:
wgh19
2024-05-15 20:05:48 +08:00
parent 93c9d14fe2
commit 702fbf42b8
3 changed files with 17 additions and 5 deletions

View File

@@ -129,9 +129,15 @@ class DownloadingTask {
String subPathPatten = appdata.settings["downloadSubPath"]; String subPathPatten = appdata.settings["downloadSubPath"];
final tagsWeight = (appdata.settings["tagsWeight"] as String).split(' '); final tagsWeight = (appdata.settings["tagsWeight"] as String).split(' ');
final originalTags = List<Tag>.from(illust.tags); final originalTags = List<Tag>.from(illust.tags);
print(originalTags);
originalTags.sort((a, b){ originalTags.sort((a, b){
return tagsWeight.indexOf(a.name) - tagsWeight.indexOf(b.name); var aWeight = tagsWeight.indexOf(a.name);
if(aWeight == -1) aWeight = tagsWeight.length;
var bWeight = tagsWeight.indexOf(b.name);
if(bWeight == -1) bWeight = tagsWeight.length;
return aWeight - bWeight;
}); });
print(originalTags);
final tags = appdata.settings["useTranslatedNameForDownload"] == false final tags = appdata.settings["useTranslatedNameForDownload"] == false
? originalTags.map((e) => e.name).toList() ? originalTags.map((e) => e.name).toList()
: originalTags.map((e) => e.translatedName ?? e.name).toList(); : originalTags.map((e) => e.translatedName ?? e.name).toList();

View File

@@ -137,6 +137,11 @@ class Tag {
final String? translatedName; final String? translatedName;
const Tag(this.name, this.translatedName); const Tag(this.name, this.translatedName);
@override
String toString() {
return "$name${translatedName == null ? "" : "($translatedName)"}";
}
} }
class IllustImage { class IllustImage {

View File

@@ -279,10 +279,11 @@ class __SetDownloadSubPathPageState extends State<_SetDownloadSubPathPage> {
var text = controller.text; var text = controller.text;
if (check(text)) { if (check(text)) {
appdata.settings["downloadSubPath"] = text; appdata.settings["downloadSubPath"] = text;
appdata.settings["tagsWeight"] = controller2.text;
appdata.writeData(); appdata.writeData();
context.pop(); context.pop();
} else { } else {
showToast(context, message: "No Permission".tl); showToast(context, message: "Invalid".tl);
} }
}, },
).toAlign(Alignment.centerRight).paddingRight(16), ).toAlign(Alignment.centerRight).paddingRight(16),
@@ -296,11 +297,11 @@ class __SetDownloadSubPathPageState extends State<_SetDownloadSubPathPage> {
} }
bool check(String text) { bool check(String text) {
if (!text.startsWith('/') || !text.startsWith('\\')) { if (text.startsWith('/') || text.startsWith('\\')) {
return false;
}
return true; return true;
} }
return false;
}
String get _instruction => """ String get _instruction => """
${"Edit the rule for where to save an image.".tl} ${"Edit the rule for where to save an image.".tl}