提交 858a28d5 authored 作者: 岳维路's avatar 岳维路

合并分支 'test' 到 'sim'

Test 查看合并请求 kiwitap/zijing-app!8
......@@ -43,6 +43,10 @@ PODS:
- permission_handler_apple (9.1.1):
- Flutter
- ReachabilitySwift (5.0.0)
- screen_protector (1.2.1):
- Flutter
- ScreenProtectorKit (~> 1.3.1)
- ScreenProtectorKit (1.3.1)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
......@@ -72,6 +76,7 @@ DEPENDENCIES:
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- screen_protector (from `.symlinks/plugins/screen_protector/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- tobias (from `.symlinks/plugins/tobias/ios`)
......@@ -81,6 +86,7 @@ SPEC REPOS:
- flutter_sound_core
- OrderedSet
- ReachabilitySwift
- ScreenProtectorKit
- WechatOpenSDK-XCFramework
EXTERNAL SOURCES:
......@@ -114,6 +120,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
screen_protector:
:path: ".symlinks/plugins/screen_protector/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
......@@ -140,6 +148,8 @@ SPEC CHECKSUMS:
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
screen_protector: 6f92086bd2f2f4b54f54913289b9d1310610140b
ScreenProtectorKit: 83a6281b02c7a5902ee6eac4f5045f674e902ae4
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
tobias: 22f69183b14af82a2ac8ff698af084c352744e5f
......
......@@ -540,6 +540,7 @@ class DiscussModel {
this.personPic,
this.isMy,
this.commentsCheck,
this.privacyStatus,
this.status,
this.isPraise,
});
......@@ -565,6 +566,7 @@ class DiscussModel {
isMy = json['is_my'];
isPraise = json['is_praise'];
commentsCheck = json['comments_check'];
privacyStatus = json['privacy_status'];
status = json['status'];
if (json['comment_all'] != null) {
......@@ -589,6 +591,7 @@ class DiscussModel {
num? isMy;
num? isPraise;
num? commentsCheck;
num? privacyStatus;
num? status;
String? createTime;
String? replacePersonName;
......@@ -612,6 +615,7 @@ class DiscussModel {
num? isMy,
num? isPraise,
num? commentsCheck,
num? privacyStatus,
num? status,
String? createTime,
String? replacePersonName,
......@@ -636,6 +640,7 @@ class DiscussModel {
isPraise: isPraise ?? this.isPraise,
status:status ?? this.status,
commentsCheck: commentsCheck ?? this.commentsCheck,
privacyStatus: privacyStatus ?? this.privacyStatus,
createTime: createTime ?? this.createTime,
replacePersonName: replacePersonName ?? this.replacePersonName,
replacePersonPic: replacePersonPic ?? this.replacePersonPic,
......@@ -663,6 +668,7 @@ class DiscussModel {
map['is_my'] = isMy;
map['is_praise'] = isPraise;
map['comments_check'] = commentsCheck;
map['privacy_status'] = privacyStatus;
map['status'] = status;
map['create_time'] = createTime;
map['replace_person_name'] = replacePersonName;
......
......@@ -112,7 +112,17 @@ class _BuildItemState extends State<BuildItem> {
/// 章节名称容器
GestureDetector(
onTap: (){
widget.onTap(chapterModel);
if(chapterModel.children!.isEmpty){
widget.onTap(chapterModel);
}
else{
setState(() {
chapterModel.selected = !chapterModel.selected;
});
}
// setState(() {
// chapterModel.selected = !chapterModel.selected;
// });
// // 如果章下面没有节 点击才会跳转
// if (widget.model.children!.isEmpty){
// widget.onTap(widget.model);
......@@ -156,7 +166,7 @@ class _BuildItemState extends State<BuildItem> {
chapterModel.selected = !chapterModel.selected;
});
},
child: Container(
child: SizedBox(
width: 20.w,
height: 20.w,
// color: Colors.red,
......
......@@ -48,36 +48,26 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
}
}
/// 写入特定数据
void writeData(List<ChapterModel> listA, List<ChapterModel> listB){
for(int i = 0; i < listA.length;i++){
ChapterModel aModel = listA[i];
ChapterModel bModel = listB[i];
if(aModel.id == bModel.id){
// aModel.seen = bModel.seen;
bModel.selected = aModel.selected;
}
writeData(aModel.children!, bModel.children!);
}
}
/// 获取目录信息
void getChapters() async {
final result = await LibraryAPI.chapters(bookId: bookId);
writeData(chapters, result);
// final result = await LibraryAPI.chapters(bookId: bookId);
// for(int index = 0;index < chapters.length;index++){
// ChapterModel oModel = chapters[index];
// ChapterModel nModel = result[index];
// if()
// }
chapters = await LibraryAPI.chapters(bookId: bookId);
// chapters = [
// ChapterModel(name: '第一章',selected: false, children: [
// ChapterModel(name: '第一节',children: [
// ChapterModel(name: '第一小节',children: []),
// ]),
// ChapterModel(name: '第二节',children: [
// ChapterModel(name: '第二小节',children: []),
// ])
// ]),
// ChapterModel(name: '第二章',children: [
// ChapterModel(name: '第一节',children: [
// ChapterModel(name: '第1小节',children: []),
// ]),
// ChapterModel(name: '第一节',children: [
// ChapterModel(name: '第1小节',children: []),
// ])
// ]),
// ];
chapters = result;
update();
}
......@@ -85,12 +75,16 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
void getBookDetails() async {
bookDetails = await LibraryAPI.details(bookId:bookId);
// 将阅读最后章节写入到数据库
try {
final result = await SqlManager.updateReadHistoryByBookId(int.parse(bookId), bookDetails.chapterId!.toInt());
Console.log('Sql-------存入数据库读到的章节----------------book_id:$bookId-----chapterId:${bookDetails.chapterId!.toInt()}---------result:$result--');
}
catch(err){
Console.log('Sql--------------err------------------$err');
bool netStatus = await Tools.checkCurrentNetStatus();
// 有网络的时候才会 存储 其余不存储
if (netStatus){
try {
final result = await SqlManager.updateReadHistoryByBookId(int.parse(bookId), bookDetails.chapterId!.toInt());
Console.log('Sql-------存入数据库读到的章节----------------book_id:$bookId-----chapterId:${bookDetails.chapterId!.toInt()}---------result:$result--');
}
catch(err){
Console.log('Sql--------------err------------------$err');
}
}
update();
......@@ -108,14 +102,77 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
}
bool result = await CommonAPI.love(
bookId: bookId, love: isCollection.toString());
Console.log('================================$result');
if (result) {
getBookDetails();
}
}
// 获取当前的章节id
Future<String> getCurrentChapterId() async{
String chapterId = '';
bool netStatus = await Tools.checkCurrentNetStatus();
final exist = await _isExistFile(bookId);
if (!netStatus && exist){
chapterId = await SqlManager.queryReadHistoryByBookId(int.parse(bookId));
}
else{
chapterId = bookDetails.chapterId.toString();
}
return chapterId;
}
// 获取当前的章节名称
Future<String> getCurrentChapterName() async{
String chapterName = '';
bool netStatus = await Tools.checkCurrentNetStatus();
final exist = await _isExistFile(bookId);
if (!netStatus && exist){
String chapterId = await SqlManager.queryReadHistoryByBookId(int.parse(bookId));
chapterName = _getChapterName(chapterId);
}
else{
chapterName = bookDetails.chapterName.toString();
}
Console.log('getCurrentChapterName-------------------------------$chapterName-');
return chapterName;
}
// 判断是否存在离线文件
Future<bool> _isExistFile(String bookId) async {
bool existDownFile= false;
String directoryPath = await Tools.getDirectory();
Directory directory = Directory(directoryPath);
bool directoryExists = await directory.exists();
if (directoryExists) {
Console.log('存在名为 "$bookId" 的文件夹');
existDownFile = await Directory('${directory.path}/$bookId').exists();
}
else {
Console.log('不存在名为 "$bookId" 的文件夹');
existDownFile = false;
}
return existDownFile;
}
String _getChapterName(String chapterId){
for (ChapterModel model in chapters){
if ('${model.id}' == chapterId){
return model.name??'';
}
if (model.children !=null){
for (ChapterModel subModel in model.children!){
if ('${subModel.id}' == chapterId){
return subModel.name??'';
}
}
}
}
return '';
}
......
library book_detail;
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/theme.dart';
......
......@@ -143,11 +143,16 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<style>
*{ margin: 0; padding: 5px;}
html{ font-size: 10px;}
body p{ font-size: 1.5rem; line-height:2.4rem;color: #999}
img,video,pre,code{ max-width:100%}
pre{white-space: pre-wrap;word-wrap: break-word;word-break: break-all}
*{ margin: 0px; padding: 5px; font-size:16px}
html{ font-size: 10px;}
body{ padding:0px}
body p{ font-size: 1.5rem; line-height:2.4rem;color: #999}
img,video,pre,code{ max-width:100%}
pre{white-space: pre-wrap;word-wrap: break-word;word-break: break-all}
hr{background-color: var(--w-e-textarea-border-color); border: 0; display: block; height: 1px}
table, td {border: 1px solid #ccc;border-collapse: collapse;}
ol, ol li{margin:10px}
ul, ul li{margin:10px}
</style>
</head>
<body>
......@@ -204,7 +209,9 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
// 1免费 0 不免费
if(controller.bookDetails.isFree == 1){
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': controller.bookDetails.chapterId.toString(),'chapter_name':controller.bookDetails.chapterName.toString(),'note_id':'0'},extra: controller.bookDetails);
final String chapterId = await controller.getCurrentChapterId();
final String chapterName = await controller.getCurrentChapterName();
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (result == true){
controller.getChapters();
}
......@@ -233,14 +240,20 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
}
}
else{
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': controller.bookDetails.chapterId.toString(),'chapter_name':controller.bookDetails.chapterName.toString(),'note_id':'0'},extra: controller.bookDetails);
final String chapterId = await controller.getCurrentChapterId();
final String chapterName = await controller.getCurrentChapterName();
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (result == true){
controller.getChapters();
}
}
}
else{
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': controller.bookDetails.chapterId.toString(),'chapter_name':controller.bookDetails.chapterName.toString(),'note_id':'0'},extra: controller.bookDetails);
final String chapterId = await controller.getCurrentChapterId();
final String chapterName = await controller.getCurrentChapterName();
final result = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (result == true){
controller.getChapters();
}
......@@ -271,5 +284,4 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
}
}
......@@ -28,11 +28,16 @@ class HelpCenterContentController extends GetxController {
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<style>
*{ margin: 0; padding: 5px;}
html{ font-size: 10px;}
body p{ font-size: 1.5rem; line-height:2.4rem;color: #999}
img,video,pre,code{ max-width:100%}
pre{white-space: pre-wrap;word-wrap: break-word;word-break: break-all}
*{ margin: 0px; padding: 5px; font-size:16px}
html{ font-size: 10px;}
body{ padding:0px}
body p{ font-size: 1.5rem; line-height:2.4rem;color: #999}
img,video,pre,code{ max-width:100%}
pre{white-space: pre-wrap;word-wrap: break-word;word-break: break-all}
hr{background-color: var(--w-e-textarea-border-color); border: 0; display: block; height: 1px}
table, td {border: 1px solid #ccc;border-collapse: collapse;}
ol, ol li{margin:10px}
ul, ul li{margin:10px}
</style>
</head>
<body>
......
......@@ -68,9 +68,6 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
@override
void onInit() {
// 获取分类数据
_getTabs();
_controller = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 100),
......@@ -84,8 +81,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
void onReady() async {
// 获取标签数据
_getLabels();
// 获取分类数据
_getTabs();
// 获取广告数据
_getAds();
onRefresh();
// Map<String, dynamic> data = {
// 'types': 1,
......@@ -207,7 +206,6 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
filterCategories = categories.map((model) {
return FilterModel(id: model.categoryId.toString(), name: model.name??'',selected: model.selected);
}).toList();
print('===========$filterCategories');
update();
}
......
......@@ -85,13 +85,18 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
late SearchAllModel sModel = SearchAllModel(bookId: '0');
// 本地文件地址
String localHtml5Path = '';
///------------------------------------------ 页面 生命周期--------------------------------------------------------
@override
void onInit() {
void onInit() async {
initTts();
netStatus = await Tools.checkCurrentNetStatus();
discussTitleFocusNode.addListener(_onCommentFocusChanged);
await ScreenProtector.preventScreenshotOn();
super.onInit();
}
......@@ -103,18 +108,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
netStatus = await Tools.checkCurrentNetStatus();
final exist = await _isExistFile(bookId);
// chapterId = await SqlManager.queryReadHistoryByBookId(int.parse(bookId));
// Console.log('数据库中得到最后阅读的章节----------------------$chapterId----------');
if (!netStatus && exist){
// 1、从数据库中获取读到那个章节
chapterId = await SqlManager.queryReadHistoryByBookId(int.parse(bookId));
Console.log('Sql-----------数据库中得到最后阅读的章节----------------------$chapterId----------');
chapterName = getChapterName(chapterId);
// 2、通过 chapterId 获取 对应离线的 html路径
// 1、通过 chapterId 获取 对应离线的 html路径
String toReadHtmlPath = await getLocalReadHtml(chapterId);
// 3、开始读书
// 2、开始读书
read(toReadHtmlPath);
// 获取当前 文件名称
......@@ -127,7 +126,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
@override
void onClose() {
void onClose() async {
// 上报阅读结束时间
_addReadTime(type: 'close');
discussTitleFocusNode.removeListener(_onCommentFocusChanged);
......@@ -136,6 +135,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
contentInput.dispose();
flutterTts.stop();
searchInput.dispose();
await ScreenProtector.preventScreenshotOff();
super.onClose();
}
///------------------------------------------ 页面 生命周期--------------------------------------------------------
......@@ -304,13 +304,14 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
startRecording = true;
String filePath = await Tools.getDirectory();
String fileName = Tools.generateVoiceFileName();
Console.log('record---------------------$filePath/$fileName');
_mRecorder.startRecorder(
toFile: '$filePath/$fileName',
audioSource: AudioSource.microphone,
codec: Codec.aacMP4,
);
// _mRecorder?.setSubscriptionDuration(Duration(milliseconds: 100));
// _mRecorder?.onProgress?.listen((e)
// {
......@@ -325,10 +326,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void stopRecorder() async{
startRecording = false;
final path = await _mRecorder.stopRecorder();
Console.log('stopRecorder-----------path---------------------$path');
var duration = await audioPlayer.setFilePath(path!);
Console.log('-----duration---------------------$duration------');
AudioModel audioModel = AudioModel(path: path,duration: Tools.formatDuration(duration!),currentDuration: '0:00:00');
discussInputAudios.add(audioModel);
if(audioModel.duration !='0:00:00'){
discussInputAudios.add(audioModel);
}
update();
}
......@@ -450,6 +454,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
final status = await Tools.checkCurrentNetStatus();
// 有网情况下 先直传oss 获取到url
if (status){
CustomToast.loading();
// 循环上传图片获取地址
for(String path in discussInputImages){
final url = await upload(path: path);
......@@ -461,6 +466,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
final url = await upload(path: model.path);
audios.add(url);
}
CustomToast.dismiss();
}
// 没有网的情况下 存储到本地数据库
else{
......@@ -688,10 +694,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
File file = File(writeFilePath);
// 7、将HTML内容写入文件
await file.writeAsString(htmlStr);
localHtml5Path = writeFilePath;
String url = writeFilePath;
if(Platform.isIOS){
url = 'file://$writeFilePath';
}
webViewController.loadUrl(urlRequest: URLRequest(
// url: Uri.parse(writeFilePath),
url: WebUri.uri(Uri.parse(writeFilePath))
url: WebUri.uri(Uri.parse(url))
));
final result = await SqlManager.updateReadHistoryByBookId(int.parse(bookId), int.parse(chapterId));
Console.log('Sql----readread---存入数据库读到的章节----------------book_id:$bookId-----chapterId:$chapterId---------result:$result--');
queryLocalNote();
}
......
......@@ -26,6 +26,7 @@ import 'package:just_audio/just_audio.dart' as just_audio;
import 'package:path_provider/path_provider.dart';
import 'dart:async';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:screen_protector/screen_protector.dart';
import 'package:sqflite/sqflite.dart';
import '../../apis/index.dart';
......
......@@ -30,6 +30,7 @@ class _ReadPageState extends State<ReadPage> {
return WillPopScope(
onWillPop: () async {
context.pop(true);
CustomToast.dismiss();
return false;
},
child: GetBuilder<ReadController>(
......@@ -69,9 +70,9 @@ class _ReadPageState extends State<ReadPage> {
child: Stack(
children: [
InAppWebView(
initialUrlRequest: URLRequest(
initialUrlRequest:URLRequest(
// url: Uri.parse(kReadBook),
url: WebUri.uri(Uri.parse(kReadBook))
url: readController.localHtml5Path.isNotEmpty?WebUri.uri(Uri.parse(readController.localHtml5Path)): WebUri.uri(Uri.parse(kReadBook))
// url: Uri.parse("/storage/emulated/0/Android/data/com.zijin.book.flutter_book/files/174/7-325.html"),
),
initialSettings:InAppWebViewSettings(
......
......@@ -34,7 +34,7 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> {
widget.onTap!();
},
child: Container(
// color: Colors.red,
color: Colors.white,
padding: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: Image.asset('assets/images/close.png')
),
......
......@@ -35,7 +35,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
widget.onTap!();
},
child: Container(
// color: Colors.red,
color: Colors.white,
padding: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: Image.asset('assets/images/close.png')
),
......
......@@ -98,7 +98,18 @@ class _BuildItemState extends State<BuildItem> {
/// 章节名称容器
GestureDetector(
onTap: (){
widget.onTapChapter(chapterModel);
if(chapterModel.children!.isEmpty){
widget.onTapChapter(chapterModel);
}
else{
setState(() {
chapterModel.selected = !chapterModel.selected;
});
}
// // widget.onTapChapter(chapterModel);
// setState(() {
// chapterModel.selected = !chapterModel.selected;
// });
// // 如果章下面没有节 点击才会跳转
// if (widget.model.children!.isEmpty){
// widget.onTap(widget.model);
......
......@@ -33,7 +33,7 @@ class _ReadNotePageState extends State<ReadNotePage> {
widget.onTap!();
},
child: Container(
// color: Colors.red,
color: Colors.white,
padding: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w,bottom: 15.w),
child: Image.asset('assets/images/close.png')
),
......
......@@ -42,23 +42,25 @@ class BuildItem extends StatelessWidget {
height: 86.w,
url: model.img??'',
),
Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),),
],
),
Text('${model.commentNum.toString()}个讨论',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
Expanded(
child: Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),overflow: TextOverflow.ellipsis,maxLines: 2,),
],
),
Text('${model.commentNum.toString()}个讨论',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
),
),
)
],
......
......@@ -245,25 +245,23 @@ class _BuildDiscussState extends State<BuildDiscuss> {
String text = '';
// 是我的
if(discussModel.isMy == 1){
if(discussModel.commentsCheck == 1){
// 审核中
if(discussModel.content?.text?.privacyStatus ==0 ||discussModel.content?.text?.privacyStatus ==2 ||discussModel.status == 0){
text = '(审核中)';
}
// 审核未通过
else if(discussModel.content?.text?.privacyStatus ==-1 ||discussModel.status == 2){
text = '(审核未通过)';
}
}else{
// 审核中
if(discussModel.content?.text?.privacyStatus ==0 ||discussModel.content?.text?.privacyStatus ==2){
text = '(审核中)';
}
// 审核未通过
else if(discussModel.content?.text?.privacyStatus ==-1){
text = '(审核未通过)';
}
if(discussModel.privacyStatus ==-1){
text = '(审核未通过)';
}
else if(discussModel.privacyStatus ==0){
text = '(审核中)';
}
else if(discussModel.privacyStatus ==1){
if(discussModel.commentsCheck == 1){
if(discussModel.status == 0){
text = '(审核中)';
}
else if(discussModel.status == 2){
text = '(审核未通过)';
}
}
}
}
return text;
......@@ -273,25 +271,23 @@ class _BuildDiscussState extends State<BuildDiscuss> {
String text = '';
// 是我的
if(discussModel.isMy == 1){
if(discussModel.commentsCheck == 1){
// 审核中
if(mediaModel?.privacyStatus ==0 ||mediaModel?.privacyStatus ==2 ||discussModel.status == 0){
text = '(审核中)';
}
// 审核未通过
else if(mediaModel?.privacyStatus ==-1 ||discussModel.status == 2){
text = '(审核未通过)';
}
}else{
// 审核中
if(mediaModel?.privacyStatus ==0 ||mediaModel?.privacyStatus ==2){
text = '(审核中)';
}
// 审核未通过
else if(mediaModel?.privacyStatus ==-1){
text = '(审核未通过)';
}
if(discussModel.privacyStatus ==-1){
text = '(审核未通过)';
}
else if(discussModel.privacyStatus ==0){
text = '(审核中)';
}
else if(discussModel.privacyStatus ==1){
if(discussModel.commentsCheck == 1){
if(discussModel.status == 0){
text = '(审核中)';
}
else if(discussModel.status == 2){
text = '(审核未通过)';
}
}
}
}
return text;
......
......@@ -37,23 +37,25 @@ class BuildItem extends StatelessWidget {
height: 86.w,
url: model.img??'',
),
Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),),
],
),
Text('${model.commentNum.toString()}个讨论',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
Expanded(
child: Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),overflow: TextOverflow.ellipsis,maxLines: 2,),
],
),
Text('${model.commentNum.toString()}个讨论',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
),
),
)
],
......
......@@ -37,23 +37,25 @@ class BuildItem extends StatelessWidget {
height: 86.w,
url: model.img??'',
),
Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),),
],
),
Text('${model.notesNum.toString()}个笔记',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
Expanded(
child: Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),overflow: TextOverflow.ellipsis,maxLines: 2,),
],
),
Text('${model.notesNum.toString()}个笔记',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
),
),
)
],
......
......@@ -37,23 +37,25 @@ class BuildItem extends StatelessWidget {
height: 86.w,
url: model.img??'',
),
Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),),
],
),
Text('${model.notesNum.toString()}个笔记',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
Expanded(
child: Container(
height: 87.w,
margin: EdgeInsets.only(left: 13.w),
// color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.bookName??'',style: TextStyle(fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.authors??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c6),overflow: TextOverflow.ellipsis,maxLines: 2,),
],
),
Text('${model.notesNum.toString()}个笔记',style: TextStyle(fontSize: 11.w,height: 1.5,color: AppTheme.primary)),
],
),
),
)
],
......
......@@ -63,7 +63,7 @@ class BuildNote extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
_showText(model).isEmpty?const SizedBox():Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(_showText(model),style: TextStyle(
......
......@@ -343,10 +343,10 @@ class _CacheInterceptor extends Interceptor {
final status = await Tools.checkCurrentNetStatus();
if (cacheEnabled && !status) {
// 在发起请求之前,检查缓存是否存在有效数据
String cacheKey = options.data.isEmpty ? options.uri.toString() : '${options.uri.toString()}?${options.data}';
String cacheKey = '${options.uri.toString()}?${options.data}';
final cachedFile = await DefaultCacheManager().getFileFromCache(cacheKey);
Console.log('获取数据----------cacheKey-----------------------$cacheKey');
if (cachedFile != null && cachedFile.validTill.isAfter(DateTime.now())) {
Console.log('-获取数据cachedFile------------------------------$cachedFile-');
// 如果缓存有效,直接返回缓存数据
final cachedData = await cachedFile.file.readAsBytes();
final decodedData = utf8.decode(cachedData); // 将字节列表解码为字符串
......@@ -383,7 +383,7 @@ class _CacheInterceptor extends Interceptor {
cacheKey,
uint8List,
fileExtension: '.json', // 可以根据需求修改文件扩展名
maxAge: const Duration(hours: 1)
maxAge: const Duration(hours: 12)
);
} catch (e) {
Console.log('Error caching response: $e');
......
......@@ -53,8 +53,10 @@ class SqlManager {
static Future<Database?> getCurrentDatabase() async {
if (_database == null) {
Console.log('Sql-------------getCurrentDatabase---------------_database == null----');
await init();
}
Console.log('Sql-------------getCurrentDatabase---------------$_database');
return _database;
}
......@@ -146,18 +148,29 @@ class SqlManager {
}
// 根据 book_id 查询当前读到的 章节
static Future<String> queryReadHistoryByBookId(int bookId) async {
Database? db = await SqlManager.getCurrentDatabase();
List<Map<String, dynamic>>? results = await db?.query(
'read_history',
where: 'book_id = ?',
whereArgs: [bookId],
);
return results?.first['chapter_id'].toString() ?? '';
try {
Database? db = await SqlManager.getCurrentDatabase();
if (!db!.isOpen){
await init();
}
List<Map<String, dynamic>>? results = await db?.query(
'read_history',
where: 'book_id = ?',
whereArgs: [bookId],
);
return results?.first['chapter_id'].toString() ?? '';
}
catch(e){
Console.log('Error querying read history by book id: $e');
return '';
}
}
// 根据 book_id 写入当前读到的 章节
static Future<int> updateReadHistoryByBookId(int bookId ,int chapterId) async {
Database? db = await SqlManager.getCurrentDatabase();
final queryResult = await queryReadHistoryByBookId(bookId);
if (queryResult.isEmpty){
Console.log('Sql----------没有当前书籍的数据----------------------');
......@@ -171,14 +184,14 @@ class SqlManager {
}
else{
Console.log('Sql----------有当前书籍的数据----------------------');
final result = await db!.update(
final result = await db?.update(
'read_history',
{'chapter_id':chapterId},
where: 'book_id = ?',
whereArgs: [bookId],
);
Console.log('Sql----------更新数据结果:$result----------------------');
return result;
return result??0;
}
}
......
......@@ -38,7 +38,7 @@ abstract class Tools {
static Future<String> getDirectory() async {
// getTemporaryDirectory
final directory = await getExternalStorageDirectory();
final directory = await getTemporaryDirectory();
return directory!.path;
}
......
......@@ -857,10 +857,18 @@ packages:
dependency: transitive
description:
name: rxdart
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
sha256: "2ef8b4e91cb3b55d155e0e34eeae0ac7107974e451495c955ac04ddee8cc21fd"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.27.7"
version: "0.26.0"
screen_protector:
dependency: "direct main"
description:
name: screen_protector
sha256: "541bdcd341de1e38026b5b94cc2a74cd95299d2c51150735165c4b445fa0209a"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.2"
scrollable_positioned_list:
dependency: transitive
description:
......
......@@ -119,6 +119,9 @@ dependencies:
device_info_plus: ^9.1.2
# 安卓
android_id: ^0.3.6
# 防止截屏
# secure_application: ^3.8.0
screen_protector: ^1.4.2
dev_dependencies:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论