From 01df6c44fabad350111099ac3cf9f466bfe89cb5 Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 3 Nov 2024 12:24:44 +0900 Subject: [PATCH 1/7] Bump windows build --- violet/pubspec.lock | 8 -------- violet/windows/flutter/generated_plugin_registrant.cc | 3 --- violet/windows/flutter/generated_plugins.cmake | 1 - 3 files changed, 12 deletions(-) diff --git a/violet/pubspec.lock b/violet/pubspec.lock index 89e93dbe2..c79b16c57 100644 --- a/violet/pubspec.lock +++ b/violet/pubspec.lock @@ -1772,14 +1772,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.6" - sqlite3_flutter_libs: - dependency: "direct main" - description: - name: sqlite3_flutter_libs - sha256: "62bbb4073edbcdf53f40c80775f33eea01d301b7b81417e5b3fb7395416258c1" - url: "https://pub.dev" - source: hosted - version: "0.5.24" stack_trace: dependency: transitive description: diff --git a/violet/windows/flutter/generated_plugin_registrant.cc b/violet/windows/flutter/generated_plugin_registrant.cc index 1c40f7cb5..71808f8ba 100644 --- a/violet/windows/flutter/generated_plugin_registrant.cc +++ b/violet/windows/flutter/generated_plugin_registrant.cc @@ -11,7 +11,6 @@ #include #include #include -#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -25,8 +24,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("LocalAuthPlugin")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); - Sqlite3FlutterLibsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/violet/windows/flutter/generated_plugins.cmake b/violet/windows/flutter/generated_plugins.cmake index 7cf25e934..dd34db612 100644 --- a/violet/windows/flutter/generated_plugins.cmake +++ b/violet/windows/flutter/generated_plugins.cmake @@ -8,7 +8,6 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_js local_auth_windows permission_handler_windows - sqlite3_flutter_libs url_launcher_windows ) From e302b4385d93ef8000b6f8e433691410fef2fb0f Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 3 Nov 2024 12:24:53 +0900 Subject: [PATCH 2/7] Refactor similar list page --- .../pages/artist_info/similar_list_page.dart | 61 +++++++++---------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/violet/lib/pages/artist_info/similar_list_page.dart b/violet/lib/pages/artist_info/similar_list_page.dart index bba9a75ed..0cb980fdc 100644 --- a/violet/lib/pages/artist_info/similar_list_page.dart +++ b/violet/lib/pages/artist_info/similar_list_page.dart @@ -24,49 +24,37 @@ class SimilarListPage extends StatelessWidget { required this.type, }); - Future> _future(String e) async { - var unescape = HtmlUnescape(); + Future> query(String e) async { var postfix = e.toLowerCase().replaceAll(' ', '_'); if (type.isUploader) postfix = e; - var queryString = HitomiManager.translate2query( + + final queryString = HitomiManager.translate2query( '${type.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); final qm = QueryManager.queryPagination(queryString); qm.itemsPerPage = 10; - var x = await qm.next(); - var y = [x[0]]; + var quries = await qm.next(); - var titles = [unescape.convert((x[0].title() as String).trim())]; - if (titles[0].contains('Ch.')) { - titles[0] = titles[0].split('Ch.')[0]; - } else if (titles[0].contains('ch.')) { - titles[0] = titles[0].split('ch.')[0]; - } + var titles = [removeChapter(quries[0].title() as String)]; + var results = [quries[0]]; - for (int i = 1; i < x.length; i++) { - var skip = false; - var ff = unescape.convert((x[i].title() as String).trim()); - if (ff.contains('Ch.')) { - ff = ff.split('Ch.')[0]; - } else if (ff.contains('ch.')) { - ff = ff.split('ch.')[0]; - } - for (int j = 0; j < titles.length; j++) { - var tt = titles[j]; - if (Distance.levenshteinDistanceComparable( - tt.runes.map((e) => e.toString()).toList(), - ff.runes.map((e) => e.toString()).toList()) < - 3) { - skip = true; - break; - } + // 제목이 비슷한(중복) 작품을 보여주지 않기 위해 필터링 + for (var i = 1; i < quries.length; i++) { + final target = removeChapter(quries[i].title() as String); + final hasSimilar = titles.any((source) { + return Distance.levenshteinDistanceComparable( + source.runes.map((e) => e.toString()).toList(), + target.runes.map((e) => e.toString()).toList()) < + 3; + }); + + if (!hasSimilar) { + titles.add(target); + results.add(quries[i]); } - if (skip) continue; - y.add(x[i]); - titles.add(ff.trim()); } - return y; + return results; } @override @@ -81,7 +69,7 @@ class SimilarListPage extends StatelessWidget { itemBuilder: (BuildContext ctxt, int index) { var e = similarsAll[index]; return FutureBuilder>( - future: _future(e.$1), + future: query(e.$1), builder: (BuildContext context, AsyncSnapshot> snapshot) { if (!snapshot.hasData) { @@ -108,3 +96,10 @@ class SimilarListPage extends StatelessWidget { ); } } + +String removeChapter(String title) { + final unescapedTitle = HtmlUnescape().convert(title.trim()); + final pos = unescapedTitle.indexOf(RegExp(r'Ch\.|ch\.')); + + return (pos == -1 ? unescapedTitle : unescapedTitle.substring(0, pos)).trim(); +} From 5dcd6d797a1822b40324434c177a03bb423ab778 Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 3 Nov 2024 12:29:35 +0900 Subject: [PATCH 3/7] Pass page argument when call queryPagination --- violet/lib/component/hitomi/series_finder.dart | 15 +++++++-------- violet/lib/database/query.dart | 3 ++- .../lib/pages/artist_info/artist_info_page.dart | 3 +-- .../lib/pages/artist_info/similar_list_page.dart | 3 +-- .../bookmark/group/group_artist_article_list.dart | 3 +-- .../pages/bookmark/group/group_artist_list.dart | 6 ++---- .../database_download/database_download_page.dart | 5 ++--- .../lab/lab/artist_search/artist_search.dart | 3 +-- .../lab/lab/bookmark/bookmarks_artist_list.dart | 6 ++---- .../artist_collection/artist_list_page.dart | 3 +-- violet/lib/pages/settings/tag_rebuild_page.dart | 8 ++++---- 11 files changed, 24 insertions(+), 34 deletions(-) diff --git a/violet/lib/component/hitomi/series_finder.dart b/violet/lib/component/hitomi/series_finder.dart index 995bc0ce4..0244db017 100644 --- a/violet/lib/component/hitomi/series_finder.dart +++ b/violet/lib/component/hitomi/series_finder.dart @@ -29,9 +29,9 @@ class SeriesFinder { if (kv.key.toLowerCase() == 'n/a') continue; - final qm = QueryManager.queryPagination(HitomiManager.translate2query( - 'artist:${kv.key.replaceAll(' ', '_')}')); - qm.itemsPerPage = 99999; + final query = HitomiManager.translate2query( + 'artist:${kv.key.replaceAll(' ', '_')}'); + final qm = QueryManager.queryPagination(query, 99999); final qr = await qm.next(); if (qr.length == 1) continue; @@ -52,9 +52,9 @@ class SeriesFinder { if (kv.key.toLowerCase() == 'n/a') continue; - final qm = QueryManager.queryPagination(HitomiManager.translate2query( - 'artist:${kv.key.replaceAll(' ', '_')}')); - qm.itemsPerPage = 99999; + final query = HitomiManager.translate2query( + 'artist:${kv.key.replaceAll(' ', '_')}'); + final qm = QueryManager.queryPagination(query, 99999); final qr = await qm.next(); if (qr.length == 1) continue; @@ -77,8 +77,7 @@ class SeriesFinder { static Future doFind2() async { final qm = QueryManager.queryPagination( - 'SELECT Title, Artists, Groups FROM HitomiColumnModel'); - qm.itemsPerPage = 999999; + 'SELECT Title, Artists, Groups FROM HitomiColumnModel', 999999); final qr = await qm.next(); final artists = >{}; diff --git a/violet/lib/database/query.dart b/violet/lib/database/query.dart index 34b68f935..aa2081b52 100644 --- a/violet/lib/database/query.dart +++ b/violet/lib/database/query.dart @@ -64,11 +64,12 @@ class QueryManager { return qm; } - static QueryManager queryPagination(String rawQuery) { + static QueryManager queryPagination(String rawQuery, int itemsPerPage) { QueryManager qm = QueryManager(); qm.isPagination = true; qm.curPage = 0; qm.queryString = rawQuery; + qm.itemsPerPage = itemsPerPage; return qm; } diff --git a/violet/lib/pages/artist_info/artist_info_page.dart b/violet/lib/pages/artist_info/artist_info_page.dart index 32c5d926f..460b4b459 100644 --- a/violet/lib/pages/artist_info/artist_info_page.dart +++ b/violet/lib/pages/artist_info/artist_info_page.dart @@ -226,8 +226,7 @@ class _ArtistInfoPageState extends State { var postfix = similars[i].$1.toLowerCase().replaceAll(' ', '_'); var queryString = HitomiManager.translate2query( '$prefix:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 10; + final qm = QueryManager.queryPagination(queryString, 10); var x = await qm.next(); if (x.isEmpty) { diff --git a/violet/lib/pages/artist_info/similar_list_page.dart b/violet/lib/pages/artist_info/similar_list_page.dart index 0cb980fdc..1543c2a87 100644 --- a/violet/lib/pages/artist_info/similar_list_page.dart +++ b/violet/lib/pages/artist_info/similar_list_page.dart @@ -30,8 +30,7 @@ class SimilarListPage extends StatelessWidget { final queryString = HitomiManager.translate2query( '${type.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 10; + final qm = QueryManager.queryPagination(queryString, 10); var quries = await qm.next(); diff --git a/violet/lib/pages/bookmark/group/group_artist_article_list.dart b/violet/lib/pages/bookmark/group/group_artist_article_list.dart index f17a46127..c7f797d69 100644 --- a/violet/lib/pages/bookmark/group/group_artist_article_list.dart +++ b/violet/lib/pages/bookmark/group/group_artist_article_list.dart @@ -55,8 +55,7 @@ class _GroupArtistArticleListState extends State '${e.type().name}:${e.artist().toLowerCase().replaceAll(' ', '_')} ${Settings.includeTags}') .join(' or ')); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 100; + final qm = QueryManager.queryPagination(queryString, 100); return await qm.next(); }), builder: (context, AsyncSnapshot> snapshot) { diff --git a/violet/lib/pages/bookmark/group/group_artist_list.dart b/violet/lib/pages/bookmark/group/group_artist_list.dart index a086cee50..15414180b 100644 --- a/violet/lib/pages/bookmark/group/group_artist_list.dart +++ b/violet/lib/pages/bookmark/group/group_artist_list.dart @@ -49,8 +49,7 @@ class _GroupArtistListState extends State var postfix = artists[i].artist().toLowerCase().replaceAll(' ', '_'); var queryString = HitomiManager.translate2query( '${artists[i].type().name}:$postfix ${Settings.includeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 1; + final qm = QueryManager.queryPagination(queryString, 1); var query = (await qm.next())[0].id(); ids.add((query, i)); } @@ -68,8 +67,7 @@ class _GroupArtistListState extends State var postfix = e.toLowerCase().replaceAll(' ', '_'); var queryString = HitomiManager.translate2query( '${type.name}:$postfix ${Settings.includeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 4; + final qm = QueryManager.queryPagination(queryString, 4); return await qm.next(); } diff --git a/violet/lib/pages/database_download/database_download_page.dart b/violet/lib/pages/database_download/database_download_page.dart index 312af860d..35d131b54 100644 --- a/violet/lib/pages/database_download/database_download_page.dart +++ b/violet/lib/pages/database_download/database_download_page.dart @@ -268,9 +268,8 @@ class DataBaseDownloadPageState extends State { } Future indexing() async { - QueryManager qm; - qm = QueryManager.queryPagination('SELECT * FROM HitomiColumnModel'); - qm.itemsPerPage = 50000; + final qm = + QueryManager.queryPagination('SELECT * FROM HitomiColumnModel', 50000); var tags = {}; var languages = {}; diff --git a/violet/lib/pages/lab/lab/artist_search/artist_search.dart b/violet/lib/pages/lab/lab/artist_search/artist_search.dart index 7d9bf534b..6f7b34b78 100644 --- a/violet/lib/pages/lab/lab/artist_search/artist_search.dart +++ b/violet/lib/pages/lab/lab/artist_search/artist_search.dart @@ -287,8 +287,7 @@ class _ArtistSearchState extends State { final queryString = HitomiManager.translate2query( '${selectedType.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 10; + final qm = QueryManager.queryPagination(queryString, 10); final x = await qm.next(); final y = [x[0]]; diff --git a/violet/lib/pages/lab/lab/bookmark/bookmarks_artist_list.dart b/violet/lib/pages/lab/lab/bookmark/bookmarks_artist_list.dart index 0ab6403a7..3090ff546 100644 --- a/violet/lib/pages/lab/lab/bookmark/bookmarks_artist_list.dart +++ b/violet/lib/pages/lab/lab/bookmark/bookmarks_artist_list.dart @@ -50,8 +50,7 @@ class _GroupArtistListState extends State final postfix = artists[i].artist().toLowerCase().replaceAll(' ', '_'); final queryString = HitomiManager.translate2query( '${artists[i].type().name}:$postfix ${Settings.includeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 1; + final qm = QueryManager.queryPagination(queryString, 1); var query = (await qm.next())[0].id(); ids.add((query, i)); } @@ -69,8 +68,7 @@ class _GroupArtistListState extends State var postfix = e.toLowerCase().replaceAll(' ', '_'); var queryString = HitomiManager.translate2query( '${type.name}:$postfix ${Settings.includeTags}'); - final qm = QueryManager.queryPagination(queryString); - qm.itemsPerPage = 3; + final qm = QueryManager.queryPagination(queryString, 3); return await qm.next(); } diff --git a/violet/lib/pages/settings/artist_collection/artist_list_page.dart b/violet/lib/pages/settings/artist_collection/artist_list_page.dart index c5926b895..e35eae871 100644 --- a/violet/lib/pages/settings/artist_collection/artist_list_page.dart +++ b/violet/lib/pages/settings/artist_collection/artist_list_page.dart @@ -34,8 +34,7 @@ class ArtistListPage extends StatelessWidget { final queryString = HitomiManager.translate2query( '${isLast ? '' : 'artist:'}$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final queryManager = QueryManager.queryPagination(queryString); - queryManager.itemsPerPage = 10; + final queryManager = QueryManager.queryPagination(queryString, 10); final queryResults = await queryManager.next(); final filtered = []; diff --git a/violet/lib/pages/settings/tag_rebuild_page.dart b/violet/lib/pages/settings/tag_rebuild_page.dart index 3fd9515a6..f004ef50a 100644 --- a/violet/lib/pages/settings/tag_rebuild_page.dart +++ b/violet/lib/pages/settings/tag_rebuild_page.dart @@ -118,10 +118,10 @@ class _TagRebuildPageState extends State { } Future indexing() async { - QueryManager qm; - qm = QueryManager.queryPagination(HitomiManager.translate2query( - '${Settings.includeTags} ${Settings.serializedExcludeTags}')); - qm.itemsPerPage = 50000; + final qm = QueryManager.queryPagination( + HitomiManager.translate2query( + '${Settings.includeTags} ${Settings.serializedExcludeTags}'), + 50000); var tags = {}; var languages = {}; From a23ae82b120ca25f056175607761ee01014648d6 Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 3 Nov 2024 12:39:43 +0900 Subject: [PATCH 4/7] Dedup query artist articles --- .../pages/artist_info/artist_info_page.dart | 55 ++-------------- .../pages/artist_info/similar_list_page.dart | 64 +++++++++---------- .../lab/lab/artist_search/artist_search.dart | 51 +-------------- 3 files changed, 39 insertions(+), 131 deletions(-) diff --git a/violet/lib/pages/artist_info/artist_info_page.dart b/violet/lib/pages/artist_info/artist_info_page.dart index 460b4b459..e4ce9efbc 100644 --- a/violet/lib/pages/artist_info/artist_info_page.dart +++ b/violet/lib/pages/artist_info/artist_info_page.dart @@ -160,7 +160,7 @@ class _ArtistInfoPageState extends State { similarsAll = similars; similars = similars.take(6).toList(); - await querySimilars(similars, widget.type.name, qrs); + await querySimilars(similars, widget.type, qrs); if (widget.type.isCharacter || widget.type.isSeries) { if (widget.type.isCharacter) { @@ -177,13 +177,13 @@ class _ArtistInfoPageState extends State { await querySimilars( relatedCharacterOrSeries, - widget.type.name, + widget.type, qrsCharacterOrSeries, ); await querySimilars( relatedCOSSingle, - widget.type.name, + widget.type, qrsCOSSingle, ); } @@ -219,53 +219,10 @@ class _ArtistInfoPageState extends State { if (comments!.isNotEmpty) setState(() {}); } - Future querySimilars(List<(String, double)> similars, String prefix, + Future querySimilars(List<(String, double)> similars, ArtistType type, List> qrs) async { - var unescape = HtmlUnescape(); - for (int i = 0; i < similars.length; i++) { - var postfix = similars[i].$1.toLowerCase().replaceAll(' ', '_'); - var queryString = HitomiManager.translate2query( - '$prefix:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final qm = QueryManager.queryPagination(queryString, 10); - - var x = await qm.next(); - if (x.isEmpty) { - qrs.add([]); - continue; - } - var y = [x[0]]; - - var titles = [unescape.convert((x[0].title() as String).trim())]; - if (titles[0].contains('Ch.')) { - titles[0] = titles[0].split('Ch.')[0]; - } else if (titles[0].contains('ch.')) { - titles[0] = titles[0].split('ch.')[0]; - } - - for (int i = 1; i < x.length; i++) { - var skip = false; - var ff = unescape.convert((x[i].title() as String).trim()); - if (ff.contains('Ch.')) { - ff = ff.split('Ch.')[0]; - } else if (ff.contains('ch.')) { - ff = ff.split('ch.')[0]; - } - for (int j = 0; j < titles.length; j++) { - var tt = titles[j]; - if (Distance.levenshteinDistanceComparable( - tt.runes.map((e) => e.toString()).toList(), - ff.runes.map((e) => e.toString()).toList()) < - 3) { - skip = true; - break; - } - } - if (skip) continue; - y.add(x[i]); - titles.add(ff.trim()); - } - - qrs.add(y); + for (final (name, _) in similars) { + qrs.add(await queryDedupedArtistArticles(type, name)); } } diff --git a/violet/lib/pages/artist_info/similar_list_page.dart b/violet/lib/pages/artist_info/similar_list_page.dart index 1543c2a87..87f63d972 100644 --- a/violet/lib/pages/artist_info/similar_list_page.dart +++ b/violet/lib/pages/artist_info/similar_list_page.dart @@ -24,38 +24,6 @@ class SimilarListPage extends StatelessWidget { required this.type, }); - Future> query(String e) async { - var postfix = e.toLowerCase().replaceAll(' ', '_'); - if (type.isUploader) postfix = e; - - final queryString = HitomiManager.translate2query( - '${type.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final qm = QueryManager.queryPagination(queryString, 10); - - var quries = await qm.next(); - - var titles = [removeChapter(quries[0].title() as String)]; - var results = [quries[0]]; - - // 제목이 비슷한(중복) 작품을 보여주지 않기 위해 필터링 - for (var i = 1; i < quries.length; i++) { - final target = removeChapter(quries[i].title() as String); - final hasSimilar = titles.any((source) { - return Distance.levenshteinDistanceComparable( - source.runes.map((e) => e.toString()).toList(), - target.runes.map((e) => e.toString()).toList()) < - 3; - }); - - if (!hasSimilar) { - titles.add(target); - results.add(quries[i]); - } - } - - return results; - } - @override Widget build(BuildContext context) { return CardPanel.build( @@ -68,7 +36,7 @@ class SimilarListPage extends StatelessWidget { itemBuilder: (BuildContext ctxt, int index) { var e = similarsAll[index]; return FutureBuilder>( - future: query(e.$1), + future: queryDedupedArtistArticles(type, e.$1), builder: (BuildContext context, AsyncSnapshot> snapshot) { if (!snapshot.hasData) { @@ -96,6 +64,36 @@ class SimilarListPage extends StatelessWidget { } } +Future> queryDedupedArtistArticles( + ArtistType type, String e) async { + final postfix = e.toLowerCase().replaceAll(' ', '_'); + final queryString = HitomiManager.translate2query( + '${type.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); + final qm = QueryManager.queryPagination(queryString, 10); + final quries = await qm.next(); + + final titles = [removeChapter(quries[0].title() as String)]; + final results = [quries[0]]; + + // 제목이 비슷한(중복) 작품을 보여주지 않기 위해 필터링 + for (final query in quries) { + final target = removeChapter(query.title() as String); + final hasSimilar = titles.any((source) { + return Distance.levenshteinDistanceComparable( + source.runes.map((e) => e.toString()).toList(), + target.runes.map((e) => e.toString()).toList()) < + 3; + }); + + if (!hasSimilar) { + titles.add(target); + results.add(query); + } + } + + return results; +} + String removeChapter(String title) { final unescapedTitle = HtmlUnescape().convert(title.trim()); final pos = unescapedTitle.indexOf(RegExp(r'Ch\.|ch\.')); diff --git a/violet/lib/pages/lab/lab/artist_search/artist_search.dart b/violet/lib/pages/lab/lab/artist_search/artist_search.dart index 6f7b34b78..1ff2774bf 100644 --- a/violet/lib/pages/lab/lab/artist_search/artist_search.dart +++ b/violet/lib/pages/lab/lab/artist_search/artist_search.dart @@ -13,6 +13,7 @@ import 'package:violet/database/query.dart'; import 'package:violet/database/user/bookmark.dart'; import 'package:violet/locale/locale.dart'; import 'package:violet/pages/artist_info/artist_info_page.dart'; +import 'package:violet/pages/artist_info/similar_list_page.dart'; import 'package:violet/pages/lab/lab/artist_search/tag_group_modify.dart'; import 'package:violet/pages/segment/card_panel.dart'; import 'package:community_charts_flutter/community_charts_flutter.dart' @@ -254,7 +255,7 @@ class _ArtistSearchState extends State { itemBuilder: (BuildContext ctxt, int index) { final e = similarsAll[index]; return FutureBuilder>( - future: artistListfuture(e.$1), + future: queryDedupedArtistArticles(selectedType, e.$1), builder: (BuildContext context, AsyncSnapshot> snapshot) { if (!snapshot.hasData) { @@ -279,52 +280,4 @@ class _ArtistSearchState extends State { }, ); } - - Future> artistListfuture(String e) async { - final unescape = HtmlUnescape(); - - final postfix = e.toLowerCase().replaceAll(' ', '_'); - - final queryString = HitomiManager.translate2query( - '${selectedType.name}:$postfix ${Settings.includeTags} ${Settings.serializedExcludeTags}'); - final qm = QueryManager.queryPagination(queryString, 10); - - final x = await qm.next(); - final y = [x[0]]; - - final titles = [unescape.convert((x[0].title() as String).trim())]; - if (titles[0].contains('Ch.')) { - titles[0] = titles[0].split('Ch.')[0]; - } else if (titles[0].contains('ch.')) { - titles[0] = titles[0].split('ch.')[0]; - } - - for (int i = 1; i < x.length; i++) { - var skip = false; - var ff = unescape.convert((x[i].title() as String).trim()); - - if (ff.contains('Ch.')) { - ff = ff.split('Ch.')[0]; - } else if (ff.contains('ch.')) { - ff = ff.split('ch.')[0]; - } - - for (int j = 0; j < titles.length; j++) { - var tt = titles[j]; - if (Distance.levenshteinDistanceComparable( - tt.runes.map((e) => e.toString()).toList(), - ff.runes.map((e) => e.toString()).toList()) < - 3) { - skip = true; - break; - } - } - if (skip) continue; - - y.add(x[i]); - titles.add(ff.trim()); - } - - return y; - } } From 909860329541994cf4eea45a932f1f3cb2e6707b Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 3 Nov 2024 12:44:40 +0900 Subject: [PATCH 5/7] Remove hisoki component --- violet/lib/component/hentai.dart | 9 --- .../lib/component/hisoki/hisoki_getter.dart | 32 --------- violet/lib/component/hisoki/hisoki_hash.dart | 31 --------- .../lib/component/hisoki/hisoki_provider.dart | 68 ------------------- violet/lib/pages/settings/route.dart | 2 - violet/lib/pages/settings/settings_page.dart | 4 +- violet/lib/pages/splash/splash_page.dart | 1 - 7 files changed, 2 insertions(+), 145 deletions(-) delete mode 100644 violet/lib/component/hisoki/hisoki_getter.dart delete mode 100644 violet/lib/component/hisoki/hisoki_hash.dart delete mode 100644 violet/lib/component/hisoki/hisoki_provider.dart diff --git a/violet/lib/component/hentai.dart b/violet/lib/component/hentai.dart index 42107fa09..13ff83abc 100644 --- a/violet/lib/component/hentai.dart +++ b/violet/lib/component/hentai.dart @@ -6,8 +6,6 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:violet/component/eh/eh_headers.dart'; import 'package:violet/component/eh/eh_parser.dart'; import 'package:violet/component/eh/eh_provider.dart'; -import 'package:violet/component/hisoki/hisoki_getter.dart'; -import 'package:violet/component/hisoki/hisoki_provider.dart'; import 'package:violet/component/hitomi/hitomi.dart'; import 'package:violet/component/hitomi/hitomi_parser.dart'; import 'package:violet/component/hitomi/hitomi_provider.dart'; @@ -568,13 +566,6 @@ class HentaiManager { } return HitomiImageProvider(imgList, qr.id().toString()); } - - case 'Hisoki': - { - var urls = await HisokiGetter.getImages(qr.id()); - if (urls == null || urls.isEmpty) break; - return HisokiImageProvider(infos: urls, id: qr.id()); - } } } catch (e, st) { Logger.error('[hentai-getImageProvider] E: $e\n' diff --git a/violet/lib/component/hisoki/hisoki_getter.dart b/violet/lib/component/hisoki/hisoki_getter.dart deleted file mode 100644 index 0d83fde2c..000000000 --- a/violet/lib/component/hisoki/hisoki_getter.dart +++ /dev/null @@ -1,32 +0,0 @@ -// This source code is a part of Project Violet. -// Copyright (C) 2021. violet-team. Licensed under the Apache-2.0 License. - -import 'dart:convert'; - -import 'package:violet/component/hisoki/hisoki_hash.dart'; -import 'package:violet/network/wrapper.dart' as http; - -class HisokiGetter { - static Future?> getImages(int id) async { - var hash = HisokiHash.getHash('$id'); - - if (hash == null) return null; - - var info = jsonDecode( - (await http.get('https://hisoki.me/api/v1/manga/$hash')).body)['body']; - var sl = info['sl'] as List; - var il = info['il'] as List; - - var result = <(String, double, double)>[]; - - for (var i = 0; i < il.length; i++) { - result.add(( - '${il[i]}.webp', - (sl[i]['w'] as int).toDouble(), - (sl[i]['h'] as int).toDouble() - )); - } - - return result; - } -} diff --git a/violet/lib/component/hisoki/hisoki_hash.dart b/violet/lib/component/hisoki/hisoki_hash.dart deleted file mode 100644 index e84ae743e..000000000 --- a/violet/lib/component/hisoki/hisoki_hash.dart +++ /dev/null @@ -1,31 +0,0 @@ -// This source code is a part of Project Violet. -// Copyright (C) 2020-2024. violet-team. Licensed under the Apache-2.0 License. - -import 'dart:convert'; -import 'dart:io'; - -import 'package:flutter/services.dart'; -import 'package:path/path.dart'; - -class HisokiHash { - static late Map hash; - - static Future init() async { - String data; - if (Platform.environment.containsKey('FLUTTER_TEST')) { - final file = File(join(Directory.current.path, 'assets/hisoki.json')); - data = await file.readAsString(); - } else { - data = await rootBundle.loadString('assets/hisoki.json'); - } - - Map hashs = json.decode(data); - hash = {}; - hash.addEntries( - hashs.entries.map((e) => MapEntry(e.key, e.value as String)).toList()); - } - - static String? getHash(String id) { - return hash[id]; - } -} diff --git a/violet/lib/component/hisoki/hisoki_provider.dart b/violet/lib/component/hisoki/hisoki_provider.dart deleted file mode 100644 index 6987c5e83..000000000 --- a/violet/lib/component/hisoki/hisoki_provider.dart +++ /dev/null @@ -1,68 +0,0 @@ -// This source code is a part of Project Violet. -// Copyright (C) 2021. violet-team. Licensed under the Apache-2.0 License. - -import 'package:violet/component/image_provider.dart'; - -class HisokiImageProvider extends VioletImageProvider { - int id; - List<(String, double, double)> infos; - - HisokiImageProvider({required this.infos, required this.id}); - - @override - Future init() async {} - - @override - Future> getSmallImagesUrl() async { - throw UnimplementedError(); - } - - @override - Future getThumbnailUrl() async { - return 'https://hiso.observer/${(id % 100).toString().padLeft(2, '0')}/$id/cover.webp'; - } - - @override - Future> getHeader(int page) async { - return {}; - } - - @override - Future getImageUrl(int page) async { - return infos[page].$1; - } - - @override - bool canGetImageUrlSync() => true; - - @override - String? getImageUrlSync(int page) => infos[page].$1; - - @override - int length() { - return infos.length; - } - - late List _estimatedCache; - - @override - Future getEstimatedImageHeight(int page, double baseWidth) async { - return _estimatedCache[page] = infos[page].$3 * baseWidth / infos[page].$2; - } - - @override - bool isRefreshable() { - return false; - } - - @override - Future refresh() async {} - - @override - Future refreshPartial(List target) async {} - - @override - Future getOriginalImageHeight(int page) async { - return -1; - } -} diff --git a/violet/lib/pages/settings/route.dart b/violet/lib/pages/settings/route.dart index 74b0a72e5..22f3dc15f 100644 --- a/violet/lib/pages/settings/route.dart +++ b/violet/lib/pages/settings/route.dart @@ -54,7 +54,6 @@ class _RouteDialogState extends State { 'ExHentai': 'https://exhentai.org/favicon.ico', 'Hiyobi': 'https://hiyobi.me/favicon.ico', 'NHentai': 'https://nhentai.net/favicon.ico', - 'Hisoki': 'https://hisoki.me/favicon.ico', }[e]!, height: 25, width: 25, @@ -120,7 +119,6 @@ class _ImageRouteDialogState extends State { 'ExHentai': 'https://exhentai.org/favicon.ico', 'NHentai': 'https://nhentai.net/favicon.ico', 'Hiyobi': 'https://hiyobi.me/favicon.ico', - 'Hisoki': 'https://hisoki.me/favicon.ico', }[e]!, height: 25, width: 25, diff --git a/violet/lib/pages/settings/settings_page.dart b/violet/lib/pages/settings/settings_page.dart index 9c13bdf66..b9fb69068 100644 --- a/violet/lib/pages/settings/settings_page.dart +++ b/violet/lib/pages/settings/settings_page.dart @@ -2377,9 +2377,9 @@ class _SettingsPageState extends State } Settings.searchRule = - 'ExHentai|EHentai|Hitomi|NHentai|Hisoki'.split('|'); + 'ExHentai|EHentai|Hitomi|NHentai'.split('|'); await prefs.setString( - 'searchrule', 'ExHentai|EHentai|Hitomi|NHentai|Hisoki'); + 'searchrule', 'ExHentai|EHentai|Hitomi|NHentai'); }, ), ], diff --git a/violet/lib/pages/splash/splash_page.dart b/violet/lib/pages/splash/splash_page.dart index ac16fdf5d..a3cf54286 100644 --- a/violet/lib/pages/splash/splash_page.dart +++ b/violet/lib/pages/splash/splash_page.dart @@ -217,7 +217,6 @@ class _SplashPageState extends State { await Population.init(); _changeMessage('init related...'); await Related.init(); - // await HisokiHash.init(); _changeMessage('init downloader...'); await IsolateDownloader.getInstance(); _changeMessage('init api...'); From c2226b47c8bf136e1fd34d9a834d92aef4d1fcd1 Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 3 Nov 2024 13:40:27 +0900 Subject: [PATCH 6/7] Reuse thumb size value --- .../pages/viewer/overlay/viewer_overlay.dart | 22 +++++++------------ .../lib/pages/viewer/viewer_controller.dart | 6 +++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/violet/lib/pages/viewer/overlay/viewer_overlay.dart b/violet/lib/pages/viewer/overlay/viewer_overlay.dart index 537b911ae..6cd4a1e2f 100644 --- a/violet/lib/pages/viewer/overlay/viewer_overlay.dart +++ b/violet/lib/pages/viewer/overlay/viewer_overlay.dart @@ -101,7 +101,6 @@ class _ViewerOverlayState extends State { final statusBarHeight = Settings.disableFullScreen ? MediaQuery.of(context).padding.top : 0; final height = MediaQuery.of(context).size.height; - final thumbHeight = [180, 140, 120, 96][c.thumbSize.value]; return Obx( () => AnimatedOpacity( @@ -118,12 +117,12 @@ class _ViewerOverlayState extends State { Variables.bottomBarHeight - (48 + 48 + 48 + 32 - 24) - (c.search.value ? 48 : 0) - - (c.thumb.value ? thumbHeight : 0) - + (c.thumb.value ? c.thumbSizeValue : 0) - (c.showSlider.value ? 48.0 : 0) - statusBarHeight, bottom: (48 + 48.0 + 32 - 24) + (c.search.value ? 48 : 0) + - (c.thumb.value ? thumbHeight : 0) + + (c.thumb.value ? c.thumbSizeValue : 0) + (c.showSlider.value ? 48.0 : 0), left: 48.0, right: 48.0, @@ -637,8 +636,6 @@ class _ViewerOverlayState extends State { }, ); - final thumbHeight = [180.0, 140.0, 120.0, 96.0][c.thumbSize.value]; - return Obx( () => AnimatedOpacity( opacity: c.opacity.value, @@ -663,7 +660,7 @@ class _ViewerOverlayState extends State { Variables.bottomBarHeight - (48) - (Platform.isIOS ? 48 - 24 : 0) - - (c.thumb.value ? thumbHeight : 0) - + (c.thumb.value ? c.thumbSizeValue : 0) - (c.search.value ? 48 : 0) - statusBarHeight - (c.appBarToBottom.value ? 48 : 0))), @@ -674,7 +671,7 @@ class _ViewerOverlayState extends State { height: MediaQuery.of(context).viewInsets.bottom > 1 ? MediaQuery.of(context).viewInsets.bottom + 48 : (48 + - (c.thumb.value ? thumbHeight : 0) + + (c.thumb.value ? c.thumbSizeValue : 0) + (c.search.value ? 48 : 0) + (!c.appBarToBottom.value ? 48 : 0)), curve: Curves.easeInOut, @@ -701,7 +698,7 @@ class _ViewerOverlayState extends State { child: AnimatedContainer( duration: const Duration(milliseconds: 300), curve: Curves.easeInOut, - height: c.thumb.value ? thumbHeight : 0, + height: c.thumb.value ? c.thumbSizeValue : 0, child: _thumbArea(), ), ), @@ -738,7 +735,6 @@ class _ViewerOverlayState extends State { } _preprocessImageInfoForFileImage() { - final thumbHeight = [180, 140, 120, 96][c.thumbSize.value]; c.thumb.value = Settings.enableThumbSlider; var imageSizes = c.provider.uris.map((e) { @@ -757,9 +753,9 @@ class _ViewerOverlayState extends State { if (sz != null) { _thumbImageStartPos[i + 1] = - (thumbHeight - 14.0) * sz.width / sz.height; + (c.thumbSizeValue - 14.0) * sz.width / sz.height; } else { - _thumbImageStartPos[i + 1] = (thumbHeight - 14.0) / 36 * 25; + _thumbImageStartPos[i + 1] = (c.thumbSizeValue - 14.0) / 36 * 25; } _thumbImageWidth[i] = _thumbImageStartPos[i + 1]; @@ -818,9 +814,7 @@ class _ViewerOverlayState extends State { width: double.infinity, height: double.infinity, isAntiAlias: true, - cacheHeight: - ([180, 140, 120, 96][c.thumbSize.value] * 2.0) - .toInt(), + cacheHeight: (c.thumbSizeValue * 2.0).toInt(), filterQuality: FilterQuality.high, ), ), diff --git a/violet/lib/pages/viewer/viewer_controller.dart b/violet/lib/pages/viewer/viewer_controller.dart index f4740572f..ec3972972 100644 --- a/violet/lib/pages/viewer/viewer_controller.dart +++ b/violet/lib/pages/viewer/viewer_controller.dart @@ -1,6 +1,8 @@ // This source code is a part of Project Violet. // Copyright (C) 2020-2024. violet-team. Licensed under the Apache-2.0 License. +import 'dart:io'; + import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -63,6 +65,10 @@ class ViewerController extends GetxController { var search = false.obs; var bookmark = false.obs; + double get thumbSizeValue => + [180.0, 140.0, 120.0, 96.0][thumbSize.value] * + (Platform.isWindows ? 3.0 : 0); + /// timer options var timer = false.obs; var timerTick = Settings.timerTick.obs; From 2f5da9cf1aa837fe2d68c5659e499d8f6760f9cf Mon Sep 17 00:00:00 2001 From: violet-dev Date: Sun, 10 Nov 2024 11:18:25 +0900 Subject: [PATCH 7/7] Bump flutter webview --- .../after_loading/afterloading_page.dart | 1 + violet/lib/script/script_webview.dart | 16 +++-- violet/pubspec.lock | 68 ++++++++++++++++++- violet/pubspec.yaml | 2 +- .../flutter/generated_plugin_registrant.cc | 6 ++ .../windows/flutter/generated_plugins.cmake | 2 + 6 files changed, 86 insertions(+), 9 deletions(-) diff --git a/violet/lib/pages/after_loading/afterloading_page.dart b/violet/lib/pages/after_loading/afterloading_page.dart index 4308209b2..b46aa620d 100644 --- a/violet/lib/pages/after_loading/afterloading_page.dart +++ b/violet/lib/pages/after_loading/afterloading_page.dart @@ -345,6 +345,7 @@ class AfterLoadingPageState extends State child: Stack( children: [ if (kReleaseMode) const ScriptWebView(), + const ScriptWebView(), PageView( controller: _pageController, physics: diff --git a/violet/lib/script/script_webview.dart b/violet/lib/script/script_webview.dart index 0cde1cf65..64eb8148b 100644 --- a/violet/lib/script/script_webview.dart +++ b/violet/lib/script/script_webview.dart @@ -50,6 +50,7 @@ class _ScriptWebViewState extends State } Future timerCallback(timer) async { + Logger.error('reload!!'); webViewController?.reload(); } @@ -83,14 +84,14 @@ class _ScriptWebViewState extends State height: 1, child: InAppWebView( initialUrlRequest: URLRequest( - url: Uri.parse('https://hitomi.la/'), + url: WebUri.uri(Uri.parse('https://hitomi.la/')), ), - initialOptions: InAppWebViewGroupOptions( - crossPlatform: InAppWebViewOptions( - useOnLoadResource: true, - userAgent: - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36')), + initialSettings: InAppWebViewSettings( + useOnLoadResource: true, + userAgent: + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'), onWebViewCreated: (controller) { + Logger.warning('agg'); webViewController = controller; controller.addJavaScriptHandler( @@ -110,6 +111,7 @@ class _ScriptWebViewState extends State } }, onLoadError: ((controller, url, code, message) { + Logger.warning('$code $message'); // net::ERR_CONNECTION_RESET // NSURLErrorDomain -999 (Connection Reset) // An SSL error has occurred and a secure connection to the server cannot be made. @@ -126,6 +128,7 @@ class _ScriptWebViewState extends State Logger.error('[Script Webview] Error $code\n$message'); }), onLoadHttpError: (controller, url, statusCode, description) { + Logger.warning('kk'); if (!(url.toString() == 'https://hitomi.la' || url.toString() == 'https://hitomi.la/')) return; @@ -145,6 +148,7 @@ class _ScriptWebViewState extends State '[Script Webview] Http Error $statusCode\n$description'); }, onLoadStop: (controller, url) async { + Logger.warning('aac'); if (isCurrentReload) { isCurrentReload = false; return; diff --git a/violet/pubspec.lock b/violet/pubspec.lock index c79b16c57..29ac022c1 100644 --- a/violet/pubspec.lock +++ b/violet/pubspec.lock @@ -728,10 +728,66 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - sha256: d198297060d116b94048301ee6749cd2e7d03c1f2689783f52d210a6b7aba350 + sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5" url: "https://pub.dev" source: hosted - version: "5.8.0" + version: "6.1.5" + flutter_inappwebview_android: + dependency: transitive + description: + name: flutter_inappwebview_android + sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + flutter_inappwebview_internal_annotations: + dependency: transitive + description: + name: flutter_inappwebview_internal_annotations + sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_inappwebview_ios: + dependency: transitive + description: + name: flutter_inappwebview_ios + sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_inappwebview_macos: + dependency: transitive + description: + name: flutter_inappwebview_macos + sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + name: flutter_inappwebview_platform_interface + sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500 + url: "https://pub.dev" + source: hosted + version: "1.3.0+1" + flutter_inappwebview_web: + dependency: transitive + description: + name: flutter_inappwebview_web + sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_inappwebview_windows: + dependency: transitive + description: + name: flutter_inappwebview_windows + sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055" + url: "https://pub.dev" + source: hosted + version: "0.6.0" flutter_js: dependency: "direct main" description: @@ -1772,6 +1828,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.6" + sqlite3_flutter_libs: + dependency: "direct main" + description: + name: sqlite3_flutter_libs + sha256: "7ae52b23366e5295005022e62fa093f64bfe190810223ea0ebf733a4cd140bce" + url: "https://pub.dev" + source: hosted + version: "0.5.26" stack_trace: dependency: transitive description: diff --git a/violet/pubspec.yaml b/violet/pubspec.yaml index 99c97b606..666b0b80a 100644 --- a/violet/pubspec.yaml +++ b/violet/pubspec.yaml @@ -87,7 +87,7 @@ dependencies: flutter_downloader: ^1.11.3 flutter_heatmap_calendar: ^1.0.5 flutter_image_compress: ^2.0.4 - flutter_inappwebview: ^5.8.0 + flutter_inappwebview: ^6.1.5 flutter_markdown: flutter_mobx: flutter_reorderable_list: diff --git a/violet/windows/flutter/generated_plugin_registrant.cc b/violet/windows/flutter/generated_plugin_registrant.cc index 71808f8ba..10148c259 100644 --- a/violet/windows/flutter/generated_plugin_registrant.cc +++ b/violet/windows/flutter/generated_plugin_registrant.cc @@ -8,9 +8,11 @@ #include #include +#include #include #include #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -18,12 +20,16 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); FirebaseCorePluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); + FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); FlutterJsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterJsPlugin")); LocalAuthPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("LocalAuthPlugin")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + Sqlite3FlutterLibsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/violet/windows/flutter/generated_plugins.cmake b/violet/windows/flutter/generated_plugins.cmake index dd34db612..e9b098f74 100644 --- a/violet/windows/flutter/generated_plugins.cmake +++ b/violet/windows/flutter/generated_plugins.cmake @@ -5,9 +5,11 @@ list(APPEND FLUTTER_PLUGIN_LIST connectivity_plus firebase_core + flutter_inappwebview_windows flutter_js local_auth_windows permission_handler_windows + sqlite3_flutter_libs url_launcher_windows )