read.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const framework_tools = require("../../framework/tools.js");
  4. const stores_userStatusManager = require("../../stores/userStatusManager.js");
  5. require("../../config/config.js");
  6. require("../../framework/http.js");
  7. require("../../stores/userDataManager.js");
  8. require("../../data/data.js");
  9. require("../../framework/log.js");
  10. if (!Math) {
  11. readPage();
  12. }
  13. const readPage = () => "../../components/read/readPage.js";
  14. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  15. __name: "read",
  16. setup(__props) {
  17. const readPages = common_vendor.ref(null);
  18. let book_data = stores_userStatusManager.UserStatus().getUserSlectBook();
  19. let cur_read_chapter_id = common_vendor.ref(0);
  20. let fontSize = common_vendor.ref(18);
  21. common_vendor.ref(1.8);
  22. common_vendor.ref(["#000", "#666"]);
  23. if (book_data != null) {
  24. initView();
  25. }
  26. let book_text_list = common_vendor.ref([]);
  27. function initView() {
  28. cur_read_chapter_id.value = framework_tools.tools.getChapterReadChapterIdByData(book_data);
  29. framework_tools.tools.getChapterList(book_data.chapter_path, (chapter_ls) => {
  30. draw();
  31. });
  32. }
  33. function draw() {
  34. if (cur_read_chapter_id.value != 0) {
  35. framework_tools.tools.getCurChapterTxt(book_data.base_path, cur_read_chapter_id.value, fontSize.value * 2, (text) => {
  36. book_text_list.value.push(text);
  37. });
  38. }
  39. }
  40. function lower() {
  41. cur_read_chapter_id.value += 1;
  42. draw();
  43. }
  44. function onClickView() {
  45. }
  46. function hideSetting() {
  47. }
  48. common_vendor.onPullDownRefresh(async () => {
  49. showTopLoadingStatus();
  50. });
  51. common_vendor.onReachBottom(async () => {
  52. showBottomLoadingStatus();
  53. });
  54. function showBottomLoadingStatus() {
  55. readPages.value.find((child, index) => {
  56. if (index == book_text_list.value.length - 1) {
  57. child.showBottomLoading();
  58. lower();
  59. }
  60. });
  61. }
  62. function showTopLoadingStatus() {
  63. readPages.value.find((child, index) => {
  64. if (index == 0) {
  65. child.showTopLoading();
  66. }
  67. });
  68. }
  69. return (_ctx, _cache) => {
  70. return {
  71. a: common_vendor.f(common_vendor.unref(book_text_list), (text, index, i0) => {
  72. return {
  73. a: common_vendor.sr(readPages, "509fbf6f-0-" + i0, {
  74. "k": "readPages",
  75. "f": 1
  76. }),
  77. b: index,
  78. c: "509fbf6f-0-" + i0,
  79. d: common_vendor.p({
  80. text_content: text
  81. })
  82. };
  83. }),
  84. b: common_vendor.o(onClickView),
  85. c: common_vendor.o(hideSetting)
  86. };
  87. };
  88. }
  89. });
  90. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "/Users/future/Desktop/项目/uni-xs/xs-app/pages/readbook/read.vue"]]);
  91. tt.createPage(MiniProgramPage);