Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
9855a239
提交
9855a239
authored
2月 03, 2024
作者:
maodou
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/test' into test
上级
3d1c112c
b51bb84c
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
326 行增加
和
253 行删除
+326
-253
library.dart
lib/apis/library.dart
+45
-3
controller.dart
lib/pages/read_web/controller.dart
+159
-39
index.dart
lib/pages/read_web/index.dart
+1
-0
view.dart
lib/pages/read_web/view.dart
+70
-201
input_discuss.dart
lib/pages/read_web/widgets/input_discuss.dart
+22
-4
http.dart
lib/services/http.dart
+27
-4
book.dart
lib/widgets/book.dart
+2
-2
没有找到文件。
lib/apis/library.dart
浏览文件 @
9855a239
...
@@ -229,8 +229,8 @@ abstract class LibraryAPI {
...
@@ -229,8 +229,8 @@ abstract class LibraryAPI {
return
false
;
return
false
;
}
}
/// 11、
离线下载
/// 11、
获取离线书籍下载地址 和 秘钥串
static
Future
<
BookDownloadModel
>
bookDownload
({
static
Future
<
BookDownloadModel
>
getbookDownloadParam
({
required
String
bookId
,
required
String
bookId
,
})
async
{
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
final
result
=
await
HttpService
.
to
.
post
(
...
@@ -243,7 +243,16 @@ abstract class LibraryAPI {
...
@@ -243,7 +243,16 @@ abstract class LibraryAPI {
return
BookDownloadModel
.
fromJson
(
result
.
data
);
return
BookDownloadModel
.
fromJson
(
result
.
data
);
}
}
/// 12、离线重连 上传笔记、高亮、划线
/// 12、根据书籍地址下载书籍
static
Future
<
void
>
downBookByUrl
({
required
String
url
,
required
String
savePath
,
ProgressCallback
?
onReceiveProgress
,
})
async
{
await
HttpService
.
to
.
download
(
url
,
savePath:
savePath
,
onReceiveProgress:
onReceiveProgress
);
}
/// 13、离线重连 上传笔记、高亮、划线
static
Future
<
bool
>
uploadContent
({
static
Future
<
bool
>
uploadContent
({
required
String
bookId
,
required
String
bookId
,
required
String
readTypes
required
String
readTypes
...
@@ -260,4 +269,36 @@ abstract class LibraryAPI {
...
@@ -260,4 +269,36 @@ abstract class LibraryAPI {
return
false
;
return
false
;
}
}
/// 14、添加笔记、高亮、划线的内容
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
浏览文件 @
9855a239
...
@@ -17,43 +17,45 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -17,43 +17,45 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
late
ToolModel
toolModel
=
tools
.
first
;
late
ToolModel
toolModel
=
tools
.
first
;
// 输入框窗口是否展示
bool
showChat
=
false
;
bool
showChat
=
false
;
// 0 讨论 1 笔记
late
int
chatType
=
0
;
// 笔记是否公开
bool
isPublic
=
false
;
// 笔记位置信息
String
notePosition
=
''
;
// 话题焦点
final
FocusNode
discussTitleFocusNode
=
FocusNode
();
final
FocusNode
discussTitleFocusNode
=
FocusNode
();
// 内容焦点
final
FocusNode
discussContentFocusNode
=
FocusNode
();
final
FocusNode
discussContentFocusNode
=
FocusNode
();
late
AnimationController
_controller
;
bool
_show
=
true
;
bool
get
show
=>
_show
;
// 讨论添加的图片数组
List
<
String
>
discussInputImages
=
[];
// 讨论话题标题
// 讨论话题标题
final
TextEditingController
titleInput
=
TextEditingController
();
final
TextEditingController
titleInput
=
TextEditingController
();
// 讨论内容
// 讨论内容
final
TextEditingController
contentInput
=
TextEditingController
();
final
TextEditingController
contentInput
=
TextEditingController
();
//
//
// 讨论添加的图片path数组
List
<
String
>
discussInputImages
=
[];
// 讨论添加的语音path数组
List
<
String
>
discussInputAudios
=
[];
// 笔记标题
String
noteTitle
=
''
;
bool
_show
=
true
;
bool
get
show
=>
_show
;
///------------------------------------------ 页面 生命周期--------------------------------------------------------
///------------------------------------------ 页面 生命周期--------------------------------------------------------
@override
@override
void
onInit
()
{
void
onInit
()
{
// pageController = PageController(initialPage: currentPage);
discussTitleFocusNode
.
addListener
(
_onCommentFocusChanged
);
discussTitleFocusNode
.
addListener
(
_onCommentFocusChanged
);
/// 默认不显示状态栏
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
/// 初始化
_controller
=
AnimationController
(
vsync:
this
,
duration:
const
Duration
(
milliseconds:
100
),
);
super
.
onInit
();
super
.
onInit
();
}
}
@override
@override
void
onReady
()
{
void
onReady
()
{
// 上报开始阅读时间
// 上报开始阅读时间
print
(
'000000000000000000000--------------------------------
$bookId
'
);
_addReadTime
(
type:
'open'
);
_addReadTime
(
type:
'open'
);
_getChapters
();
_getChapters
();
super
.
onReady
();
super
.
onReady
();
...
@@ -63,7 +65,6 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -63,7 +65,6 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void
onClose
()
{
void
onClose
()
{
// 上报阅读结束时间
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
_addReadTime
(
type:
'close'
);
_controller
.
dispose
();
discussTitleFocusNode
.
removeListener
(
_onCommentFocusChanged
);
discussTitleFocusNode
.
removeListener
(
_onCommentFocusChanged
);
discussTitleFocusNode
.
dispose
();
discussTitleFocusNode
.
dispose
();
titleInput
.
dispose
();
titleInput
.
dispose
();
...
@@ -74,37 +75,40 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -74,37 +75,40 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void
setShow
(
bool
value
)
{
void
setShow
(
bool
value
)
{
_show
=
!
value
;
_show
=
!
value
;
if
(
_show
)
{
/// 显示状态栏
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
edgeToEdge
);
/// 开启动画
_controller
.
forward
();
}
else
{
/// 不显示状态栏
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
/// 收回动画
_controller
.
reverse
();
}
update
();
update
();
}
}
// 添加讨论图片
// 添加讨论图片
void
addDiscussInputImages
(
String
path
){
void
addDiscussInputImages
(
String
path
){
discussInputImages
.
add
(
path
);
discussInputImages
.
add
(
path
);
print
(
'discussInputImages--------------------------------
$path
'
);
Console
.
log
(
'discussInputImages--------------------------------
$path
'
);
update
();
update
();
}
}
// 删除讨论图片
// 删除讨论图片
void
delDiscussInputImages
(
String
path
){
void
delDiscussInputImages
(
String
path
){
discussInputImages
.
remove
(
path
);
discussInputImages
.
remove
(
path
);
print
(
'delDiscussInputImages--------------------------------
$path
'
);
Console
.
log
(
'delDiscussInputImages--------------------------------
$path
'
);
update
();
update
();
}
}
// 清空讨论图片
// 清空讨论图片
void
clearDiscussInputImages
(){
void
clearDiscussInputImages
(){
discussInputImages
.
clear
();
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
();
update
();
}
}
...
@@ -117,6 +121,81 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -117,6 +121,81 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
return
result
;
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 = ''}
// {String commentId ='0',String quoteContent ='',String title = ''}
Future
<
bool
>
addDiscuss
()
async
{
Future
<
bool
>
addDiscuss
()
async
{
...
@@ -131,6 +210,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -131,6 +210,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
images
.
add
(
url
);
images
.
add
(
url
);
}
}
// 循环上传音频获取地址
for
(
String
path
in
discussInputAudios
){
final
url
=
await
upload
(
path:
path
);
audios
.
add
(
url
);
}
Map
<
String
,
dynamic
>
contentMap
=
{
Map
<
String
,
dynamic
>
contentMap
=
{
'text'
:
contentInput
.
text
,
'text'
:
contentInput
.
text
,
'audio'
:
audios
,
'audio'
:
audios
,
...
@@ -177,7 +262,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -177,7 +262,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
}
AnimationController
get
controller
=>
_controller
;
//
AnimationController get controller => _controller;
void
_onCommentFocusChanged
()
{
void
_onCommentFocusChanged
()
{
if
(
discussTitleFocusNode
.
hasFocus
||
discussContentFocusNode
.
hasFocus
)
{
if
(
discussTitleFocusNode
.
hasFocus
||
discussContentFocusNode
.
hasFocus
)
{
...
@@ -187,10 +272,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -187,10 +272,25 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
}
}
}
// 展示输入框
void
setShowChat
(
bool
value
)
{
void
setShowChat
(
bool
value
)
{
showChat
=
value
;
showChat
=
value
;
update
();
update
();
}
}
// 显示输入框类型
void
setChatType
(
int
type
){
chatType
=
type
;
}
// 设置笔记是否公开
void
setIsPublic
(){
isPublic
=
!
isPublic
;
update
();
}
// void setNoteTitle(String title){
// noteTitle = title;
// // update();
// }
...
@@ -204,12 +304,32 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -204,12 +304,32 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void
_addReadTime
({
required
type
})
async
{
void
_addReadTime
({
required
type
})
async
{
final
result
=
await
LibraryAPI
.
addReadTime
(
bookId:
bookId
,
readTypes:
type
);
final
result
=
await
LibraryAPI
.
addReadTime
(
bookId:
bookId
,
readTypes:
type
);
}
}
/// 获取离线文件路径
void
getBookDown
()
async
{
final
result
=
await
LibraryAPI
.
getbookDownloadParam
(
bookId:
bookId
);
Console
.
log
(
'----------_getBookDown------------------
${result.download}
'
);
final
String
savePath
=
await
_getDocumentsDirectory
();
LibraryAPI
.
downBookByUrl
(
url:
result
.
download
!,
savePath:
'
$savePath$bookId
.zip'
,
onReceiveProgress:
(
int
received
,
int
total
){
if
(
total
!=-
1
){
double
progress
=
(
received
/
total
)
*
100
;
Console
.
log
(
'Download progress:
$progress
%'
);
}
});
}
//获取存储目录
Future
<
String
>
_getDocumentsDirectory
()
async
{
final
directory
=
await
getApplicationDocumentsDirectory
();
return
directory
.
path
;
}
///------------------------------------------ app 生命周期--------------------------------------------------------
///------------------------------------------ app 生命周期--------------------------------------------------------
// 当应用程序从后台切换到前台并变为活动状态时调用。这通常在用户从其他应用程序返回到你的应用程序时发生
// 当应用程序从后台切换到前台并变为活动状态时调用。这通常在用户从其他应用程序返回到你的应用程序时发生
void
onResumed
(){
void
onResumed
(){
print
(
'onResumed'
);
Console
.
log
(
'onResumed'
);
// open
// open
// 上报开始阅读时间
// 上报开始阅读时间
_addReadTime
(
type:
'open'
);
_addReadTime
(
type:
'open'
);
...
@@ -217,20 +337,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -217,20 +337,20 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 当应用程序失去焦点并进入非活动状态时调用。这可能是因为用户切换到其他应用程序或将应用程序最小化
// 当应用程序失去焦点并进入非活动状态时调用。这可能是因为用户切换到其他应用程序或将应用程序最小化
void
onPaused
(){
void
onPaused
(){
// close
// close
print
(
'onPaused'
);
Console
.
log
(
'onPaused'
);
// 上报阅读结束时间
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
_addReadTime
(
type:
'close'
);
}
}
// 当应用程序失去焦点但仍然可见时调用。通常,在用户切换到另一个应用程序或显示系统对话框时,应用程序可能会处于非活动状态,但仍然是可见的
// 当应用程序失去焦点但仍然可见时调用。通常,在用户切换到另一个应用程序或显示系统对话框时,应用程序可能会处于非活动状态,但仍然是可见的
void
onInactive
(){
void
onInactive
(){
print
(
'onInactive'
);
Console
.
log
(
'onInactive'
);
// close
// close
// 上报阅读结束时间
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
_addReadTime
(
type:
'close'
);
}
}
// 当应用程序被挂起,可能是由于用户关闭应用程序或系统资源不足时调用。在这个状态下,应用程序的代码将不再运行,并且可能被系统终止
// 当应用程序被挂起,可能是由于用户关闭应用程序或系统资源不足时调用。在这个状态下,应用程序的代码将不再运行,并且可能被系统终止
void
onDetached
(){
void
onDetached
(){
print
(
'onDetached'
);
Console
.
log
(
'onDetached'
);
// close
// close
// 上报阅读结束时间
// 上报阅读结束时间
_addReadTime
(
type:
'close'
);
_addReadTime
(
type:
'close'
);
...
...
lib/pages/read_web/index.dart
浏览文件 @
9855a239
...
@@ -12,6 +12,7 @@ import 'package:flutter_book/utils/index.dart';
...
@@ -12,6 +12,7 @@ import 'package:flutter_book/utils/index.dart';
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'../../apis/index.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
import
'../../models/index.dart'
;
...
...
lib/pages/read_web/view.dart
浏览文件 @
9855a239
...
@@ -23,20 +23,30 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -23,20 +23,30 @@ class _ReadPageState extends State<ReadPage> {
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
print
(
'+++++++++++++++++++++++
${widget.bookId}
'
);
return
GetBuilder
<
ReadController
>(
return
GetBuilder
<
ReadController
>(
init:
ReadController
(
bookId:
widget
.
bookId
,
chapterId:
widget
.
chapterId
,
chapterName:
widget
.
chapterName
),
init:
ReadController
(
bookId:
widget
.
bookId
,
chapterId:
widget
.
chapterId
,
chapterName:
widget
.
chapterName
),
builder:
(
readController
)
=>
Scaffold
(
builder:
(
readController
)
=>
Scaffold
(
appBar:
AppBar
(
appBar:
Custom
AppBar
(
title:
Text
(
widget
.
chapterName
),
title:
Text
(
widget
.
chapterName
),
centerTitle:
false
,
centerTitle:
false
,
actions:
[
GestureDetector
(
onTap:
()
{
readController
.
getBookDown
();
},
child:
Text
(
'离线阅读'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
),
))
],
),
),
resizeToAvoidBottomInset:
false
,
resizeToAvoidBottomInset:
false
,
floatingActionButton:
readController
.
show
?
GestureDetector
(
floatingActionButton:
readController
.
show
?
GestureDetector
(
onTap:
(){
onTap:
(){
readController
.
setShowChat
(
true
);
readController
.
setShowChat
(
true
);
// FocusScope.of(context).requestFocus(readController.commentFocusNode);
readController
.
noteTitle
=
'你好你问你你等您第五年对哦in我ID呢哦win地哦为内地那打卡你打困哪'
;
readController
.
setChatType
(
1
);
},
},
child:
Image
.
asset
(
'assets/images/chat.png'
),
child:
Image
.
asset
(
'assets/images/chat.png'
),
):
null
,
):
null
,
...
@@ -55,20 +65,10 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -55,20 +65,10 @@ class _ReadPageState extends State<ReadPage> {
initialUrlRequest:
URLRequest
(
initialUrlRequest:
URLRequest
(
url:
Uri
.
parse
(
'http://192.168.11.46:9200/read.html'
),
url:
Uri
.
parse
(
'http://192.168.11.46:9200/read.html'
),
),
),
onWebViewCreated:
(
InAppWebViewController
controller
)
{
},
contextMenu:
ContextMenu
(
contextMenu:
ContextMenu
(
options:
ContextMenuOptions
(
hideDefaultSystemContextMenuItems:
true
),
options:
ContextMenuOptions
(
hideDefaultSystemContextMenuItems:
true
),
),
),
// onLoadStart: (InAppWebViewController controller, Uri? url) async {
//
// },
// onConsoleMessage: (controller, consoleMessage) {
// print("Received message from WebView: ${consoleMessage.message}");
// },
onLoadStop:
(
controller
,
url
)
{
onLoadStop:
(
controller
,
url
)
{
// flutter 主动给 js 传参数
// flutter 主动给 js 传参数
Map
<
String
,
dynamic
>
param
=
{
Map
<
String
,
dynamic
>
param
=
{
'book_id'
:
110
,
'book_id'
:
110
,
...
@@ -92,22 +92,20 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -92,22 +92,20 @@ class _ReadPageState extends State<ReadPage> {
// 监听笔记回调
// 监听笔记回调
controller
.
addJavaScriptHandler
(
handlerName:
'noteCallBack'
,
callback:
(
args
){
controller
.
addJavaScriptHandler
(
handlerName:
'noteCallBack'
,
callback:
(
args
){
print
(
'----------------------noteCallBack--------------------------
$args
'
);
});
});
// 监听百科回调
// 监听百科回调
controller
.
addJavaScriptHandler
(
handlerName:
'baikeCallBack'
,
callback:
(
args
){
controller
.
addJavaScriptHandler
(
handlerName:
'baikeCallBack'
,
callback:
(
args
){
print
(
'----------------------baikeCallBack--------------------------
$args
'
);
context
.
pushNamed
(
Routes
.
baiKe
,
queryParameters:
{
'keyword'
:
args
});
context
.
pushNamed
(
Routes
.
baiKe
,
queryParameters:
{
'keyword'
:
args
});
});
});
// 监听讨论回调
// 监听讨论回调
controller
.
addJavaScriptHandler
(
handlerName:
'discussCallBack'
,
callback:
(
args
){
controller
.
addJavaScriptHandler
(
handlerName:
'discussCallBack'
,
callback:
(
args
){
print
(
'----------------------discussCallBack--------------------------
$args
'
);
readController
.
setShowChat
(
true
);
readController
.
setChatType
(
0
);
readController
.
titleInput
.
text
=
'11111'
;
});
});
},
},
),
),
// AnimatedPositioned(
// AnimatedPositioned(
...
@@ -127,29 +125,70 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -127,29 +125,70 @@ class _ReadPageState extends State<ReadPage> {
left:
0
,
left:
0
,
right:
0
,
right:
0
,
top:
0
,
top:
0
,
bottom:
49
+
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
bottom:
49
,
child:
_showContent
(
readController
,
readController
.
toolModel
)
child:
_showContent
(
readController
,
readController
.
toolModel
)
),
),
AnimatedPositioned
(
// AnimatedPositioned(
duration:
readController
.
controller
.
duration
!,
// duration: readController.controller.duration!,
curve:
Curves
.
easeInOut
,
// curve: Curves.easeInOut,
bottom:
readController
.
show
?
0
:
-
49
-
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
// 负值隐藏,0 显示
// bottom: readController.show ? 0 : -49 - MediaQuery.of(context).viewInsets.bottom, // 负值隐藏,0 显示
// left: 0,
// right: 0,
// height: 49,
// child: Container(
// color: Colors.limeAccent,
// alignment: Alignment.center,
// child: _createToolBar(readController)
// ),
// ),
/// 底部工具栏布局
Visibility
(
visible:
readController
.
show
,
child:
Positioned
(
left:
0
,
left:
0
,
right:
0
,
right:
0
,
height:
49
,
bottom:
0
,
child:
SafeArea
(
child:
Container
(
child:
Container
(
height:
49
,
color:
Colors
.
limeAccent
,
color:
Colors
.
limeAccent
,
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
child:
_createToolBar
(
readController
)
child:
_createToolBar
(
readController
)
),
),
),
),
)
),
/// 悬浮按钮点击发起话题布局
Visibility
(
Visibility
(
visible:
readController
.
showChat
,
visible:
readController
.
showChat
,
child:
Positioned
(
child:
Positioned
(
left:
0
,
left:
0
,
right:
0
,
right:
0
,
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
top:
0
,
bottom:
0
,
child:
GestureDetector
(
onTap:
(){
readController
.
setShowChat
(
false
);
readController
.
clearAllDiscussInput
();
},
child:
Container
(
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
child:
SingleChildScrollView
(
reverse:
true
,
child:
Container
(
color:
Colors
.
white
,
padding:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
),
// alignment:Alignment.bottomCenter,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
onTap:
(){},
child:
ReadInputDiscuss
(
controller:
readController
,)
child:
ReadInputDiscuss
(
controller:
readController
,)
)
),
),
),
)
),
),
),
),
],
],
...
@@ -162,8 +201,7 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -162,8 +201,7 @@ class _ReadPageState extends State<ReadPage> {
/// 目录 笔记 讨论 工具栏
/// 目录 笔记 讨论 工具栏
Widget
_createToolBar
(
ReadController
controller
){
Widget
_createToolBar
(
ReadController
controller
){
return
Container
(
return
Row
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
children:
controller
.
tools
.
map
((
model
){
children:
controller
.
tools
.
map
((
model
){
return
Expanded
(
return
Expanded
(
...
@@ -191,13 +229,12 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -191,13 +229,12 @@ class _ReadPageState extends State<ReadPage> {
),
),
);
);
}).
toList
()
}).
toList
()
),
);
);
}
}
/// 目录、评论、笔记
/// 目录、评论、笔记
Widget
_showContent
(
ReadController
controller
,
ToolModel
model
)
{
Widget
_showContent
(
ReadController
controller
,
ToolModel
model
)
{
print
(
'++++++++++++++++++++++++
${model.tag}
'
);
Console
.
log
(
'++++++++++++++++++++++++
${model.tag}
'
);
if
(
controller
.
show
){
if
(
controller
.
show
){
if
(
model
.
tag
==
0
){
if
(
model
.
tag
==
0
){
return
model
.
selected
?
Container
(
return
model
.
selected
?
Container
(
...
@@ -217,7 +254,7 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -217,7 +254,7 @@ class _ReadPageState extends State<ReadPage> {
}
}
else
if
(
model
.
tag
==
1
){
else
if
(
model
.
tag
==
1
){
return
model
.
selected
?
Container
(
return
model
.
selected
?
Container
(
color:
Color
(
0xFF000000
).
withOpacity
(
0.5
),
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
child:
ClipRRect
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
...
@@ -233,7 +270,7 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -233,7 +270,7 @@ class _ReadPageState extends State<ReadPage> {
}
}
else
if
(
model
.
tag
==
2
){
else
if
(
model
.
tag
==
2
){
return
model
.
selected
?
Container
(
return
model
.
selected
?
Container
(
color:
Color
(
0xFF000000
).
withOpacity
(
0.5
),
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
child:
ClipRRect
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
...
@@ -251,158 +288,10 @@ class _ReadPageState extends State<ReadPage> {
...
@@ -251,158 +288,10 @@ class _ReadPageState extends State<ReadPage> {
return
const
SizedBox
();
return
const
SizedBox
();
}
}
Widget
_discussInput
(
ReadController
controller
){
return
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
child:
Column
(
children:
[
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
.
w
),
child:
Row
(
children:
[
Text
(
'话题'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.5
,
fontWeight:
Fonts
.
medium
),),
Gaps
.
hGaps5
,
Expanded
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
4
),
child:
TextField
(
focusNode:
controller
.
discussTitleFocusNode
,
autofocus:
true
,
decoration:
InputDecoration
(
hintText:
'请输入话题名称'
,
hintStyle:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),
filled:
true
,
fillColor:
Colours
.
cF8
,
),
),
),
),
],
),
),
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
4
.
w
),
child:
Container
(
color:
Colours
.
cF8
,
constraints:
BoxConstraints
(
minHeight:
100
.
w
),
child:
Column
(
children:
[
TextField
(
focusNode:
controller
.
discussContentFocusNode
,
maxLines:
null
,
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
hintText:
'请输入内容'
,
hintStyle:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),
filled:
true
,
fillColor:
Colours
.
cF8
,
),
),
Column
(
children:
[
MediaQuery
.
removePadding
(
context:
context
,
removeTop:
true
,
child:
GridView
.
builder
(
// padding: const EdgeInsets.only(left: 13,top: 10),
physics:
const
NeverScrollableScrollPhysics
(),
shrinkWrap:
true
,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
6
,
crossAxisSpacing:
2
.
w
,
mainAxisSpacing:
2
.
w
,
childAspectRatio:
1
),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
color:
Colors
.
red
,
child:
Center
(
child:
Text
(
'图片'
)),
);
},
itemCount:
0
,
),
),
Container
(
color:
Colors
.
red
,
child:
MediaQuery
.
removePadding
(
context:
context
,
removeTop:
true
,
child:
ListView
.
builder
(
physics:
const
NeverScrollableScrollPhysics
(),
shrinkWrap:
true
,
itemBuilder:
(
BuildContext
context
,
int
index
){
return
Container
(
height:
20
.
w
,
margin:
EdgeInsets
.
only
(
right:
130
.
w
),
child:
Container
(
margin:
EdgeInsets
.
only
(
top:
5
.
w
),
padding:
EdgeInsets
.
only
(
right:
20
.
w
,
left:
10
.
w
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
10
.
w
),
color:
Colours
.
cF9
,
),
child:
Row
(
// mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Image
.
asset
(
'assets/images/audio.png'
),
Text
(
'0:00/1:52'
,
style:
TextStyle
(
fontSize:
10
.
w
,
height:
1.4
,
color:
Colours
.
c9
),)
],
),
),
);
},
itemCount:
0
,
),
),
)
],
)
],
),
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Row
(
children:
[
Image
.
asset
(
'assets/images/read_add_img.png'
),
Gaps
.
hGaps10
,
Image
.
asset
(
'assets/images/read_add_audio.png'
),
],
),
GestureDetector
(
onTap:
(){},
child:
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
15
.
w
),
color:
AppTheme
.
primary
,
gradient:
LinearGradient
(
colors:
[
const
Color
(
0xFFD53676
).
withOpacity
(
0.9
),
AppTheme
.
primary
]
,
// 不可点击时的颜色,透明度为0.7
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
),
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
13.5
.
w
,
vertical:
4
.
w
),
child:
Text
(
'发表'
,
style:
TextStyle
(
fontSize:
14
.
w
,
fontWeight:
Fonts
.
medium
,
color:
Colors
.
white
),),
),
)
],
)
],
)
);
}
}
}
/// 定制 悬浮按钮位置
class
MyFloatingActionButtonLocation
extends
FloatingActionButtonLocation
{
class
MyFloatingActionButtonLocation
extends
FloatingActionButtonLocation
{
@override
@override
Offset
getOffset
(
ScaffoldPrelayoutGeometry
scaffoldGeometry
)
{
Offset
getOffset
(
ScaffoldPrelayoutGeometry
scaffoldGeometry
)
{
...
@@ -415,24 +304,4 @@ class MyFloatingActionButtonLocation extends FloatingActionButtonLocation {
...
@@ -415,24 +304,4 @@ class MyFloatingActionButtonLocation extends FloatingActionButtonLocation {
}
}
// class NoAnimationFabAnimator extends FloatingActionButtonAnimator {
// // 通过构造函数参数提供动画
// const NoAnimationFabAnimator();
//
// @override
// Animation<double> getRotationAnimation({required Animation<double> parent}) {
// return AlwaysStoppedAnimation<double>(0);
// }
//
// @override
// Animation<double> getScaleAnimation({required Animation<double> parent}) {
// return AlwaysStoppedAnimation<double>(1);
// }
//
// @override
// Offset getOffset({required Offset begin, required Offset end, required double progress}) {
// return begin;
// }
// }
lib/pages/read_web/widgets/input_discuss.dart
浏览文件 @
9855a239
...
@@ -15,13 +15,13 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
...
@@ -15,13 +15,13 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
(
return
Container
(
color:
Colors
.
green
,
color:
Colors
.
white
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
child:
Column
(
child:
Column
(
children:
[
children:
[
Container
(
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
.
w
),
margin:
EdgeInsets
.
symmetric
(
vertical:
10
.
w
),
child:
Row
(
child:
widget
.
controller
.
chatType
==
0
?
Row
(
children:
[
children:
[
Text
(
'话题'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.5
,
fontWeight:
Fonts
.
medium
),),
Text
(
'话题'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.5
,
fontWeight:
Fonts
.
medium
),),
Gaps
.
hGaps5
,
Gaps
.
hGaps5
,
...
@@ -41,11 +41,14 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
...
@@ -41,11 +41,14 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
filled:
true
,
filled:
true
,
fillColor:
Colours
.
cF8
,
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
(
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
4
.
w
),
borderRadius:
BorderRadius
.
circular
(
4
.
w
),
...
@@ -59,6 +62,7 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
...
@@ -59,6 +62,7 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
TextField
(
TextField
(
focusNode:
widget
.
controller
.
discussContentFocusNode
,
focusNode:
widget
.
controller
.
discussContentFocusNode
,
maxLines:
null
,
maxLines:
null
,
autofocus:
widget
.
controller
.
chatType
==
0
?
false
:
true
,
controller:
widget
.
controller
.
contentInput
,
controller:
widget
.
controller
.
contentInput
,
decoration:
InputDecoration
(
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
border:
InputBorder
.
none
,
...
@@ -174,11 +178,25 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
...
@@ -174,11 +178,25 @@ class _ReadInputDiscussState extends State<ReadInputDiscuss> {
},
},
child:
Image
.
asset
(
'assets/images/read_add_audio.png'
)
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
(
GestureDetector
(
onTap:
(){
onTap:
(){
widget
.
controller
.
addDiscuss
();
widget
.
controller
.
submit
();
},
},
child:
Container
(
child:
Container
(
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
...
...
lib/services/http.dart
浏览文件 @
9855a239
...
@@ -146,6 +146,7 @@ class HttpService extends GetxService {
...
@@ -146,6 +146,7 @@ class HttpService extends GetxService {
try
{
try
{
final
requestOptions
=
options
??
Options
();
final
requestOptions
=
options
??
Options
();
requestOptions
.
headers
=
_getHeaders
(
excludeToken:
excludeToken
,
url:
url
);
requestOptions
.
headers
=
_getHeaders
(
excludeToken:
excludeToken
,
url:
url
);
requestOptions
.
responseType
=
ResponseType
.
bytes
;
await
_dio
.
download
(
await
_dio
.
download
(
url
,
url
,
savePath
,
savePath
,
...
@@ -153,9 +154,10 @@ class HttpService extends GetxService {
...
@@ -153,9 +154,10 @@ class HttpService extends GetxService {
cancelToken:
cancelToken
,
cancelToken:
cancelToken
,
onReceiveProgress:
onReceiveProgress
onReceiveProgress:
onReceiveProgress
);
);
Console
.
log
(
'Download completed:
$savePath
'
);
Console
.
log
(
'Download completed:
$savePath
'
);
}
catch
(
e
){
}
catch
(
e
){
Console
.
log
(
e
);
Console
.
log
(
'Error during download:
$e
'
);
rethrow
;
rethrow
;
}
}
}
}
...
@@ -167,7 +169,10 @@ class HttpService extends GetxService {
...
@@ -167,7 +169,10 @@ class HttpService extends GetxService {
class
_RequestInterceptor
extends
Interceptor
{
class
_RequestInterceptor
extends
Interceptor
{
@override
@override
void
onResponse
(
Response
response
,
ResponseInterceptorHandler
handler
)
async
{
void
onResponse
(
Response
response
,
ResponseInterceptorHandler
handler
)
async
{
if
(
response
.
data
[
'code'
]
!=
200
)
{
final
responseData
=
response
.
data
;
if
(
responseData
is
Map
&&
responseData
.
containsKey
(
'code'
))
{
final
code
=
responseData
[
'code'
];
if
(
code
!=
200
)
{
handler
.
reject
(
handler
.
reject
(
DioException
(
DioException
(
requestOptions:
response
.
requestOptions
,
requestOptions:
response
.
requestOptions
,
...
@@ -176,9 +181,24 @@ class _RequestInterceptor extends Interceptor {
...
@@ -176,9 +181,24 @@ class _RequestInterceptor extends Interceptor {
),
),
true
,
true
,
);
);
}
else
{
return
;
super
.
onResponse
(
response
,
handler
);
}
}
else
if
(
response
.
requestOptions
.
responseType
==
ResponseType
.
bytes
)
{
}
}
super
.
onResponse
(
response
,
handler
);
// if (response.data['code'] != 200) {
// handler.reject(
// DioException(
// requestOptions: response.requestOptions,
// response: response,
// type: DioExceptionType.badResponse,
// ),
// true,
// );
// }else {
// super.onResponse(response, handler);
// }
}
}
@override
@override
...
@@ -206,6 +226,7 @@ class _RequestInterceptor extends Interceptor {
...
@@ -206,6 +226,7 @@ class _RequestInterceptor extends Interceptor {
var
msg
=
'服务器错误'
;
var
msg
=
'服务器错误'
;
switch
(
statusCode
)
{
switch
(
statusCode
)
{
case
403
:
case
403
:
print
(
'-------------------access_token-------------------------
${UserStore.to.accessToken}
--------------------'
);
msg
=
'
$statusCode
- Unauthorized'
;
msg
=
'
$statusCode
- Unauthorized'
;
final
newToken
=
await
refreshToken
();
final
newToken
=
await
refreshToken
();
if
(
newToken
!=
null
)
{
if
(
newToken
!=
null
)
{
...
@@ -233,6 +254,8 @@ class _RequestInterceptor extends Interceptor {
...
@@ -233,6 +254,8 @@ class _RequestInterceptor extends Interceptor {
}
else
{
}
else
{
UserStore
.
to
.
logout
();
UserStore
.
to
.
logout
();
CustomToast
.
fail
(
'登录已失效,请重新登录'
);
CustomToast
.
fail
(
'登录已失效,请重新登录'
);
print
(
'-------------------access_token-------------------------
${UserStore.to.accessToken}
--------------------'
);
}
}
break
;
break
;
case
404
:
case
404
:
...
...
lib/widgets/book.dart
浏览文件 @
9855a239
...
@@ -19,7 +19,7 @@ class CustomCard extends StatelessWidget {
...
@@ -19,7 +19,7 @@ class CustomCard extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
(
return
Container
(
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
color:
Colors
.
cyan
,
color:
Colors
.
white
,
borderRadius:
borderRadius
??
BorderRadius
.
circular
(
3
),
borderRadius:
borderRadius
??
BorderRadius
.
circular
(
3
),
boxShadow:
boxShadow
??
[
boxShadow:
boxShadow
??
[
BoxShadow
(
BoxShadow
(
...
@@ -33,7 +33,7 @@ class CustomCard extends StatelessWidget {
...
@@ -33,7 +33,7 @@ class CustomCard extends StatelessWidget {
height:
height
,
height:
height
,
width:
width
,
width:
width
,
child:
Container
(
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'
),),
child:
CustomImage
.
network
(
url:
url
,
placeholder:
Image
.
asset
(
'assets/images/book_placeholder.png'
),),
),
),
);
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论