pikapika/lib/basic/Method.dart

837 lines
22 KiB
Dart
Raw Normal View History

2021-09-29 23:57:09 +00:00
import 'dart:convert';
2021-11-06 11:25:44 +00:00
import 'dart:typed_data';
2021-09-29 23:57:09 +00:00
import 'package:flutter/services.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/Entities.dart';
2021-09-29 23:57:09 +00:00
2021-10-21 04:08:51 +00:00
/// 使用MethodChannel与平台通信
2021-09-29 23:57:09 +00:00
final method = Method._();
class Method {
2021-10-21 04:08:51 +00:00
/// 禁止其他页面构造此类
2021-09-29 23:57:09 +00:00
Method._();
2021-10-21 04:08:51 +00:00
/// channel
2022-03-17 03:31:25 +00:00
final MethodChannel _channel = const MethodChannel("method");
2021-09-29 23:57:09 +00:00
2021-10-21 04:08:51 +00:00
/// 平铺调用, 为了直接与golang进行通信
2021-09-29 23:57:09 +00:00
Future<dynamic> _flatInvoke(String method, dynamic params) {
return _channel.invokeMethod("flatInvoke", {
"method": method,
"params": params is String ? params : jsonEncode(params),
});
}
2021-10-21 04:08:51 +00:00
/// 读取配置文件
2021-09-29 23:57:09 +00:00
Future<String> loadProperty(String propertyName, String defaultValue) async {
return await _flatInvoke("loadProperty", {
"name": propertyName,
"defaultValue": defaultValue,
});
}
2021-10-21 04:08:51 +00:00
/// 保存配置文件
2021-09-29 23:57:09 +00:00
Future<dynamic> saveProperty(String propertyName, String value) {
return _flatInvoke("saveProperty", {
"name": propertyName,
"value": value,
});
}
2021-10-21 04:08:51 +00:00
/// 获取当前的分流
2021-09-29 23:57:09 +00:00
Future<String> getSwitchAddress() async {
return await _flatInvoke("getSwitchAddress", "");
}
2021-10-21 04:08:51 +00:00
/// 更换分流
2021-09-29 23:57:09 +00:00
Future<dynamic> setSwitchAddress(String switchAddress) async {
return await _flatInvoke("setSwitchAddress", switchAddress);
}
2021-11-30 02:23:49 +00:00
/// 获取当前的图片分流
Future<String> getImageSwitchAddress() async {
return await _flatInvoke("getImageSwitchAddress", "");
}
/// 更换图片分流
Future<dynamic> setImageSwitchAddress(String switchAddress) async {
return await _flatInvoke("setImageSwitchAddress", switchAddress);
}
2021-10-21 04:08:51 +00:00
/// 获取代理
2021-09-29 23:57:09 +00:00
Future<String> getProxy() async {
return await _flatInvoke("getProxy", "");
}
2021-10-21 04:08:51 +00:00
/// 更换当前的代理
2021-09-29 23:57:09 +00:00
Future<dynamic> setProxy(String proxy) async {
return await _flatInvoke("setProxy", proxy);
}
2021-10-21 04:08:51 +00:00
/// 获取用户名
2021-09-29 23:57:09 +00:00
Future<String> getUsername() async {
return await _flatInvoke("getUsername", "");
}
2021-10-21 04:08:51 +00:00
/// 设置用户名
2021-09-29 23:57:09 +00:00
Future<dynamic> setUsername(String username) async {
return await _flatInvoke("setUsername", username);
}
2021-10-21 04:08:51 +00:00
/// 获取密码
2021-09-29 23:57:09 +00:00
Future<String> getPassword() async {
return await _flatInvoke("getPassword", "");
}
2021-10-21 04:08:51 +00:00
/// 设置密码
2021-09-29 23:57:09 +00:00
Future<dynamic> setPassword(String password) async {
return await _flatInvoke("setPassword", password);
}
2021-10-21 04:08:51 +00:00
/// 预登录, 程序启用时会调用
/// 如果又账号密码或token, 且登录成功, 将返回true
2021-09-29 23:57:09 +00:00
Future<bool> preLogin() async {
String rsp = await _flatInvoke("preLogin", "");
return rsp == "true";
}
2021-10-21 04:08:51 +00:00
/// 登录
2021-09-29 23:57:09 +00:00
Future<dynamic> login() async {
return _flatInvoke("login", "");
}
2021-10-21 04:08:51 +00:00
/// 注册
2021-09-29 23:57:09 +00:00
Future<dynamic> register(
String email,
String name,
String password,
String gender,
String birthday,
String question1,
String answer1,
String question2,
String answer2,
String question3,
String answer3) {
return _flatInvoke("register", {
"email": email,
"name": name,
"password": password,
"gender": gender,
"birthday": birthday,
"question1": question1,
"answer1": answer1,
"question2": question2,
"answer2": answer2,
"question3": question3,
"answer3": answer3,
});
}
2021-10-21 04:08:51 +00:00
/// 退出登录
2021-09-29 23:57:09 +00:00
Future<dynamic> clearToken() {
return _flatInvoke("clearToken", "");
}
2021-10-21 04:08:51 +00:00
/// 获取用户自身基础信息
2021-09-29 23:57:09 +00:00
Future<UserProfile> userProfile() async {
String rsp = await _flatInvoke("userProfile", "");
return UserProfile.fromJson(json.decode(rsp));
}
2021-10-21 04:08:51 +00:00
/// 打卡
2021-09-29 23:57:09 +00:00
Future<dynamic> punchIn() {
return _flatInvoke("punchIn", "");
}
2021-10-21 04:08:51 +00:00
/// 使用服务器地址以及路径获取图片用户显示
/// 如果本地有缓存会返回路径, 如果本地没有缓存会下载再返回路径, 没有下载成功则会抛出异常
2021-09-29 23:57:09 +00:00
Future<RemoteImageData> remoteImageData(
String fileServer, String path) async {
var data = await _flatInvoke("remoteImageData", {
"fileServer": fileServer,
"path": path,
});
return RemoteImageData.fromJson(json.decode(data));
}
2021-10-21 04:08:51 +00:00
/// 功能同上, 用于预加载
Future<dynamic> remoteImagePreload(String fileServer, String path) async {
return _flatInvoke("remoteImagePreload", {
"fileServer": fileServer,
"path": path,
});
}
2021-10-21 04:08:51 +00:00
/// 获取已经下载好图片的保存位置
2021-09-29 23:57:09 +00:00
Future<String> downloadImagePath(String path) async {
return await _flatInvoke("downloadImagePath", path);
}
2021-10-21 04:08:51 +00:00
/// 获取分类
2021-09-29 23:57:09 +00:00
Future<List<Category>> categories() async {
String rsp = await _flatInvoke("categories", "");
List list = json.decode(rsp);
return list.map((e) => Category.fromJson(e)).toList();
}
2021-10-21 04:08:51 +00:00
/// 列出漫画
/// [sort] 排序方式
/// [page] 页数
/// [category] 分类
/// [tag] 标签
/// [creatorId] 创建人ID
/// [chineseTeam] 汉化组名称
/// * 几种条件使用且的关系
2021-09-29 23:57:09 +00:00
Future<ComicsPage> comics(
String sort,
int page, {
String category = "",
String tag = "",
String creatorId = "",
String chineseTeam = "",
}) async {
String rsp = await _flatInvoke("comics", {
"category": category,
"tag": tag,
"creatorId": creatorId,
"chineseTeam": chineseTeam,
"sort": sort,
"page": page,
});
return ComicsPage.fromJson(json.decode(rsp));
}
2021-10-21 04:08:51 +00:00
/// 搜索漫画
2021-09-29 23:57:09 +00:00
Future<ComicsPage> searchComics(String keyword, String sort, int page) {
return searchComicsInCategories(keyword, sort, page, []);
}
2021-10-21 04:08:51 +00:00
/// 搜索漫画, 在多个分类中
2021-09-29 23:57:09 +00:00
Future<ComicsPage> searchComicsInCategories(
String keyword, String sort, int page, List<String> categories) async {
String rsp = await _flatInvoke("searchComics", {
"keyword": keyword,
"sort": sort,
"page": page,
"categories": categories,
});
return ComicsPage.fromJson(json.decode(rsp));
}
2021-10-21 04:08:51 +00:00
/// 随机漫画
2021-09-29 23:57:09 +00:00
Future<List<ComicSimple>> randomComics() async {
String data = await _flatInvoke("randomComics", "");
return List.of(jsonDecode(data))
.map((e) => Map<String, dynamic>.of(e))
.map((e) => ComicSimple.fromJson(e))
.toList();
}
2021-10-21 04:08:51 +00:00
/// 漫画榜单
/// [type] 榜单类型 H24 D7 D30
2021-09-29 23:57:09 +00:00
Future<List<ComicSimple>> leaderboard(String type) async {
String data = await _flatInvoke("leaderboard", type);
return List.of(jsonDecode(data))
.map((e) => Map<String, dynamic>.of(e))
.map((e) => ComicSimple.fromJson(e))
.toList();
}
2021-10-21 04:08:51 +00:00
/// 获取漫画详情
2021-09-29 23:57:09 +00:00
Future<ComicInfo> comicInfo(String comicId) async {
String rsp = await _flatInvoke("comicInfo", comicId);
return ComicInfo.fromJson(json.decode(rsp));
}
2021-10-21 04:08:51 +00:00
/// 分页获取漫画的章节
2021-09-29 23:57:09 +00:00
Future<EpPage> comicEpPage(String comicId, int page) async {
String rsp = await _flatInvoke("comicEpPage", {
"comicId": comicId,
"page": page,
});
return EpPage.fromJson(json.decode(rsp));
}
2021-10-21 04:08:51 +00:00
/// 分页获取一个章节的图片, 并且需要图片的质量参数
2021-09-29 23:57:09 +00:00
Future<PicturePage> comicPicturePageWithQuality(
String comicId, int epOrder, int page, String quality) async {
String data = await _flatInvoke("comicPicturePageWithQuality", {
"comicId": comicId,
"epOrder": epOrder,
"page": page,
"quality": quality,
});
return PicturePage.fromJson(json.decode(data));
}
2021-10-21 04:08:51 +00:00
/// 对漫画进行点赞/取消点赞操作
2021-09-29 23:57:09 +00:00
Future<String> switchLike(String comicId) async {
return await _flatInvoke("switchLike", comicId);
}
2021-10-21 04:08:51 +00:00
/// 对漫画进行收藏/取消收藏操作
2021-09-29 23:57:09 +00:00
Future<String> switchFavourite(String comicId) async {
return await _flatInvoke("switchFavourite", comicId);
}
2021-10-21 04:08:51 +00:00
/// 收藏漫画列表
2021-09-29 23:57:09 +00:00
Future<ComicsPage> favouriteComics(String sort, int page) async {
var rsp = await _flatInvoke("favouriteComics", {
"sort": sort,
"page": page,
});
return ComicsPage.fromJson(json.decode(rsp));
}
2022-04-18 02:55:08 +00:00
/// 看了此漫画的人还看了...
2021-09-29 23:57:09 +00:00
Future<List<ComicSimple>> recommendation(String comicId) async {
String rsp = await _flatInvoke("recommendation", comicId);
List list = json.decode(rsp);
return list.map((e) => ComicSimple.fromJson(e)).toList();
}
2021-10-21 04:08:51 +00:00
/// 对漫画发送评论
2021-09-29 23:57:09 +00:00
Future<dynamic> postComment(String comicId, String content) {
return _flatInvoke("postComment", {
"comicId": comicId,
"content": content,
});
}
2021-10-21 04:08:51 +00:00
/// 发送子评论
2021-09-29 23:57:09 +00:00
Future<dynamic> postChildComment(String commentId, String content) {
return _flatInvoke("postChildComment", {
"commentId": commentId,
"content": content,
});
}
2021-10-21 04:08:51 +00:00
/// 漫画的评论列表
2021-09-29 23:57:09 +00:00
Future<CommentPage> comments(String comicId, int page) async {
var rsp = await _flatInvoke("comments", {
"comicId": comicId,
"page": page,
});
return CommentPage.fromJson(json.decode(rsp));
}
2021-10-21 04:08:51 +00:00
/// 拉取子评论
2021-09-29 23:57:09 +00:00
Future<CommentChildrenPage> commentChildren(
String comicId,
String commentId,
int page,
) async {
var rsp = await _flatInvoke("commentChildren", {
"comicId": comicId,
"commentId": commentId,
"page": page,
});
return CommentChildrenPage.fromJson(json.decode(rsp));
}
2021-11-09 21:57:44 +00:00
/// 喜欢/取消喜欢 一条评论
Future switchLikeComment(String commentId, String comicId) {
return _flatInvoke("switchLikeComment", {
"commentId": commentId,
"comicId": comicId,
});
}
2021-10-21 04:08:51 +00:00
/// 我的评论列表
2021-09-29 23:57:09 +00:00
Future<MyCommentsPage> myComments(int page) async {
String response = await _flatInvoke("myComments", "$page");
return MyCommentsPage.fromJson(jsonDecode(response));
}
2021-10-21 04:08:51 +00:00
/// 浏览记录
2021-09-29 23:57:09 +00:00
Future<List<ViewLog>> viewLogPage(int offset, int limit) async {
var data = await _flatInvoke("viewLogPage", {
"offset": offset,
"limit": limit,
});
List list = json.decode(data);
return list.map((e) => ViewLog.fromJson(e)).toList();
}
2021-10-21 04:08:51 +00:00
/// 清除所有的浏览记录
2021-09-29 23:57:09 +00:00
Future<dynamic> clearAllViewLog() {
return _flatInvoke("clearAllViewLog", "");
}
2021-10-21 04:08:51 +00:00
/// 删除一个漫画的浏览记录
2021-09-29 23:57:09 +00:00
Future<dynamic> deleteViewLog(String id) {
return _flatInvoke("deleteViewLog", id);
}
2021-10-21 04:08:51 +00:00
/// 游戏列表
2021-09-29 23:57:09 +00:00
Future<GamePage> games(int page) async {
var data = await _flatInvoke("games", "$page");
return GamePage.fromJson(json.decode(data));
}
2021-10-21 04:08:51 +00:00
/// 游戏详情
2021-09-29 23:57:09 +00:00
Future<GameInfo> game(String gameId) async {
var data = await _flatInvoke("game", gameId);
return GameInfo.fromJson(json.decode(data));
}
2021-11-09 21:57:44 +00:00
/// 游戏的评论列表
Future<GameCommentPage> gameComments(String gameId, int page) async {
var rsp = await _flatInvoke("gameComments", {
"gameId": gameId,
"page": page,
});
return GameCommentPage.fromJson(json.decode(rsp));
}
/// 对游戏发送评论
Future<dynamic> postGameComment(String gameId, String content) {
return _flatInvoke("postGameComment", {
"gameId": gameId,
"content": content,
});
}
/// 拉取游戏子评论
Future<GameCommentChildrenPage> gameCommentChildren(
String gameId,
String commentId,
int page,
) async {
var rsp = await _flatInvoke("gameCommentChildren", {
"gameId": gameId,
"commentId": commentId,
"page": page,
});
return GameCommentChildrenPage.fromJson(json.decode(rsp));
}
/// 喜欢/取消喜欢 一条游戏评论
Future switchLikeGameComment(String commentId, String gameId) {
return _flatInvoke("switchLikeGameComment", {
"commentId": commentId,
"gameId": gameId,
});
}
/// 发送游戏子评论
Future<dynamic> postGameChildComment(String commentId, String content) {
return _flatInvoke("postGameChildComment", {
"commentId": commentId,
"content": content,
});
}
2021-11-08 05:38:27 +00:00
/// 清理网络缓存
Future cleanNetworkCache() {
return _flatInvoke("cleanNetworkCache", "");
}
/// 清理图片缓存
Future cleanImageCache() {
return _flatInvoke("cleanImageCache", "");
}
2021-10-21 04:08:51 +00:00
/// 清理缓存
2021-09-29 23:57:09 +00:00
Future clean() {
return _flatInvoke("clean", "");
}
2021-10-21 04:08:51 +00:00
/// 清理[expireSec]秒以前的缓存
2021-09-29 23:57:09 +00:00
Future autoClean(String expireSec) {
return _flatInvoke("autoClean", expireSec);
}
2021-10-21 04:08:51 +00:00
/// 保存当前浏览器的进度
2021-09-29 23:57:09 +00:00
Future storeViewEp(
String comicId, int epOrder, String epTitle, int pictureRank) {
return _flatInvoke("storeViewEp", {
"comicId": comicId,
"epOrder": epOrder,
"epTitle": epTitle,
"pictureRank": pictureRank,
});
}
2021-10-21 04:08:51 +00:00
/// 加载浏览进度
2021-09-29 23:57:09 +00:00
Future<ViewLog?> loadView(String comicId) async {
String data = await _flatInvoke("loadView", comicId);
if (data == "") {
return null;
}
return ViewLog.fromJson(jsonDecode(data));
}
2021-10-21 04:08:51 +00:00
/// 下载是否在后台运行
2021-09-29 23:57:09 +00:00
Future<bool> downloadRunning() async {
String rsp = await _flatInvoke("downloadRunning", "");
return rsp == "true";
}
2021-10-21 04:08:51 +00:00
/// 暂停/继续 下载
2021-09-29 23:57:09 +00:00
Future<dynamic> setDownloadRunning(bool status) async {
return _flatInvoke("setDownloadRunning", "$status");
}
2021-10-21 04:08:51 +00:00
/// 下载漫画
2021-09-29 23:57:09 +00:00
Future<dynamic> createDownload(
Map<String, dynamic> comic, List<Map<String, dynamic>> epList) async {
return _flatInvoke("createDownload", {
"comic": comic,
"epList": epList,
});
}
2021-10-21 04:08:51 +00:00
/// 追加下载的章节
2021-09-29 23:57:09 +00:00
Future<dynamic> addDownload(
Map<String, dynamic> comic, List<Map<String, dynamic>> epList) async {
await _flatInvoke("addDownload", {
"comic": comic,
"epList": epList,
});
}
2021-10-21 04:08:51 +00:00
/// 下载详情
2021-09-29 23:57:09 +00:00
Future<DownloadComic?> loadDownloadComic(String comicId) async {
var data = await _flatInvoke("loadDownloadComic", comicId);
// 未找到 且 未异常
if (data == "") {
return null;
}
return DownloadComic.fromJson(json.decode(data));
}
2021-10-21 04:08:51 +00:00
/// 所有下载
2021-09-29 23:57:09 +00:00
Future<List<DownloadComic>> allDownloads() async {
var data = await _flatInvoke("allDownloads", "");
data = jsonDecode(data);
if (data == null) {
return [];
}
List list = data;
return list.map((e) => DownloadComic.fromJson(e)).toList();
}
2021-10-21 04:08:51 +00:00
/// 删除一个下载
2021-09-29 23:57:09 +00:00
Future<dynamic> deleteDownloadComic(String comicId) async {
return _flatInvoke("deleteDownloadComic", comicId);
}
2021-10-21 04:08:51 +00:00
/// 所有下载的EP
2021-09-29 23:57:09 +00:00
Future<List<DownloadEp>> downloadEpList(String comicId) async {
var data = await _flatInvoke("downloadEpList", comicId);
List list = json.decode(data);
return list.map((e) => DownloadEp.fromJson(e)).toList();
}
2021-10-21 04:08:51 +00:00
/// 下载漫画这个EP下的图片
2021-09-29 23:57:09 +00:00
Future<List<DownloadPicture>> downloadPicturesByEpId(String epId) async {
var data = await _flatInvoke("downloadPicturesByEpId", epId);
List list = json.decode(data);
return list.map((e) => DownloadPicture.fromJson(e)).toList();
}
2021-10-21 04:08:51 +00:00
/// 重置所有下载失败的漫画
2021-09-29 23:57:09 +00:00
Future<dynamic> resetFailed() async {
return _flatInvoke("resetAllDownloads", "");
}
2021-10-21 04:08:51 +00:00
/// 导出下载的漫画到zip
2022-02-25 10:46:11 +00:00
Future<dynamic> exportComicDownload(String comicId, String dir, String name) {
2021-09-29 23:57:09 +00:00
return _flatInvoke("exportComicDownload", {
"comicId": comicId,
"dir": dir,
2022-02-25 10:46:11 +00:00
"name": name,
2021-09-29 23:57:09 +00:00
});
}
2022-07-01 05:39:08 +00:00
/// 导出下载的漫画到pki
Future<dynamic> exportComicDownloadToPki(String comicId, String dir, String name) {
return _flatInvoke("exportComicDownloadToPki", {
"comicId": comicId,
"dir": dir,
"name": name,
});
}
2021-10-21 04:08:51 +00:00
/// 导出下载的图片到HTML+JPG
2022-02-25 10:46:11 +00:00
Future<dynamic> exportComicDownloadToJPG(
String comicId,
String dir,
String name,
) {
2021-09-29 23:57:09 +00:00
return _flatInvoke("exportComicDownloadToJPG", {
"comicId": comicId,
"dir": dir,
2022-02-25 10:46:11 +00:00
"name": name,
2021-09-29 23:57:09 +00:00
});
}
2022-06-29 19:02:01 +00:00
/// 导出下载的图片到PKZ
Future<dynamic> exportComicDownloadToPkz(
List<String> comicIds,
String dir,
String name,
) {
return _flatInvoke("exportComicDownloadToPkz", {
"comicIds": comicIds,
"dir": dir,
"name": name,
});
}
2021-10-21 04:08:51 +00:00
/// 使用网络将下载传输到其他设备
2021-09-29 23:57:09 +00:00
Future<int> exportComicUsingSocket(String comicId) async {
return int.parse(await _flatInvoke("exportComicUsingSocket", comicId));
}
2021-10-21 04:08:51 +00:00
/// 传输窗口关闭时调用, 令socket关闭(如果传输没有结束)
2021-09-29 23:57:09 +00:00
Future<dynamic> exportComicUsingSocketExit() {
return _flatInvoke("exportComicUsingSocketExit", "");
}
2021-10-21 04:08:51 +00:00
/// 从zip导入漫画
2021-09-29 23:57:09 +00:00
Future<dynamic> importComicDownload(String zipPath) {
return _flatInvoke("importComicDownload", zipPath);
}
2022-07-01 05:39:08 +00:00
/// 从pki导入漫画
Future<dynamic> importComicDownloadPki(String zipPath) {
return _flatInvoke("importComicDownloadPki", zipPath);
}
2021-10-21 04:08:51 +00:00
/// 从网络接收漫画
2021-09-29 23:57:09 +00:00
Future<dynamic> importComicDownloadUsingSocket(String addr) {
return _flatInvoke("importComicDownloadUsingSocket", addr);
}
2021-10-21 04:08:51 +00:00
/// 获取本机的所有ip地址
2021-09-29 23:57:09 +00:00
Future<String> clientIpSet() async {
return await _flatInvoke("clientIpSet", "");
}
2021-10-21 04:08:51 +00:00
/// 获取一个游戏的下载地址
2021-09-29 23:57:09 +00:00
Future<List<String>> downloadGame(String url) async {
if (url.startsWith("https://game.eroge.xyz/hhh.php")) {
var data = await _flatInvoke("downloadGame", url);
2021-11-15 08:26:53 +00:00
return [
url,
...List.of(jsonDecode(data)).map((e) => e.toString()),
];
2021-09-29 23:57:09 +00:00
}
return [url];
}
2021-10-21 04:08:51 +00:00
/// 保存图片(ios)
2021-09-29 23:57:09 +00:00
Future<dynamic> iosSaveFileToImage(String path) async {
return _channel.invokeMethod("iosSaveFileToImage", {
"path": path,
});
}
2021-10-21 04:08:51 +00:00
/// 保存图片(android)
2021-09-29 23:57:09 +00:00
Future androidSaveFileToImage(String path) async {
return _channel.invokeMethod("androidSaveFileToImage", {
"path": path,
});
}
2021-10-21 04:08:51 +00:00
/// 保存图片(PC)
2021-09-29 23:57:09 +00:00
Future convertImageToJPEG100(String path, String dir) async {
return _flatInvoke("convertImageToJPEG100", {
"path": path,
"dir": dir,
});
}
2021-10-21 04:08:51 +00:00
/// 获取安卓的屏幕刷新率
2021-09-29 23:57:09 +00:00
Future<List<String>> loadAndroidModes() async {
return List.of(await _channel.invokeMethod("androidGetModes"))
.map((e) => "$e")
.toList();
}
2021-10-21 04:08:51 +00:00
/// 设置安卓的屏幕刷新率
2021-09-29 23:57:09 +00:00
Future setAndroidMode(String androidDisplayMode) {
return _channel
.invokeMethod("androidSetMode", {"mode": androidDisplayMode});
}
2021-10-21 04:08:51 +00:00
/// 获取安卓的版本
2021-09-29 23:57:09 +00:00
Future<int> androidGetVersion() async {
return await _channel.invokeMethod("androidGetVersion", {});
}
2021-10-18 09:31:05 +00:00
2021-10-21 04:08:51 +00:00
/// 数据文件保存位置
2021-10-18 09:31:05 +00:00
Future<String> dataLocal() async {
return await _channel.invokeMethod("dataLocal", {});
}
2021-10-21 04:08:51 +00:00
/// 获取安卓支持的文件保存路径
2021-10-18 09:31:05 +00:00
Future<List<String>> androidGetExtendDirs() async {
String? tmp = await _channel.invokeMethod("androidGetExtendDirs", {});
if (tmp != null && tmp.isNotEmpty) {
return tmp.split("|");
}
return [];
}
2021-10-21 04:08:51 +00:00
/// 安卓文件迁移
2021-10-18 09:31:05 +00:00
Future migrate(String path) async {
return _channel.invokeMethod("migrate", {"path": path});
}
2021-10-21 04:08:51 +00:00
2021-10-25 11:27:38 +00:00
/// 下载的同时导出-配置获取
Future loadDownloadAndExportPath() {
return _flatInvoke("loadDownloadAndExportPath", "");
}
/// 下载的同时导出-设置
Future saveDownloadAndExportPath(String folder) {
return _flatInvoke("saveDownloadAndExportPath", folder);
}
2021-10-29 03:38:36 +00:00
/// 切换安全策略 (安卓禁止截图, 录屏, 不显示在任务视图)
Future androidSecureFlag(bool flag) {
return _channel.invokeMethod("androidSecureFlag", {
"flag": flag,
});
}
2021-10-31 06:01:19 +00:00
/// 获取下载线程数量
Future<int> loadDownloadThreadCount() async {
var strValue = await _flatInvoke("loadDownloadThreadCount", {});
return int.parse(strValue);
}
/// 设置下载线程数
Future saveDownloadThreadCount(int value) {
return _flatInvoke("saveDownloadThreadCount", "$value");
}
2021-11-11 03:00:38 +00:00
/// HTTP-GET-STRING
2022-02-11 05:33:42 +00:00
Future<String> defaultHttpClientGet(String url) async {
return await _flatInvoke("defaultHttpClientGet", url);
2021-11-11 03:00:38 +00:00
}
2022-02-24 16:08:18 +00:00
/// 更新签名
Future updateSlogan(String input) async {
return await _flatInvoke("updateSlogan", input);
}
2022-02-25 05:50:43 +00:00
/// 更新签名
Future updateAvatar(String data) async {
return await _flatInvoke("updateAvatar", data);
}
2022-02-25 06:31:25 +00:00
/// 修改密码
Future updatePassword(String oldPassword, String newPassword) {
return _flatInvoke("updatePassword", {
"oldPassword": oldPassword,
"newPassword": newPassword,
});
}
2022-03-27 06:19:08 +00:00
Future<List<String>> loadViewedList(List<String> list) async {
return List.of(jsonDecode(await _flatInvoke("loadViewedList", list)))
.cast();
}
2022-04-15 16:53:37 +00:00
Future<List<Collection>> collections() async {
String rsp = await _flatInvoke("collections", "");
List list = json.decode(rsp);
return list.map((e) => Collection.fromJson(e)).toList();
}
2022-05-14 13:45:00 +00:00
Future<bool> verifyAuthentication() async {
return await _channel.invokeMethod("verifyAuthentication");
}
2022-06-29 19:02:01 +00:00
Future<PkzArchive> pkzInfo(String pkzPath) async {
return PkzArchive.fromJson(
jsonDecode(await _flatInvoke("pkzInfo", pkzPath)));
}
Future<Uint8List> loadPkzFile(String pkzPath, String path) async {
return base64Decode(await _flatInvoke("loadPkzFile", {
"pkzPath": pkzPath,
"path": path,
}));
}
Future<List<PkzComicViewLog>> pkzComicViewLogs(
String fileName,
String comicId,
) async {
return List.of(jsonDecode(await _flatInvoke("pkzComicViewLogs", fileName)))
.map((e) => PkzComicViewLog.fromJson(e))
.toList();
}
Future<PkzComicViewLog?> pkzComicViewLogByPkzNameAndId(
String fileName,
String comicId,
) async {
String data = await _flatInvoke("pkzComicViewLogByPkzNameAndId", {
"fileName": fileName,
"comicId": comicId,
});
if (data == "" || data == "nil" || data == "null") {
return null;
}
return PkzComicViewLog.fromJson(jsonDecode(data));
}
Future viewPkz(
String fileName,
String filePath,
) async {
return _flatInvoke("viewPkz", {
"fileName": fileName,
"filePath": filePath,
});
}
Future viewPkzComic(
String fileName,
String filePath,
String comicId,
String comicTitle,
) async {
return _flatInvoke("viewPkzComic", {
"fileName": fileName,
"filePath": filePath,
"comicId": comicId,
"comicTitle": comicTitle,
});
}
Future viewPkzEpAndPicture(
String fileName,
String filePath,
String comicId,
String comicTitle,
String epId,
String epTitle,
int pictureRank,
) async {
return _flatInvoke("viewPkzEpAndPicture", {
"fileName": fileName,
"filePath": filePath,
"comicId": comicId,
"comicTitle": comicTitle,
"epId": epId,
"epTitle": epTitle,
"pictureRank": pictureRank,
});
}
Future<List<Knight>> leaderboardOfKnight() async {
return List.of(jsonDecode(await _flatInvoke("leaderboardOfKnight", "")))
.map((e) => Knight.fromJson(e))
.toList();
}
2021-09-29 23:57:09 +00:00
}