Skip to content

Commit

Permalink
Merge branch 'master' of https://gitee.com/jiangtian616/JHenTai
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangtian616 committed Apr 10, 2022
2 parents 658307e + 5436e78 commit 993511a
Show file tree
Hide file tree
Showing 20 changed files with 486 additions and 85 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ mush thanks to these projects🙇‍

## screenshot

<img width="250" style="margin-right:10px" src="screenshot/1.jpg"/> <img width="250" style="margin-right:10px" src="screenshot/2.jpg"/> <img width="250" src="screenshot/3.jpg"/>
<img width="250" style="margin-right:10px" src="screenshot/1.jpg"/>
<img width="250" style="margin-right:10px" src="screenshot/2.jpg"/>
<img width="250" style="margin-right:10px" src="screenshot/3.jpg"/>
<img width="250" src="screenshot/4.jpg"/>

<img width="770" src="screenshot/4.png"/>
<img width="770" src="screenshot/0.png"/>

## Main Features

- [x] GalleryPage, Popular, Favorite, Watched, History, support multiple gallery list style
- [x] search, search suggestion, tap tag to search, file search, jump to a certain page
- [x] online reading and download, support restore download task
- [x] favorite, rating, torrent, archive, share
- [x] favorite, rating, torrent, archive, statistics, share
- [x] password login, Cookie login, web login
- [x] support EX site
- [x] vote for Tag, watch and hidden tags
Expand All @@ -64,7 +67,6 @@ mush thanks to these projects🙇‍
## Feature Todo

- [ ] customize Archive Page, support automatic unzip and read directly
- [ ] customize Statistic Page
- [ ] support sharing favorite

## Improvement & Todo
Expand All @@ -81,6 +83,11 @@ mush thanks to these projects🙇‍

## Bug

1. Local cookie file will be broken in some cases, causing login status invalid, and now I don't know why.
In logs, we can see errors like `_hostSet hasn't been initializeed`.
Can be solved by logout and login again temporarily.


## Main Dart Dependencies

- dependency management, state management, l18n, NoSQL: get
Expand Down
14 changes: 9 additions & 5 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
E-hentai 的一个移动端app。

仍在起步阶段,欢迎提交issue。

## 下载&安装

[下载](https://github.com/jiangtian616/JHenTai/releases)
Expand Down Expand Up @@ -37,16 +38,19 @@ E-hentai 的一个移动端app。

## 截图

<img width="250" style="margin-right:10px" src="screenshot/1.jpg"/> <img width="250" style="margin-right:10px" src="screenshot/2.jpg"/> <img width="250" src="screenshot/3.jpg"/>
<img width="250" style="margin-right:10px" src="screenshot/1.jpg"/>
<img width="250" style="margin-right:10px" src="screenshot/2.jpg"/>
<img width="250" style="margin-right:10px" src="screenshot/3.jpg"/>
<img width="250" src="screenshot/4.jpg"/>

<img width="770" src="screenshot/4.png"/>
<img width="770" src="screenshot/0.png"/>

## 主要功能

- [x] 主页、热门、收藏、关注、历史,支持多种画廊样式
- [x] 搜索、搜索Tag提示、点击Tag快捷搜索、以图搜图、跳页
- [x] 在线阅读与下载,支持恢复下载记录
- [x] 收藏、评分、磁力、归档、分享
- [x] 收藏、评分、磁力、归档、统计、分享
- [x] 账号密码登录、Cookie登录、Web登录
- [x] 支持里站
- [x] Tag翻译、Tag投票、关注Tag、隐藏Tag
Expand All @@ -56,9 +60,7 @@ E-hentai 的一个移动端app。

## 功能Todo

- [ ] 接入E站本身的My Tags
- [ ] 自定义归档视图,支持下载完后自动解压、阅读
- [ ] 自定义统计视图
- [ ] 支持收藏夹分享

## 优化Todo
Expand All @@ -74,6 +76,8 @@ E-hentai 的一个移动端app。

## 已知bug

1. 本地Cookie文件记录会因不明原因而损坏,导致登录状态失效。日志中可以见到 `_hostSet hasn't been initializeed` 等字样,暂时可以通过注销再重新登陆解决。

## 主要dart依赖

- 依赖管理、状态管理、国际化、NoSQL:get
Expand Down
10 changes: 10 additions & 0 deletions lib/src/l18n/en_US.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ class en_US {
'addNewHiddenTagSetSuccess': 'Add New Hidden Tag Set Success',
'addNewTagSetSuccessHint': 'You can check your tags at Setting->EH->My Tags',
'addNewTagSetFailed': 'Add New Tag Set Failed',
'VisitorStatistics': 'Visitor Statistics',
'invisible2UserWithoutDonation': 'This gallery\'s stats is invisible to user without donation',
'getGalleryStatisticsFailed': 'Get Gallery Statistics Failed',
'totalVisits': 'Total Visits',
'visits': 'Visits',
'imageAccesses': 'Image Accesses',
'period': 'Period',
'ranking': 'Ranking',
'score': 'Score',
'NotOnTheList': 'Not on the list',

/// comment page
'newComment': 'New Comment',
Expand Down
10 changes: 10 additions & 0 deletions lib/src/l18n/zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ class zh_CN {
'addNewHiddenTagSetSuccess': '添加新隐藏标签成功',
'addNewTagSetSuccessHint': '你可以在 设置->EH->我的标签 查看你的所有标签',
'addNewTagSetFailed': '添加新标签数据失败',
'VisitorStatistics': '访问数据',
'invisible2UserWithoutDonation': '该画廊统计数据对未捐赠用户不可见',
'getGalleryStatisticsFailed': '获取画廊统计数据失败',
'totalVisits': '总访问量',
'visits': '访问数',
'imageAccesses': '图片访问数',
'period': '时间段',
'ranking': '排行',
'score': '分数',
'NotOnTheList': '未上榜',

/// comment page
'newComment': '新评论',
Expand Down
54 changes: 54 additions & 0 deletions lib/src/model/gallery_stats.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class GalleryStats {
int totalVisits;

int? allTimeRanking;
int? allTimeScore;
int? yearRanking;
int? yearScore;
int? monthRanking;
int? monthScore;
int? dayRanking;
int? dayScore;

List<VisitStat> yearlyStats;
List<VisitStat> monthlyStats;
List<VisitStat> dailyStats;

GalleryStats({
required this.totalVisits,
this.allTimeRanking,
this.allTimeScore,
this.yearRanking,
this.yearScore,
this.monthRanking,
this.monthScore,
this.dayRanking,
this.dayScore,
required this.yearlyStats,
required this.monthlyStats,
required this.dailyStats,
});
}

class VisitStat {
/// 1. 2013
/// 2. January
/// 3. 1st
String period;

/// 1. 16.2M
/// 2. 570K
/// 3. 5731
double visits;

/// 1. 16.2M
/// 2. 570K
/// 3. 5731
double hits;

VisitStat({
required this.period,
required this.visits,
required this.hits,
});
}
47 changes: 12 additions & 35 deletions lib/src/network/eh_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class EHRequest {
static Future<void> storeEhCookiesForAllUri(List<Cookie> cookies) async {
/// never warn about offensive gallery
cookies.add(Cookie("nw", "1"));
Log.info('store cookies: ${cookies.toString()}',false);
Log.info('store cookies: ${cookies.toString()}', false);
Future.wait(EHConsts.host2Ip.keys.map((host) => _storeCookies('https://' + host, cookies)));
Future.wait(EHConsts.host2Ip.values.map((ip) => _storeCookies('https://' + ip, cookies)));
}
Expand Down Expand Up @@ -208,40 +208,8 @@ class EHRequest {
CancelToken? cancelToken,
required EHHtmlParser<T> parser,
}) async {
Response<String> response;

if (EHSetting.redirect2EH.isFalse || galleryUrl.startsWith(EHConsts.EHIndex)) {
response = await _dio.get(
galleryUrl,
queryParameters: {'p': thumbnailsPageNo},
cancelToken: cancelToken,
options: useCacheIfAvailable
? cacheOption.copyWith(policy: CachePolicy.forceCache).toOptions()
: cacheOption.copyWith(policy: CachePolicy.refreshForceCache).toOptions(),
);
return parser(response);
}

Log.verbose('try redirect to EH site', false);
try {
response = await _dio.get(
galleryUrl.replaceFirst(EHConsts.EXIndex, EHConsts.EHIndex),
queryParameters: {'p': thumbnailsPageNo},
cancelToken: cancelToken,
options: useCacheIfAvailable
? cacheOption.copyWith(policy: CachePolicy.forceCache).toOptions()
: cacheOption.copyWith(policy: CachePolicy.refreshForceCache).toOptions(),
);
return parser(response);
} on DioError catch (e) {
if (e.response?.statusCode != 404) {
rethrow;
}
Log.verbose('redirect to EH 404', false);
}

response = await _dio.get(
galleryUrl,
Response response = await _dio.get(
EHSetting.site.value == 'EH' ? galleryUrl : galleryUrl.replaceFirst(EHConsts.EHIndex, EHConsts.EXIndex),
queryParameters: {'p': thumbnailsPageNo},
cancelToken: cancelToken,
options: useCacheIfAvailable
Expand Down Expand Up @@ -374,6 +342,15 @@ class EHRequest {
return parser(response);
}

static Future<T> requestStatPage<T>({
required int gid,
required String token,
required EHHtmlParser<T> parser,
}) async {
Response<String> response = await _dio.get('${EHConsts.EStat}?gid=$gid&t=$token');
return parser(response);
}

static Future<T> requestAddTagSet<T>({
required String tag,
String? tagColor,
Expand Down
10 changes: 2 additions & 8 deletions lib/src/pages/details/details_page_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:jhentai/src/model/gallery_thumbnail.dart';
import 'package:jhentai/src/network/eh_request.dart';
import 'package:jhentai/src/pages/details/widget/favorite_dialog.dart';
import 'package:jhentai/src/pages/details/widget/stat_dialog.dart';
import 'package:jhentai/src/pages/details/widget/torrent_dialog.dart';
import 'package:jhentai/src/pages/search/search_page_logic.dart';
import 'package:jhentai/src/routes/routes.dart';
Expand Down Expand Up @@ -404,14 +405,7 @@ class DetailsPageLogic extends GetxController {
}

Future<void> handleTapStatistic() async {
List<Cookie> cookies = await EHRequest.getCookie(Uri.parse(EHConsts.EIndex));
toNamed(
Routes.webview,
arguments: {
'url': '${EHConsts.EStat}?gid=${state.gallery!.gid}&t=${state.gallery!.token}',
'cookies': CookieUtil.parse2String(cookies)
},
);
Get.dialog(const StatDialog());
}

void goToReadPage([int? index]) {
Expand Down
Loading

0 comments on commit 993511a

Please sign in to comment.