Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
cd4702cb
提交
cd4702cb
authored
2月 03, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
笔记逻辑
上级
ca470cd3
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
199 行增加
和
45 行删除
+199
-45
library.dart
lib/apis/library.dart
+33
-0
controller.dart
lib/pages/read_web/controller.dart
+139
-39
view.dart
lib/pages/read_web/view.dart
+0
-0
input_discuss.dart
lib/pages/read_web/widgets/input_discuss.dart
+22
-4
http.dart
lib/services/http.dart
+3
-0
book.dart
lib/widgets/book.dart
+2
-2
没有找到文件。
lib/apis/library.dart
浏览文件 @
cd4702cb
...
...
@@ -260,4 +260,36 @@ abstract class LibraryAPI {
return
false
;
}
/// 13、添加笔记、高亮、划线的内容
static
Future
<
bool
>
addNote
({
required
String
bookId
,
required
String
chapterId
,
String
types
=
'3'
,
required
String
content
,
required
String
isOpen
,
String
color
=
''
,
required
String
positioning
,
required
String
noteContent
,
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/book/Information/addNotes'
,
params:
{
'book_id'
:
bookId
,
'chapter_id'
:
chapterId
,
'types'
:
types
,
'content'
:
content
,
'is_open'
:
isOpen
,
'color'
:
content
,
'positioning'
:
positioning
,
'note_content'
:
noteContent
},
);
if
(
result
.
data
is
Map
&&
result
.
data
[
'is_success'
]
==
1
){
return
true
;
}
return
false
;
}
}
\ No newline at end of file
lib/pages/read_web/controller.dart
浏览文件 @
cd4702cb
...
...
@@ -17,43 +17,45 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
late
ToolModel
toolModel
=
tools
.
first
;
// 输入框窗口是否展示
bool
showChat
=
false
;
// 0 讨论 1 笔记
late
int
chatType
=
0
;
// 笔记是否公开
bool
isPublic
=
false
;
// 笔记位置信息
String
notePosition
=
''
;
// 话题焦点
final
FocusNode
discussTitleFocusNode
=
FocusNode
();
// 内容焦点
final
FocusNode
discussContentFocusNode
=
FocusNode
();
late
AnimationController
_controller
;
bool
_show
=
true
;
bool
get
show
=>
_show
;
// 讨论添加的图片数组
List
<
String
>
discussInputImages
=
[];
// 讨论话题标题
final
TextEditingController
titleInput
=
TextEditingController
();
// 讨论内容
final
TextEditingController
contentInput
=
TextEditingController
();
//
// 讨论添加的图片path数组
List
<
String
>
discussInputImages
=
[];
// 讨论添加的语音path数组
List
<
String
>
discussInputAudios
=
[];
// 笔记标题
String
noteTitle
=
''
;
bool
_show
=
true
;
bool
get
show
=>
_show
;
///------------------------------------------ 页面 生命周期--------------------------------------------------------
@override
void
onInit
()
{
// pageController = PageController(initialPage: currentPage);
discussTitleFocusNode
.
addListener
(
_onCommentFocusChanged
);
/// 默认不显示状态栏
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
/// 初始化
_controller
=
AnimationController
(
vsync:
this
,
duration:
const
Duration
(
milliseconds:
100
),
);
super
.
onInit
();
}
@override
void
onReady
()
{
// 上报开始阅读时间
print
(
'000000000000000000000--------------------------------
$bookId
'
);
_addReadTime
(
type:
'open'
);
_getChapters
();
super
.
onReady
();
...
...
@@ -63,7 +65,6 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void
onClose
()
{
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
_controller
.
dispose
();
discussTitleFocusNode
.
removeListener
(
_onCommentFocusChanged
);
discussTitleFocusNode
.
dispose
();
titleInput
.
dispose
();
...
...
@@ -74,37 +75,40 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void
setShow
(
bool
value
)
{
_show
=
!
value
;
if
(
_show
)
{
/// 显示状态栏
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
edgeToEdge
);
/// 开启动画
_controller
.
forward
();
}
else
{
/// 不显示状态栏
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
/// 收回动画
_controller
.
reverse
();
}
update
();
}
// 添加讨论图片
void
addDiscussInputImages
(
String
path
){
discussInputImages
.
add
(
path
);
print
(
'discussInputImages--------------------------------
$path
'
);
Console
.
log
(
'discussInputImages--------------------------------
$path
'
);
update
();
}
// 删除讨论图片
void
delDiscussInputImages
(
String
path
){
discussInputImages
.
remove
(
path
);
print
(
'delDiscussInputImages--------------------------------
$path
'
);
Console
.
log
(
'delDiscussInputImages--------------------------------
$path
'
);
update
();
}
// 清空讨论图片
void
clearDiscussInputImages
(){
discussInputImages
.
clear
();
print
(
'clearDiscussInputImages--------------------------------'
);
Console
.
log
(
'clearDiscussInputImages--------------------------------'
);
update
();
}
// 情况语音
void
clearDiscussAudios
(){
discussInputAudios
.
clear
();
Console
.
log
(
'clearDiscussAudios--------------------------------'
);
update
();
}
// 清空所有已经填写的数据
void
clearAllDiscussInput
(){
discussInputImages
.
clear
();
discussInputAudios
.
clear
();
titleInput
.
text
=
''
;
contentInput
.
text
=
''
;
Console
.
log
(
'clearAllDiscussInput--------------------------------'
);
update
();
}
...
...
@@ -117,6 +121,81 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
return
result
;
}
// 提交
Future
<
bool
>
submit
()
async
{
// 音频链接数组
List
<
String
>
audios
=
[];
// 图片链接数组
List
<
String
>
images
=
[];
// 循环上传图片获取地址
for
(
String
path
in
discussInputImages
){
final
url
=
await
upload
(
path:
path
);
images
.
add
(
url
);
}
// 循环上传音频获取地址
for
(
String
path
in
discussInputAudios
){
final
url
=
await
upload
(
path:
path
);
audios
.
add
(
url
);
}
Map
<
String
,
dynamic
>
contentMap
=
{
'text'
:
contentInput
.
text
,
'audio'
:
audios
,
'image'
:
images
};
// 话题
if
(
chatType
==
0
){
final
result
=
await
addDiscuss
();
return
result
;
}
// 笔记
else
if
(
chatType
==
1
){
final
result
=
addNote
();
return
result
;
}
return
false
;
}
// 添加笔记
Future
<
bool
>
addNote
()
async
{
// 音频链接数组
List
<
String
>
audios
=
[];
// 图片链接数组
List
<
String
>
images
=
[];
// 循环上传图片获取地址
for
(
String
path
in
discussInputImages
){
final
url
=
await
upload
(
path:
path
);
images
.
add
(
url
);
}
// 循环上传音频获取地址
for
(
String
path
in
discussInputAudios
){
final
url
=
await
upload
(
path:
path
);
audios
.
add
(
url
);
}
Map
<
String
,
dynamic
>
contentMap
=
{
'text'
:
contentInput
.
text
,
'audio'
:
audios
,
'image'
:
images
};
final
result
=
await
LibraryAPI
.
addNote
(
bookId:
bookId
,
chapterId:
chapterId
,
content:
noteTitle
,
isOpen:
isPublic
?
'1'
:
'0'
,
positioning:
notePosition
,
noteContent:
jsonEncode
(
contentMap
)
);
return
result
;
}
// 发表评论
// {String commentId ='0',String quoteContent ='',String title = ''}
Future
<
bool
>
addDiscuss
()
async
{
...
...
@@ -131,6 +210,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
images
.
add
(
url
);
}
// 循环上传音频获取地址
for
(
String
path
in
discussInputAudios
){
final
url
=
await
upload
(
path:
path
);
audios
.
add
(
url
);
}
Map
<
String
,
dynamic
>
contentMap
=
{
'text'
:
contentInput
.
text
,
'audio'
:
audios
,
...
...
@@ -177,7 +262,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
AnimationController
get
controller
=>
_controller
;
//
AnimationController get controller => _controller;
void
_onCommentFocusChanged
()
{
if
(
discussTitleFocusNode
.
hasFocus
||
discussContentFocusNode
.
hasFocus
)
{
...
...
@@ -187,10 +272,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
}
// 展示输入框
void
setShowChat
(
bool
value
)
{
showChat
=
value
;
update
();
}
// 显示输入框类型
void
setChatType
(
int
type
){
chatType
=
type
;
}
// 设置笔记是否公开
void
setIsPublic
(){
isPublic
=
!
isPublic
;
update
();
}
// void setNoteTitle(String title){
// noteTitle = title;
// // update();
// }
...
...
@@ -209,7 +309,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 当应用程序从后台切换到前台并变为活动状态时调用。这通常在用户从其他应用程序返回到你的应用程序时发生
void
onResumed
(){
print
(
'onResumed'
);
Console
.
log
(
'onResumed'
);
// open
// 上报开始阅读时间
_addReadTime
(
type:
'open'
);
...
...
@@ -217,20 +317,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 当应用程序失去焦点并进入非活动状态时调用。这可能是因为用户切换到其他应用程序或将应用程序最小化
void
onPaused
(){
// close
print
(
'onPaused'
);
Console
.
log
(
'onPaused'
);
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
}
// 当应用程序失去焦点但仍然可见时调用。通常,在用户切换到另一个应用程序或显示系统对话框时,应用程序可能会处于非活动状态,但仍然是可见的
void
onInactive
(){
print
(
'onInactive'
);
Console
.
log
(
'onInactive'
);
// close
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
}
// 当应用程序被挂起,可能是由于用户关闭应用程序或系统资源不足时调用。在这个状态下,应用程序的代码将不再运行,并且可能被系统终止
void
onDetached
(){
print
(
'onDetached'
);
Console
.
log
(
'onDetached'
);
// close
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
...
...
lib/pages/read_web/view.dart
浏览文件 @
cd4702cb
差异被折叠。
点击展开。
lib/pages/read_web/widgets/input_discuss.dart
浏览文件 @
cd4702cb
...
...
@@ -15,13 +15,13 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
color:
Colors
.
green
,
color:
Colors
.
white
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
child:
Column
(
children:
[
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
.
w
),
child:
Row
(
child:
widget
.
controller
.
chatType
==
0
?
Row
(
children:
[
Text
(
'话题'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.5
,
fontWeight:
Fonts
.
medium
),),
Gaps
.
hGaps5
,
...
...
@@ -41,11 +41,14 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
filled:
true
,
fillColor:
Colours
.
cF8
,
),
onSubmitted:
(
_
){
FocusScope
.
of
(
context
).
requestFocus
(
widget
.
controller
.
discussContentFocusNode
);
},
),
),
),
],
),
)
:
Text
(
'"
${widget.controller.noteTitle}
"'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.4
,
color:
Colours
.
c9
),)
,
),
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
4
.
w
),
...
...
@@ -59,6 +62,7 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
TextField
(
focusNode:
widget
.
controller
.
discussContentFocusNode
,
maxLines:
null
,
autofocus:
widget
.
controller
.
chatType
==
0
?
false
:
true
,
controller:
widget
.
controller
.
contentInput
,
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
...
...
@@ -174,11 +178,25 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
},
child:
Image
.
asset
(
'assets/images/read_add_audio.png'
)
),
widget
.
controller
.
chatType
==
0
?
const
SizedBox
():
GestureDetector
(
onTap:
(){
widget
.
controller
.
setIsPublic
();
},
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Gaps
.
hGaps10
,
Image
.
asset
(
widget
.
controller
.
isPublic
?
'assets/images/pay_check.png'
:
'assets/images/pay_uncheck.png'
),
SizedBox
(
width:
3
.
w
,),
Text
(
'公开'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.3
,
color:
Colours
.
c9
),)
],
),
)
],
),
GestureDetector
(
onTap:
(){
widget
.
controller
.
addDiscuss
();
widget
.
controller
.
submit
();
},
child:
Container
(
decoration:
BoxDecoration
(
...
...
lib/services/http.dart
浏览文件 @
cd4702cb
...
...
@@ -206,6 +206,7 @@ class _RequestInterceptor extends Interceptor {
var
msg
=
'服务器错误'
;
switch
(
statusCode
)
{
case
403
:
print
(
'-------------------access_token-------------------------
${UserStore.to.accessToken}
--------------------'
);
msg
=
'
$statusCode
- Unauthorized'
;
final
newToken
=
await
refreshToken
();
if
(
newToken
!=
null
)
{
...
...
@@ -233,6 +234,8 @@ class _RequestInterceptor extends Interceptor {
}
else
{
UserStore
.
to
.
logout
();
CustomToast
.
fail
(
'登录已失效,请重新登录'
);
print
(
'-------------------access_token-------------------------
${UserStore.to.accessToken}
--------------------'
);
}
break
;
case
404
:
...
...
lib/widgets/book.dart
浏览文件 @
cd4702cb
...
...
@@ -19,7 +19,7 @@ class CustomCard extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
return
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
cyan
,
color:
Colors
.
white
,
borderRadius:
borderRadius
??
BorderRadius
.
circular
(
3
),
boxShadow:
boxShadow
??
[
BoxShadow
(
...
...
@@ -33,7 +33,7 @@ class CustomCard extends StatelessWidget {
height:
height
,
width:
width
,
child:
Container
(
padding:
const
EdgeInsets
.
all
(
1
),
padding:
const
EdgeInsets
.
all
(
2
),
child:
CustomImage
.
network
(
url:
url
,
placeholder:
Image
.
asset
(
'assets/images/book_placeholder.png'
),),
),
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论