Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
a4d27b1e
提交
a4d27b1e
authored
4月 07, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化阅读页代码
上级
9bfd0e61
全部展开
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
61 行删除
+8
-61
controller.dart
lib/pages/read_web/controller.dart
+0
-0
view.dart
lib/pages/read_web/view.dart
+8
-61
没有找到文件。
lib/pages/read_web/controller.dart
浏览文件 @
a4d27b1e
差异被折叠。
点击展开。
lib/pages/read_web/view.dart
浏览文件 @
a4d27b1e
...
...
@@ -71,7 +71,6 @@ class _ReadPageState extends State<ReadPage> {
child:
Stack
(
children:
[
InAppWebView
(
// initialFile:''assets/html/read_unline.html'',
initialFile:
readController
.
existDownFile
&&
!
readController
.
netStatus
?
'assets/html/read_unline.html'
:
'assets/html/read.html'
,
// initialUrlRequest:URLRequest(
// url:WebUri.uri(Uri.parse(kReadTestUnderLineBook))
...
...
@@ -82,16 +81,9 @@ class _ReadPageState extends State<ReadPage> {
// http的请求也不做限制
mixedContentMode:
MixedContentMode
.
MIXED_CONTENT_ALWAYS_ALLOW
),
// initialOptions: InAppWebViewGroupOptions(
// crossPlatform: InAppWebViewOptions(
// clearCache: true
// )
// ),
contextMenu:
ContextMenu
(
// options: ContextMenuOptions(hideDefaultSystemContextMenuItems: true),
settings:
ContextMenuSettings
(
hideDefaultSystemContextMenuItems:
true
,
)
),
onWebViewCreated:
(
InAppWebViewController
controller
){
...
...
@@ -103,30 +95,22 @@ class _ReadPageState extends State<ReadPage> {
Console
.
log
(
"Received message from WebView-----------------------------:
${consoleMessage.message}
"
);
},
onLoadStop:
(
controller
,
url
)
{
// flutter 主动给 js 传参数
// String str = '$kServerUrl,${readController.bookId},${readController.chapterId},${UserStore.to.token},${readController.noteId},${readController.sModel.bookId =='0'?'':readController.sModel.combinedContent}';
// controller.evaluateJavascript(source: 'callbackInFlutterComponent("$str");');
// Console.log('传给前端的参数--------------------------------$str');
// String jsonStr = jsonEncode(param);
// controller.evaluateJavascript(source: 'callbackInFlutterComponent($jsonStr)');
if
(
readController
.
existDownFile
&&
!
readController
.
netStatus
){
String
temp
=
readController
.
existDownFile
&&
!
readController
.
netStatus
?
'assets/html/read_unline.html'
:
'assets/html/read.html'
;
Console
.
log
(
'-----------------加载离线数据---------------
$temp
'
);
Console
.
log
(
'-----------------加载离线数据---------------'
);
readController
.
getOffLineInfo
();
}
else
{
// controller.loadFile(assetFilePath: 'assets/html/read.html');
Console
.
log
(
'-----------------加载在线数据---------------'
);
String
str
=
'
$kServerUrl
,
${readController.bookId}
,
${readController.chapterId}
,
${UserStore.to.token}
,
${readController.noteId}
,
${readController.sModel.bookId =='0'?'':readController.sModel.combinedContent}
'
;
controller
.
evaluateJavascript
(
source
:
'callbackInFlutterComponent("
$str
");'
);
}
// 添加单击事件
controller
.
evaluateJavascript
(
source
:
'''
document.addEventListener('
click
', function() {
window.flutter_inappwebview.callHandler('
onTap
');
});
'''
);
// 监听js单击回调
controller
.
addJavaScriptHandler
(
handlerName:
'onTap'
,
callback:
(
args
){
readController
.
setShow
(
readController
.
show
);
...
...
@@ -158,12 +142,6 @@ class _ReadPageState extends State<ReadPage> {
controller
.
addJavaScriptHandler
(
handlerName:
'readCallBack'
,
callback:
(
args
){
Console
.
log
(
'监听朗读回调------------------------------------------------
$args
'
);
readController
.
speak
(
args
.
first
.
toString
());
// readController.speak('中国共产党(英文名:the Communist Party of China,简写CPC),'
// '创建于1921年7月23日,1921年中国共产党成立后,确立了新民主主义革命的正确道路,让灾难深重的中'
// '国人民看到了新的希望、有了新的依靠。我们党探索出农村包围城市、武装夺取政权的正确革命道路,“唤起工'
// '农千百万”“夺过鞭子揍敌人”,经过土地革命战争、抗日战争、解放战争,推翻了压在中国人民头上的帝国主义、'
// '封建主义、官僚资本主义“三座大山”,建立了人民当家作主的中华人民共和国,彻底结束了近代以来中国内忧外患、积贫积弱的悲惨境地,开启了中华民族发展进步的新纪元'
// );
});
// 监听讨论回调
...
...
@@ -174,6 +152,7 @@ class _ReadPageState extends State<ReadPage> {
readController
.
noteTitle
=
args
.
first
.
toString
();
});
// 答题和答题结果页回调
controller
.
addJavaScriptHandler
(
handlerName:
'answerResultCallBack'
,
callback:
(
args
){
Console
.
log
(
'监听答题回调------------------------------------------------
$args
'
);
...
...
@@ -245,6 +224,7 @@ class _ReadPageState extends State<ReadPage> {
Console
.
log
(
'监听画廊 扩展于都---------------给页面传参---------------------------------
$params
'
);
context
.
pushNamed
(
Routes
.
readInfo
,
queryParameters:
params
);
});
// 图片预览
controller
.
addJavaScriptHandler
(
handlerName:
'scaleImageCallback'
,
callback:
(
args
){
String
url
=
args
.
first
[
0
].
toString
();
...
...
@@ -274,23 +254,13 @@ class _ReadPageState extends State<ReadPage> {
});
/// 离线需要参数
// //
// Map<String, dynamic> param111 = {
// 'book_id': readController.bookId,
// 'chapter_id': readController.chapterId,
// 'token':UserStore.to.token
// };
// String jsonStr = jsonEncode(param111);
// controller.evaluateJavascript(source: 'offlineCallbackInFlutterComponent($jsonStr)');
// // controller.evaluateJavascript(source: 'callbackInFlutterComponent("$str");');
// 添加高亮划线笔记
controller
.
addJavaScriptHandler
(
handlerName:
'offlineAddNoteCallBack'
,
callback:
(
args
){
Console
.
log
(
'添加笔记回调------------------------------------------
${args[0]}
'
);
Map
<
String
,
dynamic
>
data
=
args
[
0
];
readController
.
addLocalNote
(
data
);
});
// 删除高亮划线笔记
controller
.
addJavaScriptHandler
(
handlerName:
'offlineDelNoteCallBack'
,
callback:
(
args
){
Console
.
log
(
'删除笔记回调------------------------------------------
${args[0]}
'
);
...
...
@@ -316,26 +286,6 @@ class _ReadPageState extends State<ReadPage> {
}
readController
.
updateLocalNote
(
notesId:
notesId
,
id:
id
,
data:
data
);
});
// 查询高亮划线笔记
// controller.addJavaScriptHandler(handlerName: 'offlineQueryNoteCallBack', callback: (args){
//
// });
// // 上一节下一节
// controller.addJavaScriptHandler(handlerName: 'offlineReadNoteCallBack', callback: (args){
// int type = 0;
// // 上一节
// if (type == 0){
// readController.readChapter(type: 0);
// }
// // 下一节
// else{
// readController.readChapter(type: 1);
// }
//
// });
},
),
Positioned
(
...
...
@@ -405,7 +355,7 @@ class _ReadPageState extends State<ReadPage> {
}
//
/
目录 笔记 讨论 工具栏
// 目录 笔记 讨论 工具栏
Widget
_createToolBar
(
ReadController
controller
){
return
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
...
...
@@ -439,7 +389,6 @@ class _ReadPageState extends State<ReadPage> {
);
}
Widget
detail
(
ReadController
controller
,
ToolModel
model
){
if
(
model
.
tag
==
0
){
return
ReadCategoryPage
(
controller:
controller
,
...
...
@@ -508,7 +457,7 @@ class _ReadPageState extends State<ReadPage> {
}
return
const
SizedBox
();
}
//
/
目录、评论、笔记 背景
// 目录、评论、笔记 背景
Widget
_showContent
(
ReadController
controller
,
ToolModel
model
)
{
if
(
controller
.
show
){
if
(
model
.
selected
){
...
...
@@ -540,12 +489,10 @@ class _ReadPageState extends State<ReadPage> {
}
return
const
SizedBox
();
}
}
//
/
定制 悬浮按钮位置
// 定制 悬浮按钮位置
class
MyFloatingActionButtonLocation
extends
FloatingActionButtonLocation
{
@override
Offset
getOffset
(
ScaffoldPrelayoutGeometry
scaffoldGeometry
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论