Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
858a28d5
提交
858a28d5
authored
3月 12, 2024
作者:
岳维路
浏览文件
操作
浏览文件
下载
差异文件
合并分支 'test' 到 'sim'
Test 查看合并请求 kiwitap/zijing-app!8
上级
5fb6909d
685056fd
显示空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
258 行增加
和
101 行删除
+258
-101
Podfile.lock
ios/Podfile.lock
+10
-0
mine.dart
lib/models/mine.dart
+6
-0
item.dart
lib/pages/book_category/widgets/item.dart
+11
-1
controller.dart
lib/pages/book_detail/controller.dart
+85
-28
index.dart
lib/pages/book_detail/index.dart
+2
-0
view.dart
lib/pages/book_detail/view.dart
+17
-5
controller.dart
lib/pages/help_cneter_content/controller.dart
+6
-1
controller.dart
lib/pages/library/controller.dart
+3
-5
controller.dart
lib/pages/read_web/controller.dart
+29
-13
index.dart
lib/pages/read_web/index.dart
+1
-0
view.dart
lib/pages/read_web/view.dart
+3
-2
category.dart
lib/pages/read_web/widgets/category.dart
+1
-1
discuss.dart
lib/pages/read_web/widgets/discuss.dart
+1
-1
item.dart
lib/pages/read_web/widgets/item.dart
+11
-0
note.dart
lib/pages/read_web/widgets/note.dart
+1
-1
item.dart
lib/pages/user_discuss/widgets/item.dart
+4
-2
discuss.dart
lib/pages/user_discuss_des/widgets/discuss.dart
+22
-26
item.dart
lib/pages/user_discuss_des/widgets/item.dart
+4
-2
item.dart
lib/pages/user_notes/widgets/item.dart
+4
-2
item.dart
lib/pages/user_notes_des/widgets/item.dart
+4
-2
note.dart
lib/pages/user_notes_des/widgets/note.dart
+1
-1
http.dart
lib/services/http.dart
+3
-3
sql.dart
lib/utils/sql.dart
+15
-2
tools.dart
lib/utils/tools.dart
+1
-1
pubspec.lock
pubspec.lock
+10
-2
pubspec.yaml
pubspec.yaml
+3
-0
没有找到文件。
ios/Podfile.lock
浏览文件 @
858a28d5
...
...
@@ -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
...
...
lib/models/mine.dart
浏览文件 @
858a28d5
...
...
@@ -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
;
...
...
lib/pages/book_category/widgets/item.dart
浏览文件 @
858a28d5
...
...
@@ -112,7 +112,17 @@ class _BuildItemState extends State<BuildItem> {
/// 章节名称容器
GestureDetector
(
onTap:
(){
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,
...
...
lib/pages/book_detail/controller.dart
浏览文件 @
858a28d5
...
...
@@ -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,6 +75,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
void
getBookDetails
()
async
{
bookDetails
=
await
LibraryAPI
.
details
(
bookId:
bookId
);
// 将阅读最后章节写入到数据库
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
--'
);
...
...
@@ -92,6 +85,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
catch
(
err
){
Console
.
log
(
'Sql--------------err------------------
$err
'
);
}
}
update
();
}
...
...
@@ -108,13 +102,76 @@ 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
''
;
}
...
...
lib/pages/book_detail/index.dart
浏览文件 @
858a28d5
library
book_detail
;
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/apis/index.dart'
;
import
'package:flutter_book/theme.dart'
;
...
...
lib/pages/book_detail/view.dart
浏览文件 @
858a28d5
...
...
@@ -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;
}
*{ 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
}
}
lib/pages/help_cneter_content/controller.dart
浏览文件 @
858a28d5
...
...
@@ -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;
}
*{ 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>
...
...
lib/pages/library/controller.dart
浏览文件 @
858a28d5
...
...
@@ -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
();
}
...
...
lib/pages/read_web/controller.dart
浏览文件 @
858a28d5
...
...
@@ -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'
);
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
();
}
...
...
lib/pages/read_web/index.dart
浏览文件 @
858a28d5
...
...
@@ -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'
;
...
...
lib/pages/read_web/view.dart
浏览文件 @
858a28d5
...
...
@@ -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
(
...
...
lib/pages/read_web/widgets/category.dart
浏览文件 @
858a28d5
...
...
@@ -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'
)
),
...
...
lib/pages/read_web/widgets/discuss.dart
浏览文件 @
858a28d5
...
...
@@ -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'
)
),
...
...
lib/pages/read_web/widgets/item.dart
浏览文件 @
858a28d5
...
...
@@ -98,7 +98,18 @@ class _BuildItemState extends State<BuildItem> {
/// 章节名称容器
GestureDetector
(
onTap:
(){
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);
...
...
lib/pages/read_web/widgets/note.dart
浏览文件 @
858a28d5
...
...
@@ -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'
)
),
...
...
lib/pages/user_discuss/widgets/item.dart
浏览文件 @
858a28d5
...
...
@@ -42,7 +42,8 @@ class BuildItem extends StatelessWidget {
height:
86
.
w
,
url:
model
.
img
??
''
,
),
Container
(
Expanded
(
child:
Container
(
height:
87
.
w
,
margin:
EdgeInsets
.
only
(
left:
13
.
w
),
// color: Colors.green,
...
...
@@ -54,12 +55,13 @@ class BuildItem extends StatelessWidget {
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
.
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
)),
],
),
),
)
],
),
...
...
lib/pages/user_discuss_des/widgets/discuss.dart
浏览文件 @
858a28d5
...
...
@@ -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
){
if
(
discussModel
.
privacyStatus
==-
1
){
text
=
'(审核未通过)'
;
}
}
else
{
// 审核中
if
(
discussModel
.
content
?.
text
?.
privacyStatus
==
0
||
discussModel
.
content
?.
text
?.
privacyStatus
==
2
){
else
if
(
discussModel
.
privacyStatus
==
0
){
text
=
'(审核中)'
;
}
// 审核未通过
else
if
(
discussModel
.
content
?.
text
?.
privacyStatus
==-
1
){
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
){
if
(
discussModel
.
privacyStatus
==-
1
){
text
=
'(审核未通过)'
;
}
}
else
{
// 审核中
if
(
mediaModel
?.
privacyStatus
==
0
||
mediaModel
?.
privacyStatus
==
2
){
else
if
(
discussModel
.
privacyStatus
==
0
){
text
=
'(审核中)'
;
}
// 审核未通过
else
if
(
mediaModel
?.
privacyStatus
==-
1
){
else
if
(
discussModel
.
privacyStatus
==
1
){
if
(
discussModel
.
commentsCheck
==
1
){
if
(
discussModel
.
status
==
0
){
text
=
'(审核中)'
;
}
else
if
(
discussModel
.
status
==
2
){
text
=
'(审核未通过)'
;
}
}
}
}
return
text
;
...
...
lib/pages/user_discuss_des/widgets/item.dart
浏览文件 @
858a28d5
...
...
@@ -37,7 +37,8 @@ class BuildItem extends StatelessWidget {
height:
86
.
w
,
url:
model
.
img
??
''
,
),
Container
(
Expanded
(
child:
Container
(
height:
87
.
w
,
margin:
EdgeInsets
.
only
(
left:
13
.
w
),
// color: Colors.green,
...
...
@@ -49,12 +50,13 @@ class BuildItem extends StatelessWidget {
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
.
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
)),
],
),
),
)
],
),
...
...
lib/pages/user_notes/widgets/item.dart
浏览文件 @
858a28d5
...
...
@@ -37,7 +37,8 @@ class BuildItem extends StatelessWidget {
height:
86
.
w
,
url:
model
.
img
??
''
,
),
Container
(
Expanded
(
child:
Container
(
height:
87
.
w
,
margin:
EdgeInsets
.
only
(
left:
13
.
w
),
// color: Colors.green,
...
...
@@ -49,12 +50,13 @@ class BuildItem extends StatelessWidget {
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
.
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
)),
],
),
),
)
],
),
...
...
lib/pages/user_notes_des/widgets/item.dart
浏览文件 @
858a28d5
...
...
@@ -37,7 +37,8 @@ class BuildItem extends StatelessWidget {
height:
86
.
w
,
url:
model
.
img
??
''
,
),
Container
(
Expanded
(
child:
Container
(
height:
87
.
w
,
margin:
EdgeInsets
.
only
(
left:
13
.
w
),
// color: Colors.green,
...
...
@@ -49,12 +50,13 @@ class BuildItem extends StatelessWidget {
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
.
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
)),
],
),
),
)
],
),
...
...
lib/pages/user_notes_des/widgets/note.dart
浏览文件 @
858a28d5
...
...
@@ -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
(
...
...
lib/services/http.dart
浏览文件 @
858a28d5
...
...
@@ -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:
1
2
)
);
}
catch
(
e
)
{
Console
.
log
(
'Error caching response:
$e
'
);
...
...
lib/utils/sql.dart
浏览文件 @
858a28d5
...
...
@@ -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,7 +148,11 @@ class SqlManager {
}
// 根据 book_id 查询当前读到的 章节
static
Future
<
String
>
queryReadHistoryByBookId
(
int
bookId
)
async
{
try
{
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
if
(!
db
!.
isOpen
){
await
init
();
}
List
<
Map
<
String
,
dynamic
>>?
results
=
await
db
?.
query
(
'read_history'
,
where:
'book_id = ?'
,
...
...
@@ -154,10 +160,17 @@ class SqlManager {
);
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
;
}
}
...
...
lib/utils/tools.dart
浏览文件 @
858a28d5
...
...
@@ -38,7 +38,7 @@ abstract class Tools {
static
Future
<
String
>
getDirectory
()
async
{
// getTemporaryDirectory
final
directory
=
await
get
ExternalStorage
Directory
();
final
directory
=
await
get
Temporary
Directory
();
return
directory
!.
path
;
}
...
...
pubspec.lock
浏览文件 @
858a28d5
...
...
@@ -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:
...
...
pubspec.yaml
浏览文件 @
858a28d5
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论