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

add

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