mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
fix #128
This commit is contained in:
@@ -261,7 +261,10 @@
|
|||||||
"Enable DNS Overrides": "启用DNS覆写",
|
"Enable DNS Overrides": "启用DNS覆写",
|
||||||
"DNS Overrides": "DNS覆写",
|
"DNS Overrides": "DNS覆写",
|
||||||
"Custom Image Processing": "自定义图片处理",
|
"Custom Image Processing": "自定义图片处理",
|
||||||
"Enable": "启用"
|
"Enable": "启用",
|
||||||
|
"Aggregated": "聚合",
|
||||||
|
"Default Search Target": "默认搜索目标",
|
||||||
|
"Auto Language Filters": "自动语言筛选"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -525,6 +528,9 @@
|
|||||||
"Enable DNS Overrides": "啟用DNS覆寫",
|
"Enable DNS Overrides": "啟用DNS覆寫",
|
||||||
"DNS Overrides": "DNS覆寫",
|
"DNS Overrides": "DNS覆寫",
|
||||||
"Custom Image Processing": "自定義圖片處理",
|
"Custom Image Processing": "自定義圖片處理",
|
||||||
"Enable": "啟用"
|
"Enable": "啟用",
|
||||||
|
"Aggregated": "聚合",
|
||||||
|
"Default Search Target": "默認搜索目標",
|
||||||
|
"Auto Language Filters": "自動語言篩選"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -150,6 +150,7 @@ class _Settings with ChangeNotifier {
|
|||||||
'enableCustomImageProcessing': false,
|
'enableCustomImageProcessing': false,
|
||||||
'customImageProcessing': _defaultCustomImageProcessing,
|
'customImageProcessing': _defaultCustomImageProcessing,
|
||||||
'sni': true,
|
'sni': true,
|
||||||
|
'autoAddLanguageFilter': 'none', // none, chinese, english, japanese
|
||||||
};
|
};
|
||||||
|
|
||||||
operator [](String key) {
|
operator [](String key) {
|
||||||
|
@@ -139,7 +139,9 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
var defaultSearchTarget = appdata.settings['defaultSearchTarget'];
|
var defaultSearchTarget = appdata.settings['defaultSearchTarget'];
|
||||||
if (defaultSearchTarget != null &&
|
if (defaultSearchTarget == "_aggregated_") {
|
||||||
|
aggregatedSearch = true;
|
||||||
|
} else if (defaultSearchTarget != null &&
|
||||||
ComicSource.find(defaultSearchTarget) != null) {
|
ComicSource.find(defaultSearchTarget) != null) {
|
||||||
searchTarget = defaultSearchTarget;
|
searchTarget = defaultSearchTarget;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -45,8 +45,9 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
if (suggestionsController.entry != null) {
|
if (suggestionsController.entry != null) {
|
||||||
suggestionsController.remove();
|
suggestionsController.remove();
|
||||||
}
|
}
|
||||||
|
text = checkAutoLanguage(text);
|
||||||
setState(() {
|
setState(() {
|
||||||
this.text = text;
|
this.text = text!;
|
||||||
});
|
});
|
||||||
appdata.addSearchHistory(text);
|
appdata.addSearchHistory(text);
|
||||||
controller.currentText = text;
|
controller.currentText = text;
|
||||||
@@ -92,13 +93,33 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String checkAutoLanguage(String text) {
|
||||||
|
var setting = appdata.settings["autoAddLanguageFilter"] ?? 'none';
|
||||||
|
if (setting == 'none') {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
var searchSource = sourceKey;
|
||||||
|
// TODO: Move it to a better place
|
||||||
|
const enabledSources = [
|
||||||
|
'nhentai',
|
||||||
|
'ehentai',
|
||||||
|
];
|
||||||
|
if (!enabledSources.contains(searchSource)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
if (!text.contains('language:')) {
|
||||||
|
return '$text language:$setting';
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
sourceKey = widget.sourceKey;
|
||||||
controller = SearchBarController(
|
controller = SearchBarController(
|
||||||
currentText: widget.text,
|
currentText: checkAutoLanguage(widget.text),
|
||||||
onSearch: search,
|
onSearch: search,
|
||||||
);
|
);
|
||||||
sourceKey = widget.sourceKey;
|
|
||||||
options = widget.options ?? const [];
|
options = widget.options ?? const [];
|
||||||
validateOptions();
|
validateOptions();
|
||||||
text = widget.text;
|
text = widget.text;
|
||||||
@@ -162,6 +183,12 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(Icons.tune),
|
icon: const Icon(Icons.tune),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if (suggestionOverlay != null) {
|
||||||
|
suggestionsController.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
var previousOptions = options;
|
||||||
|
var previousSourceKey = sourceKey;
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
@@ -169,7 +196,11 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
return _SearchSettingsDialog(state: this);
|
return _SearchSettingsDialog(state: this);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
setState(() {});
|
if (previousOptions != options || previousSourceKey != sourceKey) {
|
||||||
|
text = checkAutoLanguage(controller.text);
|
||||||
|
controller.currentText = text;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@@ -88,6 +88,30 @@ class _ExploreSettingsState extends State<ExploreSettings> {
|
|||||||
title: "Keyword blocking".tl,
|
title: "Keyword blocking".tl,
|
||||||
builder: () => const _ManageBlockingWordView(),
|
builder: () => const _ManageBlockingWordView(),
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
|
SelectSetting(
|
||||||
|
title: "Default Search Target".tl,
|
||||||
|
settingKey: "defaultSearchTarget",
|
||||||
|
optionTranslation: {
|
||||||
|
'_aggregated_': "Aggregated".tl,
|
||||||
|
...((){
|
||||||
|
var map = <String, String>{};
|
||||||
|
for (var c in ComicSource.all()) {
|
||||||
|
map[c.key] = c.name;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}()),
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
|
SelectSetting(
|
||||||
|
title: "Auto Language Filters".tl,
|
||||||
|
settingKey: "autoAddLanguageFilter",
|
||||||
|
optionTranslation: {
|
||||||
|
'none': "None".tl,
|
||||||
|
'chinese': "Chinese",
|
||||||
|
'english': "English",
|
||||||
|
'japanese': "Japanese",
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -150,7 +174,7 @@ class _ManageBlockingWordViewState extends State<_ManageBlockingWordView> {
|
|||||||
errorText: error,
|
errorText: error,
|
||||||
),
|
),
|
||||||
onChanged: (s) {
|
onChanged: (s) {
|
||||||
if(error != null){
|
if (error != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
error = null;
|
error = null;
|
||||||
});
|
});
|
||||||
@@ -160,7 +184,8 @@ class _ManageBlockingWordViewState extends State<_ManageBlockingWordView> {
|
|||||||
actions: [
|
actions: [
|
||||||
Button.filled(
|
Button.filled(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if(appdata.settings["blockedWords"].contains(controller.text)){
|
if (appdata.settings["blockedWords"]
|
||||||
|
.contains(controller.text)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
error = "Keyword already exists".tl;
|
error = "Keyword already exists".tl;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user