Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
87a1166a
提交
87a1166a
authored
3月 15, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add
上级
875ca608
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
66 行增加
和
11 行删除
+66
-11
library.dart
lib/models/library.dart
+13
-1
item.dart
lib/pages/book_category/widgets/item.dart
+1
-0
controller.dart
lib/pages/book_detail/controller.dart
+22
-0
view.dart
lib/pages/book_detail/view.dart
+16
-8
routes.dart
lib/routes/routes.dart
+13
-2
http.dart
lib/services/http.dart
+1
-0
没有找到文件。
lib/models/library.dart
浏览文件 @
87a1166a
...
...
@@ -132,7 +132,8 @@ class ChapterModel {
this
.
sort
,
this
.
seen
,
this
.
children
,
this
.
selected
=
false
this
.
selected
=
false
,
this
.
currentRead
=
false
});
ChapterModel
.
fromJson
(
dynamic
json
)
{
...
...
@@ -150,6 +151,7 @@ class ChapterModel {
});
}
selected
=
false
;
currentRead
=
false
;
}
num
?
id
;
String
?
name
;
...
...
@@ -159,6 +161,7 @@ class ChapterModel {
num
?
sort
;
num
?
seen
;
late
bool
selected
;
late
bool
currentRead
;
List
<
ChapterModel
>?
children
;
ChapterModel
copyWith
({
num
?
id
,
String
?
name
,
...
...
@@ -589,3 +592,12 @@ class SearchAllModel {
}
class
PopBackModel
{
PopBackModel
({
required
this
.
chapterId
,
required
this
.
back
});
String
chapterId
;
bool
back
;
}
lib/pages/book_category/widgets/item.dart
浏览文件 @
87a1166a
...
...
@@ -114,6 +114,7 @@ class _BuildItemState extends State<BuildItem> {
onTap:
(){
if
(
chapterModel
.
children
!.
isEmpty
){
widget
.
onTap
(
chapterModel
);
chapterModel
.
currentRead
=
true
;
}
else
{
setState
(()
{
...
...
lib/pages/book_detail/controller.dart
浏览文件 @
87a1166a
...
...
@@ -14,6 +14,8 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
const
Tab
(
text:
'本书信息'
,),
];
num
currentChapterId
=
0
;
// 目录
List
<
ChapterModel
>
chapters
=
[];
// 图书
...
...
@@ -48,6 +50,25 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
}
}
/// 设置当前读的章节id
void
setCurrentReadChapterId
(){
for
(
ChapterModel
chapterModel
in
chapters
){
writeCurrentReadChapterIdToData
(
chapterModel
);
}
}
void
writeCurrentReadChapterIdToData
(
ChapterModel
chapterModel
){
for
(
ChapterModel
cModel
in
chapterModel
.
children
!){
cModel
.
currentRead
=
false
;
if
(
cModel
.
id
==
currentChapterId
){
cModel
.
currentRead
=
true
;
cModel
.
selected
=
true
;
chapterModel
.
selected
=
true
;
}
writeCurrentReadChapterIdToData
(
chapterModel
);
}
}
/// 写入特定数据
...
...
@@ -68,6 +89,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
writeData
(
chapters
,
result
);
chapters
=
result
;
setCurrentReadChapterId
();
update
();
}
...
...
lib/pages/book_detail/view.dart
浏览文件 @
87a1166a
...
...
@@ -113,9 +113,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
controller
.
getBookDetails
();
}
}
else
{
final
result
=
await
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
chapterModel
.
id
.
toString
(),
'chapter_name'
:
chapterModel
.
name
.
toString
(),
'note_id'
:
'0'
},
extra:
controller
.
bookDetails
);
if
(
result
==
true
){
final
PopBackModel
?
backModel
=
await
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
chapterModel
.
id
.
toString
(),
'chapter_name'
:
chapterModel
.
name
.
toString
(),
'note_id'
:
'0'
},
extra:
controller
.
bookDetails
);
if
(
backModel
!.
back
==
true
){
controller
.
getChapters
();
// controller.setCurrentReadChapterId(backModel!.chapterId);
controller
.
currentChapterId
=
int
.
parse
(
backModel
!.
chapterId
);
}
}
},
...
...
@@ -211,9 +213,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
if
(
controller
.
bookDetails
.
isFree
==
1
){
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
){
final
PopBackModel
?
backModel
=
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
(
backModel
!.
back
==
true
){
controller
.
getChapters
();
controller
.
currentChapterId
=
int
.
parse
(
backModel
!.
chapterId
);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
else
{
...
...
@@ -242,9 +246,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
else
{
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
){
final
PopBackModel
?
backModel
=
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
(
backModel
!.
back
==
true
){
controller
.
getChapters
();
controller
.
currentChapterId
=
int
.
parse
(
backModel
!.
chapterId
);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
}
...
...
@@ -253,9 +259,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
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
){
final
PopBackModel
?
backModel
=
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
(
backModel
!.
back
==
true
){
controller
.
getChapters
();
controller
.
currentChapterId
=
int
.
parse
(
backModel
!.
chapterId
);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
...
...
lib/routes/routes.dart
浏览文件 @
87a1166a
...
...
@@ -12,7 +12,7 @@ abstract class Routes {
static
const
web
=
'read_web'
;
static
const
answer
=
'answer'
;
static
const
readInfo
=
'read_info'
;
// 支付界面
static
const
bookPay
=
'book_pay'
;
...
...
@@ -703,7 +703,18 @@ abstract class Routes {
)
)
),
GoRoute
(
// 知识测评
GoRoute
(
// 画廊 扩展阅读
path:
'/
$readInfo
'
,
name:
readInfo
,
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
name:
state
.
uri
.
toString
(),
key:
state
.
pageKey
,
child:
ReadInfoPage
(
params:
state
.
uri
.
queryParameters
,
)
)
),
GoRoute
(
// 图片预览
path:
'/
$imageView
'
,
name:
imageView
,
pageBuilder:
(
context
,
state
)
=>
BottomToTopTransitionPage
(
...
...
lib/services/http.dart
浏览文件 @
87a1166a
...
...
@@ -245,6 +245,7 @@ class _RequestInterceptor extends Interceptor {
Console
.
log
(
'----------403---------access_token-------------------------
${UserStore.to.accessToken}
--------------------'
);
msg
=
'
$statusCode
- Unauthorized'
;
final
newToken
=
await
refreshToken
();
Console
.
log
(
'newToken----------
$newToken
'
);
if
(
newToken
!=
null
&&
newToken
.
isNotEmpty
)
{
final
RequestOptions
requestOptions
=
err
.
requestOptions
;
final
headers
=
requestOptions
.
headers
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论