reader.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. <template>
  2. <view class="container" :class="{ 'dark-mode': isDarkMode }">
  3. <!-- 顶部导航栏 -->
  4. <view class="header" v-if="showToolbar">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <text class="header-title">{{ bookInfo.title }}</text>
  9. <view class="share-btn" @click="handleShare">
  10. <text class="share-icon">↗</text>
  11. </view>
  12. </view>
  13. <!-- 阅读内容区域 -->
  14. <scroll-view
  15. class="content-area"
  16. scroll-y
  17. @scroll="handleScroll"
  18. @tap="handleContentTap"
  19. >
  20. <!-- 加载中 -->
  21. <view class="loading-section" v-if="isLoading && contentLines.length === 0">
  22. <text class="loading-text">加载中...</text>
  23. </view>
  24. <!-- 章节信息 -->
  25. <view class="chapter-info" v-if="currentChapter && !isLoading">
  26. <text class="chapter-title">{{ currentChapter.title }}</text>
  27. </view>
  28. <!-- 内容 -->
  29. <view class="content-text" :style="{ fontSize: fontSize + 'rpx' }" v-if="!isLoading || contentLines.length > 0">
  30. <view
  31. class="text-line-wrapper"
  32. v-for="(line, index) in contentLines"
  33. :key="index"
  34. @longpress="handleLongPress($event, line, index)"
  35. @touchstart="handleTouchStart"
  36. @touchend="handleTouchEnd"
  37. >
  38. <text class="text-line" :selectable="true">{{ line }}</text>
  39. </view>
  40. </view>
  41. <!-- 空状态 -->
  42. <view class="empty-section" v-if="!isLoading && contentLines.length === 0 && chapterList.length === 0">
  43. <text class="empty-text">暂无章节内容</text>
  44. </view>
  45. </scroll-view>
  46. <!-- 文本选择菜单 -->
  47. <view class="text-selection-menu" v-if="showSelectionMenu" :style="{ top: selectionMenuTop + 'px', left: selectionMenuLeft + 'px' }">
  48. <view class="selection-menu-item" @click="copySelectedText">
  49. <text class="selection-menu-text">复制</text>
  50. </view>
  51. <view class="selection-menu-item" @click="writeNoteFromSelection">
  52. <text class="selection-menu-text">写笔记</text>
  53. </view>
  54. </view>
  55. <!-- 选中文本高亮层 -->
  56. <view class="selection-overlay" v-if="showSelectionMenu" @tap="hideSelectionMenu"></view>
  57. <!-- 悬浮设置面板(随滚动悬浮显示) -->
  58. <view class="floating-settings" v-if="showToolbar" :class="{ 'dark-mode': isDarkMode }">
  59. <view class="floating-item" @click="showChapterList">
  60. <text class="floating-text">目录</text>
  61. </view>
  62. <view class="floating-divider"></view>
  63. <view class="floating-item" @click="showNotes">
  64. <text class="floating-text">笔记</text>
  65. </view>
  66. <view class="floating-divider"></view>
  67. <view class="floating-item" @click="toggleTheme">
  68. <text class="floating-text">夜间</text>
  69. </view>
  70. <view class="floating-divider"></view>
  71. <view class="floating-item" @click="showFontSize">
  72. <text class="floating-text">字号</text>
  73. </view>
  74. </view>
  75. <!-- 目录弹窗 -->
  76. <view class="chapter-modal" v-if="showChapterModal" @tap="closeChapterModal">
  77. <view class="modal-content" :class="{ 'dark-mode': isDarkMode }" @tap.stop>
  78. <view class="modal-header">
  79. <text class="modal-title">目录</text>
  80. <view class="close-btn" @click="closeChapterModal">
  81. <text class="close-icon">×</text>
  82. </view>
  83. </view>
  84. <scroll-view class="chapter-list" scroll-y>
  85. <view
  86. class="chapter-item"
  87. v-for="(chapter, index) in chapterList"
  88. :key="index"
  89. :class="{ active: currentChapter.id === chapter.id }"
  90. @click="selectChapter(chapter)"
  91. >
  92. <text class="chapter-item-title">{{ chapter.title }}</text>
  93. </view>
  94. </scroll-view>
  95. </view>
  96. </view>
  97. <!-- 笔记弹窗 -->
  98. <view class="notes-modal" v-if="showNotesModal" @tap="closeNotesModal">
  99. <view class="modal-content" :class="{ 'dark-mode': isDarkMode }" @tap.stop>
  100. <view class="modal-header">
  101. <text class="modal-title">笔记</text>
  102. <view class="close-btn" @click="closeNotesModal">
  103. <text class="close-icon">×</text>
  104. </view>
  105. </view>
  106. <view class="notes-content">
  107. <view class="add-note-section">
  108. <textarea
  109. class="note-input"
  110. v-model="newNote"
  111. placeholder="添加笔记..."
  112. maxlength="500"
  113. ></textarea>
  114. <button class="add-note-btn" @click="addNote">添加</button>
  115. </view>
  116. <scroll-view class="notes-list" scroll-y>
  117. <view
  118. class="note-item"
  119. v-for="(note, index) in notes"
  120. :key="index"
  121. >
  122. <view class="note-header">
  123. <text class="note-time">{{ note.time }}</text>
  124. <view class="note-delete" @click="deleteNote(index)">
  125. <text class="delete-icon">×</text>
  126. </view>
  127. </view>
  128. <text class="note-content">{{ note.content }}</text>
  129. </view>
  130. <view class="empty-notes" v-if="notes.length === 0">
  131. <text class="empty-text">暂无笔记</text>
  132. </view>
  133. </scroll-view>
  134. </view>
  135. </view>
  136. </view>
  137. <!-- 字号选择弹窗 -->
  138. <view class="fontsize-modal" v-if="showFontSizeModal" @tap="closeFontSizeModal">
  139. <view class="modal-content-small" :class="{ 'dark-mode': isDarkMode }" @tap.stop>
  140. <view class="fontsize-title">字号</view>
  141. <view class="fontsize-options">
  142. <view
  143. class="fontsize-item"
  144. v-for="(size, index) in fontSizeOptions"
  145. :key="index"
  146. :class="{ active: fontSize === size.value }"
  147. @click="selectFontSize(size.value)"
  148. >
  149. <text class="fontsize-label">{{ size.label }}</text>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import { getBookChapters, getBookChapterDetail, getBookById } from '../../utils/api.js'
  158. export default {
  159. data() {
  160. return {
  161. bookInfo: {
  162. id: null,
  163. title: '',
  164. author: '',
  165. image: ''
  166. },
  167. currentChapter: null,
  168. contentLines: [],
  169. chapterList: [],
  170. isLoading: false,
  171. showToolbar: false,
  172. showChapterModal: false,
  173. showNotesModal: false,
  174. showFontSizeModal: false,
  175. isDarkMode: false,
  176. fontSize: 32,
  177. fontSizeOptions: [
  178. { label: '小', value: 28 },
  179. { label: '中', value: 32 },
  180. { label: '大', value: 36 },
  181. { label: '特大', value: 40 }
  182. ],
  183. notes: [],
  184. newNote: '',
  185. showSelectionMenu: false,
  186. selectionMenuTop: 0,
  187. selectionMenuLeft: 0,
  188. selectedText: '',
  189. selectedLine: '',
  190. selectedLineIndex: -1
  191. }
  192. },
  193. onLoad(options) {
  194. if (options.bookId) {
  195. this.bookInfo.id = parseInt(options.bookId)
  196. }
  197. if (options.title) {
  198. this.bookInfo.title = decodeURIComponent(options.title)
  199. }
  200. if (options.image) {
  201. this.bookInfo.image = decodeURIComponent(options.image)
  202. }
  203. if (options.author) {
  204. this.bookInfo.author = decodeURIComponent(options.author)
  205. }
  206. // 加载书籍信息和章节列表
  207. if (this.bookInfo.id) {
  208. this.loadBookInfo()
  209. this.loadChapterList()
  210. }
  211. // 加载阅读进度和设置
  212. this.loadReadingProgress()
  213. this.loadSettings()
  214. this.loadNotes()
  215. },
  216. methods: {
  217. goBack() {
  218. uni.navigateBack()
  219. },
  220. handleShare() {
  221. uni.showToast({
  222. title: '分享功能',
  223. icon: 'none'
  224. })
  225. },
  226. handleContentTap(e) {
  227. // 如果点击的不是选择菜单,则切换工具栏
  228. if (!this.showSelectionMenu) {
  229. this.toggleToolbar()
  230. }
  231. // 隐藏选择菜单
  232. this.hideSelectionMenu()
  233. },
  234. toggleToolbar() {
  235. this.showToolbar = !this.showToolbar
  236. },
  237. handleScroll(e) {
  238. // 滚动时仅隐藏选择菜单,不隐藏悬浮设置面板
  239. if (this.showSelectionMenu) {
  240. this.hideSelectionMenu()
  241. }
  242. },
  243. // 文本选择功能
  244. handleLongPress(e, line, index) {
  245. // 长按文本时显示选择菜单
  246. if (line && line.trim()) {
  247. // 获取触摸位置
  248. const touch = e.touches && e.touches[0] || e.changedTouches && e.changedTouches[0]
  249. if (touch) {
  250. this.selectedText = line
  251. this.selectedLine = line
  252. this.selectedLineIndex = index
  253. // 使用setTimeout确保DOM已更新
  254. setTimeout(() => {
  255. // 计算菜单位置(在触摸点附近)
  256. const query = uni.createSelectorQuery().in(this)
  257. query.select('.content-area').boundingClientRect((rect) => {
  258. if (rect) {
  259. // 计算相对位置
  260. const menuWidth = 200 // 菜单宽度(rpx转px约100px)
  261. const menuHeight = 100 // 菜单高度(rpx转px约50px)
  262. // 确保菜单不超出屏幕
  263. let left = touch.clientX - menuWidth / 2
  264. if (left < 20) left = 20
  265. if (left + menuWidth > rect.width - 20) {
  266. left = rect.width - menuWidth - 20
  267. }
  268. let top = touch.clientY - menuHeight - 20
  269. if (top < rect.top + 20) {
  270. top = touch.clientY + 20
  271. }
  272. this.selectionMenuTop = top
  273. this.selectionMenuLeft = left
  274. this.showSelectionMenu = true
  275. }
  276. }).exec()
  277. }, 50)
  278. }
  279. }
  280. },
  281. handleTouchStart(e) {
  282. // 触摸开始,可以用于记录位置
  283. },
  284. handleTouchEnd(e) {
  285. // 触摸结束
  286. },
  287. hideSelectionMenu() {
  288. this.showSelectionMenu = false
  289. this.selectedText = ''
  290. this.selectedLine = ''
  291. this.selectedLineIndex = -1
  292. },
  293. copySelectedText() {
  294. if (this.selectedText) {
  295. // #ifdef H5
  296. // H5平台使用Clipboard API
  297. if (navigator.clipboard) {
  298. navigator.clipboard.writeText(this.selectedText).then(() => {
  299. uni.showToast({
  300. title: '已复制到剪贴板',
  301. icon: 'success'
  302. })
  303. }).catch(() => {
  304. this.fallbackCopy(this.selectedText)
  305. })
  306. } else {
  307. this.fallbackCopy(this.selectedText)
  308. }
  309. // #endif
  310. // #ifdef APP-PLUS
  311. // App平台
  312. plus.clipboard.setData(this.selectedText, () => {
  313. uni.showToast({
  314. title: '已复制到剪贴板',
  315. icon: 'success'
  316. })
  317. })
  318. // #endif
  319. // #ifdef MP
  320. // 小程序平台
  321. uni.setClipboardData({
  322. data: this.selectedText,
  323. success: () => {
  324. uni.showToast({
  325. title: '已复制到剪贴板',
  326. icon: 'success'
  327. })
  328. }
  329. })
  330. // #endif
  331. this.hideSelectionMenu()
  332. }
  333. },
  334. fallbackCopy(text) {
  335. // 备用复制方法(H5)
  336. const textarea = document.createElement('textarea')
  337. textarea.value = text
  338. textarea.style.position = 'fixed'
  339. textarea.style.opacity = '0'
  340. document.body.appendChild(textarea)
  341. textarea.select()
  342. try {
  343. document.execCommand('copy')
  344. uni.showToast({
  345. title: '已复制到剪贴板',
  346. icon: 'success'
  347. })
  348. } catch (err) {
  349. uni.showToast({
  350. title: '复制失败',
  351. icon: 'none'
  352. })
  353. }
  354. document.body.removeChild(textarea)
  355. },
  356. writeNoteFromSelection() {
  357. // 使用选中的文本作为笔记内容
  358. if (this.selectedText) {
  359. this.newNote = `"${this.selectedText}"`
  360. this.hideSelectionMenu()
  361. this.showNotesModal = true
  362. }
  363. },
  364. // 目录功能
  365. showChapterList() {
  366. this.showChapterModal = true
  367. },
  368. closeChapterModal() {
  369. this.showChapterModal = false
  370. },
  371. selectChapter(chapter) {
  372. this.currentChapter = chapter
  373. this.loadChapterContent(chapter.id)
  374. this.closeChapterModal()
  375. this.showToolbar = false
  376. },
  377. async loadBookInfo() {
  378. if (!this.bookInfo.id) return
  379. try {
  380. const res = await getBookById(this.bookInfo.id)
  381. if (res && res.code === 200 && res.data) {
  382. const book = res.data
  383. this.bookInfo.title = book.title || this.bookInfo.title
  384. this.bookInfo.author = book.author || this.bookInfo.author
  385. this.bookInfo.image = book.image || book.cover || this.bookInfo.image
  386. }
  387. } catch (e) {
  388. console.error('加载书籍信息失败:', e)
  389. }
  390. },
  391. async loadChapterList() {
  392. if (!this.bookInfo.id) return
  393. try {
  394. this.isLoading = true
  395. const res = await getBookChapters(this.bookInfo.id)
  396. if (res && res.code === 200 && res.data) {
  397. this.chapterList = res.data.map(ch => ({
  398. id: ch.id,
  399. title: ch.title,
  400. chapterNumber: ch.chapterNumber
  401. }))
  402. // 如果有章节列表,默认加载第一章
  403. if (this.chapterList.length > 0 && !this.currentChapter) {
  404. this.currentChapter = this.chapterList[0]
  405. this.loadChapterContent(this.currentChapter.id)
  406. }
  407. }
  408. } catch (e) {
  409. console.error('加载章节列表失败:', e)
  410. uni.showToast({
  411. title: '加载章节列表失败',
  412. icon: 'none'
  413. })
  414. } finally {
  415. this.isLoading = false
  416. }
  417. },
  418. async loadChapterContent(chapterId) {
  419. if (!chapterId) return
  420. try {
  421. this.isLoading = true
  422. const res = await getBookChapterDetail(chapterId)
  423. if (res && res.code === 200 && res.data) {
  424. const chapter = res.data
  425. // 更新当前章节信息
  426. this.currentChapter = {
  427. id: chapter.id,
  428. title: chapter.title,
  429. chapterNumber: chapter.chapterNumber
  430. }
  431. // 将内容按行分割(兼容 Windows/Mac 换行)
  432. if (chapter.content && chapter.content.trim()) {
  433. const lines = chapter.content.split(/\r?\n/)
  434. this.contentLines = (lines && lines.length > 0 ? lines : [chapter.content])
  435. } else {
  436. // 内容为空时,使用书籍简介/描述作为兜底
  437. const fallback = (this.bookInfo.introduction || this.bookInfo.desc || this.bookInfo.brief || '').trim()
  438. this.contentLines = fallback ? fallback.split(/\r?\n/) : ['暂无内容']
  439. }
  440. // 保存阅读进度
  441. this.saveReadingProgress()
  442. } else {
  443. uni.showToast({
  444. title: res && res.message ? res.message : '加载章节内容失败',
  445. icon: 'none'
  446. })
  447. }
  448. } catch (e) {
  449. console.error('加载章节内容失败:', e)
  450. uni.showToast({
  451. title: '加载章节内容失败,请重试',
  452. icon: 'none'
  453. })
  454. } finally {
  455. this.isLoading = false
  456. }
  457. },
  458. // 笔记功能
  459. showNotes() {
  460. this.showNotesModal = true
  461. },
  462. closeNotesModal() {
  463. this.showNotesModal = false
  464. this.newNote = ''
  465. },
  466. addNote() {
  467. if (!this.newNote.trim()) {
  468. uni.showToast({
  469. title: '请输入笔记内容',
  470. icon: 'none'
  471. })
  472. return
  473. }
  474. const note = {
  475. content: this.newNote,
  476. time: this.getCurrentTime(),
  477. chapter: this.currentChapter.title
  478. }
  479. this.notes.unshift(note)
  480. this.newNote = ''
  481. this.saveNotes()
  482. uni.showToast({
  483. title: '笔记已添加',
  484. icon: 'success'
  485. })
  486. },
  487. deleteNote(index) {
  488. uni.showModal({
  489. title: '提示',
  490. content: '确定要删除这条笔记吗?',
  491. success: (res) => {
  492. if (res.confirm) {
  493. this.notes.splice(index, 1)
  494. this.saveNotes()
  495. uni.showToast({
  496. title: '已删除',
  497. icon: 'success'
  498. })
  499. }
  500. }
  501. })
  502. },
  503. getCurrentTime() {
  504. const now = new Date()
  505. const month = now.getMonth() + 1
  506. const day = now.getDate()
  507. const hour = now.getHours()
  508. const minute = now.getMinutes()
  509. return `${month}-${day} ${hour}:${minute < 10 ? '0' + minute : minute}`
  510. },
  511. // 夜间模式
  512. toggleTheme() {
  513. this.isDarkMode = !this.isDarkMode
  514. this.saveSettings()
  515. uni.showToast({
  516. title: this.isDarkMode ? '已切换夜间模式' : '已切换日间模式',
  517. icon: 'none',
  518. duration: 1500
  519. })
  520. },
  521. // 字号功能
  522. showFontSize() {
  523. this.showFontSizeModal = true
  524. },
  525. closeFontSizeModal() {
  526. this.showFontSizeModal = false
  527. },
  528. selectFontSize(size) {
  529. this.fontSize = size
  530. this.saveSettings()
  531. this.closeFontSizeModal()
  532. uni.showToast({
  533. title: '字号已调整',
  534. icon: 'success',
  535. duration: 1000
  536. })
  537. },
  538. // 保存和加载设置
  539. loadSettings() {
  540. try {
  541. const settings = uni.getStorageSync(`reading_settings_${this.bookInfo.id}`)
  542. if (settings) {
  543. if (settings.fontSize) this.fontSize = settings.fontSize
  544. if (settings.isDarkMode !== undefined) this.isDarkMode = settings.isDarkMode
  545. }
  546. } catch (e) {
  547. console.error('加载设置失败', e)
  548. }
  549. },
  550. saveSettings() {
  551. try {
  552. uni.setStorageSync(`reading_settings_${this.bookInfo.id}`, {
  553. fontSize: this.fontSize,
  554. isDarkMode: this.isDarkMode
  555. })
  556. } catch (e) {
  557. console.error('保存设置失败', e)
  558. }
  559. },
  560. loadNotes() {
  561. try {
  562. const notes = uni.getStorageSync(`reading_notes_${this.bookInfo.id}`)
  563. if (notes && Array.isArray(notes)) {
  564. this.notes = notes
  565. }
  566. } catch (e) {
  567. console.error('加载笔记失败', e)
  568. }
  569. },
  570. saveNotes() {
  571. try {
  572. uni.setStorageSync(`reading_notes_${this.bookInfo.id}`, this.notes)
  573. } catch (e) {
  574. console.error('保存笔记失败', e)
  575. }
  576. },
  577. loadReadingProgress() {
  578. // 从本地存储或服务器加载阅读进度
  579. try {
  580. const progress = uni.getStorageSync(`reading_progress_${this.bookInfo.id}`)
  581. if (progress) {
  582. if (progress.chapter) this.currentChapter = progress.chapter
  583. }
  584. } catch (e) {
  585. console.error('加载阅读进度失败', e)
  586. }
  587. },
  588. saveReadingProgress() {
  589. // 保存阅读进度
  590. try {
  591. uni.setStorageSync(`reading_progress_${this.bookInfo.id}`, {
  592. chapter: this.currentChapter,
  593. bookId: this.bookInfo.id
  594. })
  595. } catch (e) {
  596. console.error('保存阅读进度失败', e)
  597. }
  598. }
  599. },
  600. onUnload() {
  601. // 页面卸载时保存阅读进度
  602. this.saveReadingProgress()
  603. }
  604. }
  605. </script>
  606. <style scoped>
  607. .container {
  608. width: 100%;
  609. height: 100vh;
  610. background-color: #F5F2E8;
  611. display: flex;
  612. flex-direction: column;
  613. transition: background-color 0.3s;
  614. padding-top: 30px;
  615. box-sizing: border-box;
  616. }
  617. .container.dark-mode {
  618. background-color: #1A1A1A;
  619. }
  620. .header {
  621. display: flex;
  622. align-items: center;
  623. justify-content: space-between;
  624. padding: 20rpx 30rpx;
  625. padding-top: calc(20rpx + env(safe-area-inset-top));
  626. background-color: rgba(245, 242, 232, 0.92);
  627. border-bottom: 1rpx solid rgba(224, 224, 224, 0.6);
  628. position: fixed;
  629. top: 0;
  630. left: 0;
  631. right: 0;
  632. z-index: 1600; /* 高于浮动设置面板,悬浮于内容之上 */
  633. transition: background-color 0.3s, border-color 0.3s;
  634. }
  635. .dark-mode .header {
  636. background-color: rgba(26, 26, 26, 0.92);
  637. border-bottom-color: rgba(51, 51, 51, 0.6);
  638. }
  639. .back-btn, .share-btn {
  640. width: 60rpx;
  641. height: 60rpx;
  642. display: flex;
  643. align-items: center;
  644. justify-content: center;
  645. }
  646. .back-icon, .share-icon {
  647. font-size: 40rpx;
  648. color: #333333;
  649. font-weight: bold;
  650. }
  651. .dark-mode .back-icon,
  652. .dark-mode .share-icon {
  653. color: #FFFFFF;
  654. }
  655. .header-title {
  656. position: absolute;
  657. left: 50%;
  658. transform: translateX(-50%);
  659. font-size: 32rpx;
  660. font-weight: bold;
  661. color: #333333;
  662. }
  663. .dark-mode .header-title {
  664. color: #FFFFFF;
  665. }
  666. .content-area {
  667. flex: 1;
  668. width: 100%;
  669. padding: 40rpx 30rpx;
  670. box-sizing: border-box;
  671. background-color: #F5F2E8;
  672. transition: background-color 0.3s;
  673. }
  674. .dark-mode .content-area {
  675. background-color: #1A1A1A;
  676. }
  677. .loading-section {
  678. padding: 100rpx 30rpx;
  679. text-align: center;
  680. }
  681. .loading-text {
  682. font-size: 28rpx;
  683. color: #999999;
  684. }
  685. .empty-section {
  686. padding: 100rpx 30rpx;
  687. text-align: center;
  688. }
  689. .empty-section .empty-text {
  690. font-size: 28rpx;
  691. color: #999999;
  692. }
  693. .chapter-info {
  694. margin-bottom: 40rpx;
  695. text-align: center;
  696. }
  697. .chapter-title {
  698. font-size: 36rpx;
  699. font-weight: bold;
  700. color: #333333;
  701. }
  702. .dark-mode .chapter-title {
  703. color: #FFFFFF;
  704. }
  705. .content-text {
  706. display: flex;
  707. flex-direction: column;
  708. line-height: 2.2;
  709. background-color: transparent;
  710. }
  711. .text-line-wrapper {
  712. margin-bottom: 20rpx;
  713. background-color: transparent;
  714. }
  715. .text-line {
  716. color: #333333;
  717. text-indent: 2em;
  718. line-height: 2.2;
  719. display: block;
  720. background-color: transparent;
  721. }
  722. .dark-mode .text-line {
  723. color: #E0E0E0;
  724. }
  725. .bottom-toolbar {
  726. display: flex;
  727. justify-content: space-around;
  728. align-items: center;
  729. padding: 30rpx 20rpx;
  730. background-color: #F5F2E8;
  731. border-top: 1rpx solid #E0E0E0;
  732. padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
  733. position: relative;
  734. z-index: 100;
  735. transition: background-color 0.3s, border-color 0.3s;
  736. }
  737. .dark-mode .bottom-toolbar {
  738. background-color: #1A1A1A;
  739. border-top-color: #333333;
  740. }
  741. .toolbar-item {
  742. display: flex;
  743. flex-direction: column;
  744. align-items: center;
  745. justify-content: center;
  746. padding: 10rpx 20rpx;
  747. }
  748. .toolbar-text {
  749. font-size: 28rpx;
  750. color: #333333;
  751. }
  752. .dark-mode .toolbar-text {
  753. color: #FFFFFF;
  754. }
  755. /* 悬浮设置面板 */
  756. .floating-settings {
  757. position: fixed;
  758. left: 50%;
  759. bottom: calc(30rpx + env(safe-area-inset-bottom));
  760. transform: translateX(-50%);
  761. display: flex;
  762. align-items: center;
  763. justify-content: center;
  764. padding: 14rpx 20rpx;
  765. background: rgba(255, 255, 255, 0.9);
  766. backdrop-filter: blur(6px);
  767. border-radius: 40rpx;
  768. box-shadow: 0 8rpx 24rpx rgba(0,0,0,0.15);
  769. z-index: 1500;
  770. }
  771. .floating-settings.dark-mode {
  772. background: rgba(42, 42, 42, 0.9);
  773. }
  774. .floating-item {
  775. padding: 10rpx 24rpx;
  776. }
  777. .floating-text {
  778. font-size: 28rpx;
  779. color: #333333;
  780. }
  781. .floating-settings.dark-mode .floating-text {
  782. color: #FFFFFF;
  783. }
  784. .floating-divider {
  785. width: 1rpx;
  786. height: 28rpx;
  787. background-color: rgba(0,0,0,0.08);
  788. margin: 0 6rpx;
  789. }
  790. .floating-settings.dark-mode .floating-divider {
  791. background-color: rgba(255,255,255,0.15);
  792. }
  793. /* 目录弹窗 */
  794. .chapter-modal {
  795. position: fixed;
  796. top: 0;
  797. left: 0;
  798. right: 0;
  799. bottom: 0;
  800. background-color: rgba(0, 0, 0, 0.5);
  801. z-index: 1000;
  802. display: flex;
  803. align-items: flex-end;
  804. }
  805. .modal-content {
  806. width: 100%;
  807. height: 70%;
  808. background-color: #FFFFFF;
  809. border-radius: 30rpx 30rpx 0 0;
  810. display: flex;
  811. flex-direction: column;
  812. padding-bottom: env(safe-area-inset-bottom);
  813. transition: background-color 0.3s;
  814. }
  815. .modal-content.dark-mode {
  816. background-color: #2A2A2A;
  817. }
  818. .modal-header {
  819. display: flex;
  820. align-items: center;
  821. justify-content: space-between;
  822. padding: 30rpx;
  823. border-bottom: 1rpx solid #E0E0E0;
  824. transition: border-color 0.3s;
  825. }
  826. .modal-content.dark-mode .modal-header,
  827. .modal-content-small.dark-mode .modal-header {
  828. border-bottom-color: #333333;
  829. }
  830. .modal-title {
  831. font-size: 36rpx;
  832. font-weight: bold;
  833. color: #333333;
  834. transition: color 0.3s;
  835. }
  836. .modal-content.dark-mode .modal-title,
  837. .modal-content-small.dark-mode .modal-title {
  838. color: #FFFFFF;
  839. }
  840. .close-btn {
  841. width: 60rpx;
  842. height: 60rpx;
  843. display: flex;
  844. align-items: center;
  845. justify-content: center;
  846. }
  847. .close-icon {
  848. font-size: 50rpx;
  849. color: #666666;
  850. line-height: 1;
  851. transition: color 0.3s;
  852. }
  853. .modal-content.dark-mode .close-icon,
  854. .modal-content-small.dark-mode .close-icon {
  855. color: #CCCCCC;
  856. }
  857. .chapter-list {
  858. flex: 1;
  859. width: 100%;
  860. padding: 20rpx 0;
  861. }
  862. .chapter-item {
  863. padding: 25rpx 30rpx;
  864. border-bottom: 1rpx solid #F0F0F0;
  865. transition: background-color 0.3s, border-color 0.3s;
  866. }
  867. .modal-content.dark-mode .chapter-item {
  868. border-bottom-color: #333333;
  869. }
  870. .chapter-item.active {
  871. background-color: #F5F5F5;
  872. }
  873. .modal-content.dark-mode .chapter-item.active {
  874. background-color: #333333;
  875. }
  876. .chapter-item-title {
  877. font-size: 30rpx;
  878. color: #333333;
  879. transition: color 0.3s;
  880. }
  881. .modal-content.dark-mode .chapter-item-title {
  882. color: #FFFFFF;
  883. }
  884. /* 笔记弹窗 */
  885. .notes-modal {
  886. position: fixed;
  887. top: 0;
  888. left: 0;
  889. right: 0;
  890. bottom: 0;
  891. background-color: rgba(0, 0, 0, 0.5);
  892. z-index: 1000;
  893. display: flex;
  894. align-items: flex-end;
  895. }
  896. .notes-content {
  897. flex: 1;
  898. display: flex;
  899. flex-direction: column;
  900. padding: 20rpx 30rpx;
  901. }
  902. .add-note-section {
  903. display: flex;
  904. flex-direction: column;
  905. margin-bottom: 30rpx;
  906. }
  907. .note-input {
  908. width: 100%;
  909. min-height: 200rpx;
  910. padding: 20rpx;
  911. background-color: #F5F5F5;
  912. border-radius: 10rpx;
  913. font-size: 28rpx;
  914. color: #333333;
  915. margin-bottom: 20rpx;
  916. box-sizing: border-box;
  917. transition: background-color 0.3s, color 0.3s;
  918. }
  919. .modal-content.dark-mode .note-input {
  920. background-color: #333333;
  921. color: #FFFFFF;
  922. }
  923. .modal-content.dark-mode .note-input::placeholder {
  924. color: #999999;
  925. }
  926. .add-note-btn {
  927. width: 100%;
  928. height: 80rpx;
  929. background-color: #4FC3F7;
  930. color: #FFFFFF;
  931. border-radius: 10rpx;
  932. font-size: 30rpx;
  933. display: flex;
  934. align-items: center;
  935. justify-content: center;
  936. border: none;
  937. }
  938. .notes-list {
  939. flex: 1;
  940. width: 100%;
  941. }
  942. .note-item {
  943. padding: 25rpx;
  944. background-color: #F5F5F5;
  945. border-radius: 10rpx;
  946. margin-bottom: 20rpx;
  947. transition: background-color 0.3s;
  948. }
  949. .modal-content.dark-mode .note-item {
  950. background-color: #333333;
  951. }
  952. .note-header {
  953. display: flex;
  954. align-items: center;
  955. justify-content: space-between;
  956. margin-bottom: 15rpx;
  957. }
  958. .note-time {
  959. font-size: 24rpx;
  960. color: #999999;
  961. transition: color 0.3s;
  962. }
  963. .modal-content.dark-mode .note-time {
  964. color: #888888;
  965. }
  966. .note-delete {
  967. width: 40rpx;
  968. height: 40rpx;
  969. display: flex;
  970. align-items: center;
  971. justify-content: center;
  972. }
  973. .delete-icon {
  974. font-size: 40rpx;
  975. color: #FF4444;
  976. line-height: 1;
  977. }
  978. .note-content {
  979. font-size: 28rpx;
  980. color: #333333;
  981. line-height: 1.8;
  982. transition: color 0.3s;
  983. }
  984. .modal-content.dark-mode .note-content {
  985. color: #FFFFFF;
  986. }
  987. .empty-notes {
  988. display: flex;
  989. justify-content: center;
  990. align-items: center;
  991. padding: 100rpx 0;
  992. }
  993. .empty-text {
  994. font-size: 28rpx;
  995. color: #999999;
  996. transition: color 0.3s;
  997. }
  998. .modal-content.dark-mode .empty-text {
  999. color: #666666;
  1000. }
  1001. /* 字号选择弹窗 */
  1002. .fontsize-modal {
  1003. position: fixed;
  1004. top: 0;
  1005. left: 0;
  1006. right: 0;
  1007. bottom: 0;
  1008. background-color: rgba(0, 0, 0, 0.5);
  1009. z-index: 1000;
  1010. display: flex;
  1011. align-items: center;
  1012. justify-content: center;
  1013. }
  1014. .modal-content-small {
  1015. width: 500rpx;
  1016. background-color: #FFFFFF;
  1017. border-radius: 20rpx;
  1018. padding: 40rpx;
  1019. box-sizing: border-box;
  1020. transition: background-color 0.3s;
  1021. }
  1022. .modal-content-small.dark-mode {
  1023. background-color: #2A2A2A;
  1024. }
  1025. .fontsize-title {
  1026. font-size: 32rpx;
  1027. font-weight: bold;
  1028. color: #333333;
  1029. text-align: center;
  1030. margin-bottom: 30rpx;
  1031. transition: color 0.3s;
  1032. }
  1033. .modal-content-small.dark-mode .fontsize-title {
  1034. color: #FFFFFF;
  1035. }
  1036. .fontsize-options {
  1037. display: flex;
  1038. flex-direction: column;
  1039. }
  1040. .fontsize-item {
  1041. padding: 25rpx;
  1042. border-bottom: 1rpx solid #F0F0F0;
  1043. text-align: center;
  1044. transition: background-color 0.3s, border-color 0.3s;
  1045. }
  1046. .modal-content-small.dark-mode .fontsize-item {
  1047. border-bottom-color: #333333;
  1048. }
  1049. .fontsize-item:last-child {
  1050. border-bottom: none;
  1051. }
  1052. .fontsize-item.active {
  1053. background-color: #F5F5F5;
  1054. }
  1055. .modal-content-small.dark-mode .fontsize-item.active {
  1056. background-color: #333333;
  1057. }
  1058. .fontsize-label {
  1059. font-size: 30rpx;
  1060. color: #333333;
  1061. transition: color 0.3s;
  1062. }
  1063. .modal-content-small.dark-mode .fontsize-label {
  1064. color: #FFFFFF;
  1065. }
  1066. /* 文本选择菜单 */
  1067. .text-selection-menu {
  1068. position: fixed;
  1069. background-color: #333333;
  1070. border-radius: 8rpx;
  1071. padding: 0;
  1072. z-index: 2000;
  1073. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.3);
  1074. min-width: 200rpx;
  1075. }
  1076. .selection-menu-item {
  1077. padding: 20rpx 30rpx;
  1078. border-bottom: 1rpx solid #444444;
  1079. }
  1080. .selection-menu-item:last-child {
  1081. border-bottom: none;
  1082. }
  1083. .selection-menu-item:active {
  1084. background-color: #444444;
  1085. }
  1086. .selection-menu-text {
  1087. font-size: 28rpx;
  1088. color: #FFFFFF;
  1089. }
  1090. /* 选中文本高亮层 */
  1091. .selection-overlay {
  1092. position: fixed;
  1093. top: 0;
  1094. left: 0;
  1095. right: 0;
  1096. bottom: 0;
  1097. z-index: 1999;
  1098. background-color: transparent;
  1099. }
  1100. </style>