提交 bc4b9436 authored 作者: yueweilu's avatar yueweilu

传参加入上一节的内容、并且传参加入上一节的标识

上级 23a38b15
...@@ -55,6 +55,15 @@ function countSubstringOccurrences(str, substring) { ...@@ -55,6 +55,15 @@ function countSubstringOccurrences(str, substring) {
</div> </div>
<div class="chapter-content-list" id="chapter-content-list"> <div class="chapter-content-list" id="chapter-content-list">
<div class="show-up">
<div
class="chapter-item-up"
:class="[`chapter-item-up-${prev_chapter.id}`]"
id="chapter-item-up"
:data-id="prev_chapter.id"
v-html="prev_chapter.contents"
></div>
</div>
<div class="show"> <div class="show">
<div <div
class="chapter-item" class="chapter-item"
...@@ -219,6 +228,7 @@ function countSubstringOccurrences(str, substring) { ...@@ -219,6 +228,7 @@ function countSubstringOccurrences(str, substring) {
docmHeight: document.documentElement.clientHeight || document.body.clientHeight, docmHeight: document.documentElement.clientHeight || document.body.clientHeight,
clientWidth: document.documentElement.clientWidth || document.body.clientWidth, clientWidth: document.documentElement.clientWidth || document.body.clientWidth,
windowHeight: 0, // 视口的高度 windowHeight: 0, // 视口的高度
upContentsHeight: 0,
colorList: [ colorList: [
"feff00", "feff00",
"00ff00", "00ff00",
...@@ -355,14 +365,21 @@ function countSubstringOccurrences(str, substring) { ...@@ -355,14 +365,21 @@ function countSubstringOccurrences(str, substring) {
this.clearRangeContent(); this.clearRangeContent();
this.callHandlerNoticeFlutterSubmit("dismissLoadingCallback"); this.callHandlerNoticeFlutterSubmit("dismissLoadingCallback");
document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
});
// 带内容加载完成 // 带内容加载完成
await this.waitForContentLoad(); await this.waitForContentLoad();
if (scroll) {
$(".chapter-content-list .show").css({
transform: `translateY(-${this.upContentsHeight - this.windowHeight}px)`,
WebkitTranform: `translateY(-${this.upContentsHeight - this.windowHeight}px)`,
})
}
this.searchTextInSide(); this.searchTextInSide();
// 计算设置上一节的高度
document.querySelectorAll('pre code').forEach((el) => { this.upContentsHeight = $(".chapter-item-up").innerHeight();
hljs.highlightElement(el);
});
// 进度设置 // 进度设置
await this.uploadRead(); await this.uploadRead();
await this.line_listFilterShow(); await this.line_listFilterShow();
...@@ -536,9 +553,7 @@ function countSubstringOccurrences(str, substring) { ...@@ -536,9 +553,7 @@ function countSubstringOccurrences(str, substring) {
loadedCount++; loadedCount++;
// 如果所有图片都加载完成,执行其他操作 // 如果所有图片都加载完成,执行其他操作
if (loadedCount === images.length) { if (loadedCount === images.length) {
_that.chapterContentHeight = $( _that.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
"#chapter-content-list .show"
).innerHeight();
observer.disconnect(); observer.disconnect();
resolve(); resolve();
} }
...@@ -548,18 +563,14 @@ function countSubstringOccurrences(str, substring) { ...@@ -548,18 +563,14 @@ function countSubstringOccurrences(str, substring) {
loadedCount++; loadedCount++;
// 处理加载失败的情况 // 处理加载失败的情况
if (loadedCount === images.length) { if (loadedCount === images.length) {
_that.chapterContentHeight = $( _that.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
"#chapter-content-list .show"
).innerHeight();
observer.disconnect(); observer.disconnect();
resolve(); resolve();
} }
}); });
}); });
} else { } else {
_that.chapterContentHeight = $( _that.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
"#chapter-content-list .show"
).innerHeight();
observer.disconnect(); observer.disconnect();
resolve(); resolve();
} }
...@@ -1047,12 +1058,11 @@ function countSubstringOccurrences(str, substring) { ...@@ -1047,12 +1058,11 @@ function countSubstringOccurrences(str, substring) {
if (Object.entries(_that.prev_chapter).length > 0) { if (Object.entries(_that.prev_chapter).length > 0) {
$(".prev-chapter").css({ opacity: 0 }); $(".prev-chapter").css({ opacity: 0 });
_that.chapter_id = _that.prev_chapter.id; _that.chapter_id = _that.prev_chapter.id;
console.log(_that.prev_chapter.name);
_that.callHandlerNoticeFlutterSubmit( _that.callHandlerNoticeFlutterSubmit(
"loadChapterCallBack", "loadChapterCallBack",
[_that.chapter_id, _that.prev_chapter.name] [_that.chapter_id, _that.prev_chapter.name]
); );
await _that.getBookChapterData(); await _that.getBookChapterData(null, true);
} else { } else {
$(".prev-chapter").css({ opacity: 0 }); $(".prev-chapter").css({ opacity: 0 });
$("#chapter-content-list .show").css({ $("#chapter-content-list .show").css({
...@@ -2210,7 +2220,7 @@ function countSubstringOccurrences(str, substring) { ...@@ -2210,7 +2220,7 @@ function countSubstringOccurrences(str, substring) {
const refreshTokenSuccess = (arguments) => { const refreshTokenSuccess = (arguments) => {
return app.refreshTokenSuccess(arguments); return app.refreshTokenSuccess(arguments);
}; };
// callbackInFlutterComponent(',368,2901,bc398dd1d424aea905b05fc7de6af8f5b'); // callbackInFlutterComponent(',358,2821,d4c36b804c0418b134c2eef6d1689943');
</script> </script>
</body> </body>
</html> </html>
...@@ -55,6 +55,15 @@ function countSubstringOccurrences(str, substring) { ...@@ -55,6 +55,15 @@ function countSubstringOccurrences(str, substring) {
</div> </div>
<div class="chapter-content-list" id="chapter-content-list"> <div class="chapter-content-list" id="chapter-content-list">
<div class="show-up">
<div
class="chapter-item-up"
:class="[`chapter-item-up-${prev_chapter.id}`]"
id="chapter-item-up"
:data-id="prev_chapter.id"
v-html="prev_chapter.contents"
></div>
</div>
<div class="show"> <div class="show">
<div <div
class="chapter-item" class="chapter-item"
...@@ -201,6 +210,7 @@ function countSubstringOccurrences(str, substring) { ...@@ -201,6 +210,7 @@ function countSubstringOccurrences(str, substring) {
docmHeight: document.documentElement.clientHeight || document.body.clientHeight, docmHeight: document.documentElement.clientHeight || document.body.clientHeight,
clientWidth: document.documentElement.clientWidth || document.body.clientWidth, clientWidth: document.documentElement.clientWidth || document.body.clientWidth,
windowHeight: 0, // 视口的高度 windowHeight: 0, // 视口的高度
upContentsHeight: 0,
colorList: [ colorList: [
"feff00", "feff00",
"00ff00", "00ff00",
...@@ -303,55 +313,62 @@ function countSubstringOccurrences(str, substring) { ...@@ -303,55 +313,62 @@ function countSubstringOccurrences(str, substring) {
methods: { methods: {
async getBookChapterData(args, scroll) { async getBookChapterData(args, scroll) {
if (this.nextChapterLoading) return; if (this.nextChapterLoading) return;
// loading
this.callHandlerNoticeFlutterSubmit("showLoadingCallback");
this.book_id = args.book_id; this.initArags();
this.chapter_id = args.chapter_id; this.clearRangeContent();
this.chapterContent = ""; if (Object.entries(args).length > 0) {
if (args && args.direction === 'scrollUp') {
$(".chapter-content-list .show").css({
transform: `translateY(-${this.upContentsHeight - this.windowHeight}px)`,
WebkitTranform: `translateY(-${this.upContentsHeight - this.windowHeight}px)`,
})
} else {
this.nextChapterLoading = true;
$("#chapter-content-list .show").css({ $("#chapter-content-list .show").css({
transform: `translateY(0px)`, transform: `translateY(0px)`,
WebkitTranform: `translateY(0px)`, WebkitTranform: `translateY(0px)`,
}); });
this.nextChapterLoading = true; }
this.book_id = args.book_id;
this.initArags(); this.chapter_id = args.chapter_id;
this.clearRangeContent();
// loading
this.callHandlerNoticeFlutterSubmit("showLoadingCallback");
this.next_chapter = args.next_chapter; // 下一节的内容 this.next_chapter = args.next_chapter; // 下一节的内容
this.prev_chapter = args.up_chapter; // 上一节的内容 this.prev_chapter = args.up_chapter; // 上一节的内容
this.color_line = args.color_line; // 高亮 this.color_line = args.color_line; // 高亮
this.line_list = args.line_list; // 划线 this.line_list = args.line_list; // 划线
this.chapterContent = args.content;
this.color_line.forEach((item) => { this.color_line.forEach((item) => {
item.color_id = item.id; item.color_id = item.id;
}) })
this.line_list.forEach((item) => { this.line_list.forEach((item) => {
item.line_id = item.id; item.line_id = item.id;
}) })
if (args.content) {
this.chapterContent = args.content;
this.initArags();
this.clearRangeContent();
this.callHandlerNoticeFlutterSubmit("dismissLoadingCallback"); this.callHandlerNoticeFlutterSubmit("dismissLoadingCallback");
// 带内容加载完成
await this.waitForContentLoad();
document.querySelectorAll('pre code').forEach((el) => { document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el); hljs.highlightElement(el);
}); });
// 进度设置 // 带内容加载完成
await this.waitForContentLoad();
setTimeout(() => {
// 计算设置上一节的高度
this.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
this.upContentsHeight = $(".chapter-item-up").innerHeight();
}, 1000)
await this.line_listFilterShow(); await this.line_listFilterShow();
this.nextChapterLoading = false;
await this.toNoteIdSide(); await this.toNoteIdSide();
// 各类事件 // 各类事件
this.listenHandlerEvents(); this.listenHandlerEvents();
} else { } else {
this.nextChapterLoading = false; $("#chapter-content-list .show").css({
transform: `translateY(0px)`,
WebkitTranform: `translateY(0px)`,
});
} }
this.nextChapterLoading = false;
this.callHandlerNoticeFlutterSubmit("dismissLoadingCallback"); this.callHandlerNoticeFlutterSubmit("dismissLoadingCallback");
}, },
...@@ -413,9 +430,7 @@ function countSubstringOccurrences(str, substring) { ...@@ -413,9 +430,7 @@ function countSubstringOccurrences(str, substring) {
loadedCount++; loadedCount++;
// 如果所有图片都加载完成,执行其他操作 // 如果所有图片都加载完成,执行其他操作
if (loadedCount === images.length) { if (loadedCount === images.length) {
_that.chapterContentHeight = $( _that.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
"#chapter-content-list .show"
).innerHeight();
observer.disconnect(); observer.disconnect();
resolve(); resolve();
} }
...@@ -425,18 +440,14 @@ function countSubstringOccurrences(str, substring) { ...@@ -425,18 +440,14 @@ function countSubstringOccurrences(str, substring) {
loadedCount++; loadedCount++;
// 处理加载失败的情况 // 处理加载失败的情况
if (loadedCount === images.length) { if (loadedCount === images.length) {
_that.chapterContentHeight = $( _that.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
"#chapter-content-list .show"
).innerHeight();
observer.disconnect(); observer.disconnect();
resolve(); resolve();
} }
}); });
}); });
} else { } else {
_that.chapterContentHeight = $( _that.chapterContentHeight = $("#chapter-content-list .show").innerHeight();
"#chapter-content-list .show"
).innerHeight();
observer.disconnect(); observer.disconnect();
resolve(); resolve();
} }
...@@ -448,7 +459,6 @@ function countSubstringOccurrences(str, substring) { ...@@ -448,7 +459,6 @@ function countSubstringOccurrences(str, substring) {
// 监听touch事件 // 监听touch事件
async listenHandlerEvents() { async listenHandlerEvents() {
const eleContent = document.querySelector("#chapter-content-list"); const eleContent = document.querySelector("#chapter-content-list");
const chapterContent = document.querySelector("#chapter-content-list"); const chapterContent = document.querySelector("#chapter-content-list");
document.addEventListener("touchstart", this.touchStartEvent); document.addEventListener("touchstart", this.touchStartEvent);
document.addEventListener("touchmove", this.touchMoveEvent); document.addEventListener("touchmove", this.touchMoveEvent);
...@@ -575,6 +585,12 @@ function countSubstringOccurrences(str, substring) { ...@@ -575,6 +585,12 @@ function countSubstringOccurrences(str, substring) {
_that.touchIn = false; _that.touchIn = false;
if ($(target).closest(".tange-tooptip").length > 0 ) { if ($(target).closest(".tange-tooptip").length > 0 ) {
const href = $(target).closest(".c-link").attr("href");
_that.callHandlerNoticeFlutterSubmit(
"openLinkCallback",
href
);
_that.tooltipId = null;
event.preventDefault(); event.preventDefault();
return false; return false;
} }
...@@ -910,9 +926,10 @@ function countSubstringOccurrences(str, substring) { ...@@ -910,9 +926,10 @@ function countSubstringOccurrences(str, substring) {
if (Object.entries(_that.prev_chapter).length > 0) { if (Object.entries(_that.prev_chapter).length > 0) {
$(".prev-chapter").css({ opacity: 0 }); $(".prev-chapter").css({ opacity: 0 });
_that.chapter_id = _that.prev_chapter.id; _that.chapter_id = _that.prev_chapter.id;
_that.chapterContent = _that.prev_chapter.contents;
_that.callHandlerNoticeFlutterSubmit( _that.callHandlerNoticeFlutterSubmit(
"loadChapterCallBack", "loadChapterCallBack",
[_that.chapter_id, _that.prev_chapter.name] [_that.chapter_id, _that.prev_chapter.name, 'scrollUp']
); );
} else { } else {
$(".prev-chapter").css({ opacity: 0 }); $(".prev-chapter").css({ opacity: 0 });
......
...@@ -648,7 +648,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -648,7 +648,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
} }
// 获取离线数据 // 获取离线数据
void getOffLineInfo() async { void getOffLineInfo({String direction = ''}) async {
Console.log('-chapterId----------------------$chapterId-----------------------------------------'); Console.log('-chapterId----------------------$chapterId-----------------------------------------');
Map<String, dynamic> data = {}; Map<String, dynamic> data = {};
data['chapter_name'] = chapterName; data['chapter_name'] = chapterName;
...@@ -670,7 +670,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -670,7 +670,12 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
String upName = getChapterName(upId); String upName = getChapterName(upId);
upChapter['name'] = upName; upChapter['name'] = upName;
upChapter['id'] = int.parse(upId); upChapter['id'] = int.parse(upId);
String htmlPath = await getLocalReadHtml(upId);
final enCodeContent = await readHtmlFileContent(htmlPath);
String deCodeContent = EncryptUtil.aesDecrypt(enCodeContent!);
upChapter['contents'] = deCodeContent;
data['up_chapter'] = upChapter; data['up_chapter'] = upChapter;
} }
// 5、获取下一章节信息 // 5、获取下一章节信息
Map<String, dynamic> nextChapter = {}; Map<String, dynamic> nextChapter = {};
...@@ -690,6 +695,9 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -690,6 +695,9 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
data['line_list'] = temp['line_list']; data['line_list'] = temp['line_list'];
data['color_line'] = temp['color_line']; data['color_line'] = temp['color_line'];
//
data['direction'] = direction;
// 7、 给前端参数 // 7、 给前端参数
String jsonStr = jsonEncode(data); String jsonStr = jsonEncode(data);
Console.log('callbackInFlutterComponent--------------------------------$jsonStr'); Console.log('callbackInFlutterComponent--------------------------------$jsonStr');
......
...@@ -186,15 +186,19 @@ class _ReadPageState extends State<ReadPage> { ...@@ -186,15 +186,19 @@ class _ReadPageState extends State<ReadPage> {
// 监听 上一节 下一节 // 监听 上一节 下一节
controller.addJavaScriptHandler(handlerName: 'loadChapterCallBack', callback: (args){ controller.addJavaScriptHandler(handlerName: 'loadChapterCallBack', callback: (args){
Console.log('监听 上一节 下一节------------------------------------------------$args');
String chapterId = args.first[0].toString(); String chapterId = args.first[0].toString();
String chapterName = args.first[1].toString(); String chapterName = args.first[1].toString();
ChapterModel chapterModel = ChapterModel(id: int.parse(chapterId), name: chapterName); ChapterModel chapterModel = ChapterModel(id: int.parse(chapterId), name: chapterName);
// readController.setChapterInfo(id: chapterId, name: chapterName ?? ''); // readController.setChapterInfo(id: chapterId, name: chapterName ?? '');
readController.selectChapter(chapterModel); readController.selectChapter(chapterModel);
if(readController.existDownFile && !readController.netStatus){ if(readController.existDownFile && !readController.netStatus){
readController.getOffLineInfo(); String direction = '';
if(args.first.length == 3){
direction = args.first[2].toString();
}
readController.getOffLineInfo(direction: direction);
} }
Console.log('监听 上一节 下一节------------------------------------------------$args');
}); });
// // 监听 双击回调 // // 监听 双击回调
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论