提交 dc771715 authored 作者: yueweilu's avatar yueweilu

add

上级 d25f0f4d
...@@ -52,8 +52,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -52,8 +52,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 录音开始 // 录音开始
bool startRecording = false; bool startRecording = false;
// 是否存在离线文件 // 是否存在离线文件
bool isExistFile = false; bool existDownFile= false;
// 网络状态
bool netStatus = false;
///------------------------------------------ 页面 生命周期-------------------------------------------------------- ///------------------------------------------ 页面 生命周期--------------------------------------------------------
@override @override
...@@ -69,20 +71,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -69,20 +71,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 上报开始阅读时间 // 上报开始阅读时间
_addReadTime(type: 'open'); _addReadTime(type: 'open');
_getChapters(); _getChapters();
final netStatus = await Tools.checkCurrentNetStatus(); netStatus = await Tools.checkCurrentNetStatus();
// 判断是否有离线文件 如果有使用离线阅读 // // 判断是否有离线文件 如果有使用离线阅读
final exist = await _isExistFile(bookId); // final exist = await _isExistFile(bookId);
// 没有网并且有离线文件 离线阅读 // // 没有网并且有离线文件 离线阅读
if (netStatus && exist){ // String path = await _getDirectory();
// webViewController.loadUrl(urlRequest: Uri.parse(urlRequest)) // String finalPath = '$path/174/0-318.html';
} // final content = await readHtmlFileContent(finalPath);
// Console.log('原始内容-----------------$content');
String path = await _getDirectory(); // String htmlStr = EncryptUtil.aesDecrypt(content!);
String finalPath = '$path/175/333.html'; // Console.log('解密-----------------$htmlStr');
final content = await readHtmlFileContent(finalPath); // if (netStatus && exist){
// EncryptUtil.aesDecrypt(content); // Console.log('-------------使用本地文件-------------------');
Console.log('原始内容-----------------$content'); // webViewController.loadData(data: htmlStr??'');
Console.log('解密-----------------${EncryptUtil.aesDecrypt(content!)}'); // }
super.onReady(); super.onReady();
...@@ -112,6 +114,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -112,6 +114,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
update(); update();
} }
// 读取那个章节
void readLocalHtml(String chapterId) async {
// 判断是否有离线文件 如果有使用离线阅读
final exist = await _isExistFile(bookId);
if (netStatus && exist){
// 没有网并且有离线文件 离线阅读
String path = await _getDirectory();
String finalPath = '$path/$bookId/0-318.html';
final content = await readHtmlFileContent(finalPath);
Console.log('原始内容-----------------$content');
String htmlStr = EncryptUtil.aesDecrypt(content!);
Console.log('解密-----------------$htmlStr');
Console.log('-------------使用本地文件-------------------');
webViewController.loadData(data: htmlStr??'');
}
}
// 初始化录音组件 // 初始化录音组件
Future<void> openTheRecorder() async { Future<void> openTheRecorder() async {
// 获取权限 // 获取权限
...@@ -460,12 +481,15 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -460,12 +481,15 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
bool directoryExists = await directory.exists(); bool directoryExists = await directory.exists();
if (directoryExists) { if (directoryExists) {
print('存在名为 "$bookId" 的文件夹'); print('存在名为 "$bookId" 的文件夹');
return await Directory('${directory.path}/$bookId').exists(); existDownFile = await Directory('${directory.path}/$bookId').exists();
} }
isExistFile = directoryExists; else {
print('不存在名为 "$bookId" 的文件夹'); print('不存在名为 "$bookId" 的文件夹');
return false; existDownFile = false;
}
update();
return existDownFile;
} }
......
...@@ -42,7 +42,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -42,7 +42,7 @@ class _ReadPageState extends State<ReadPage> {
readController.getBookDown(); readController.getBookDown();
}, },
child: Text( child: Text(
readController.isExistFile?'':'离线阅读', readController.existDownFile == true?'':'离线阅读',
style: TextStyle( style: TextStyle(
fontSize: 14.w, color: Colours.c3), fontSize: 14.w, color: Colours.c3),
)) ))
...@@ -301,6 +301,7 @@ class _ReadPageState extends State<ReadPage> { ...@@ -301,6 +301,7 @@ class _ReadPageState extends State<ReadPage> {
return const SizedBox(); return const SizedBox();
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论