read.js 2.7 KB

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