From e39f47855bc4f6c250acc1d3529b19e079045fe7 Mon Sep 17 00:00:00 2001 From: chenghuan Date: Mon, 10 Nov 2025 17:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E2=80=9C=E5=9B=BE=E4=B9=A6=E9=A6=96=E9=A1=B5=E2=80=9D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 2 +- api/modules/home.ts | 105 ++++ components/book/BookCardIndex.vue | 178 +++++++ components/nav-bar/nav-bar.vue | 6 +- locale/en.json | 14 +- locale/zh-Hans.json | 14 +- manifest.json | 10 +- package.json | 4 +- pages.json | 6 + pages/book/README.md | 207 -------- pages/book/index.vue | 844 +++++++++++++++++++++++++++++- pages/book/reader.vue | 28 +- pages/book/search.vue | 293 +++++++++++ pages/index/index.vue | 2 +- pages/login/README.md | 163 ------ style/tailwind.css | 60 ++- tailwind.config.js | 55 +- types/book.d.ts | 73 +++ 18 files changed, 1634 insertions(+), 430 deletions(-) create mode 100644 api/modules/home.ts create mode 100644 components/book/BookCardIndex.vue delete mode 100644 pages/book/README.md create mode 100644 pages/book/search.vue delete mode 100644 pages/login/README.md diff --git a/App.vue b/App.vue index 82ff1a6..8281a62 100644 --- a/App.vue +++ b/App.vue @@ -13,7 +13,7 @@ diff --git a/components/nav-bar/nav-bar.vue b/components/nav-bar/nav-bar.vue index c0c3de0..7106200 100644 --- a/components/nav-bar/nav-bar.vue +++ b/components/nav-bar/nav-bar.vue @@ -2,7 +2,11 @@ - + + + diff --git a/locale/en.json b/locale/en.json index 6133184..4c1de75 100644 --- a/locale/en.json +++ b/locale/en.json @@ -10,7 +10,10 @@ "close": "Close", "confirm": "Confirm", "loading": "Loading", - "tips": "Tips" + "tips": "Tips", + "searchNoResult": "No search results found", + "more": "More", + "dataNull": "No data available" }, "tabar.course": "COURSE", "tabar.book": "EBOOK", @@ -19,7 +22,7 @@ "title": "Taimed International", "schema": "Schema", "demo": "uni-app globalization", - "demo-description": "Include uni-framework, manifest.json, pages.json, tabbar, Page, Component, API, Schema", + "demoDescription": "Include uni-framework, manifest.json, pages.json, tabbar, Page, Component, API, Schema", "detail": "Detail", "language": "Language", "language-info": "Settings", @@ -250,9 +253,14 @@ "deleteSuccess": "Deleted" }, "home": { + "block1": "My Books", + "block2": "Recommended", + "more": "More", + "activityTitle": "Featured Books", "readingCount": " reads", "listenCount": " listens", - "purchased": " purchased" + "purchased": " purchased", + "searchPlaceholder": "Search books..." }, "listen": { "title": "Audio Book", diff --git a/locale/zh-Hans.json b/locale/zh-Hans.json index 8dd831c..31bdba5 100644 --- a/locale/zh-Hans.json +++ b/locale/zh-Hans.json @@ -10,7 +10,10 @@ "close": "关闭", "confirm": "确认", "loading": "加载中", - "tips": "提示" + "tips": "提示", + "searchNoResult": "暂无搜索结果", + "more": "更多", + "dataNull": "暂无数据" }, "tabar.course": "课程", "tabar.book": "图书", @@ -19,7 +22,7 @@ "title": "太湖国际", "schema": "Schema", "demo": "uni-app 国际化演示", - "demo-description": "包含 uni-framework、manifest.json、pages.json、tabbar、页面、组件、API、Schema", + "demoDescription": "包含 uni-framework、manifest.json、pages.json、tabbar、页面、组件、API、Schema", "detail": "详情", "language": "语言", "language-info": "语言信息", @@ -251,9 +254,14 @@ "deleteSuccess": "删除成功" }, "home": { + "block1": "我的书单", + "block2": "推荐图书", + "more": "更多", + "activityTitle": "活动图书", "readingCount": "次阅读", "listenCount": "次听书", - "purchased": "人购买" + "purchased": "人购买", + "searchPlaceholder": "搜索图书..." }, "listen": { "title": "听书", diff --git a/manifest.json b/manifest.json index a9f429b..dcf0c1b 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "appid" : "__UNI__1250B39", "description" : "", "versionName" : "1.0.1", - "versionCode" : "100", + "versionCode" : 101, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { @@ -38,10 +38,14 @@ "", "", "" - ] + ], + "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], + "minSdkVersion" : 21 }, /* ios打包配置 */ - "ios" : {}, + "ios" : { + "dSYMs" : false + }, /* SDK配置 */ "sdkConfigs" : {} } diff --git a/package.json b/package.json index 9d7b1df..e40383c 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "中医学 国学 心理学" ], "scripts": { - "tailwind-dev": "npx @tailwindcss/cli -i ./tailwind-input.css -o ./static/tailwind.css --watch", - "tailwind-build": "npx @tailwindcss/cli -i ./tailwind-input.css -o ./static/tailwind.css" + "tailwind-dev": "npx @tailwindcss/cli -i ./tailwind-input.css -o ./style/tailwind.css --watch", + "tailwind-build": "npx @tailwindcss/cli -i ./tailwind-input.css -o ./style/tailwind.css" }, "dcloudext": { "sale": { diff --git a/pages.json b/pages.json index a2e20b6..0b9760f 100644 --- a/pages.json +++ b/pages.json @@ -103,6 +103,12 @@ "navigationStyle": "custom", "navigationBarTitleText": "%book.read%" } + }, { + "path": "pages/book/search", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "%home.searchPlaceholder%" + } }, { "path": "pages/book/listen/index", "style": { diff --git a/pages/book/README.md b/pages/book/README.md deleted file mode 100644 index 1248394..0000000 --- a/pages/book/README.md +++ /dev/null @@ -1,207 +0,0 @@ -# 我的书单功能模块 - -## 概述 - -本模块是从nuttyreading项目迁移并升级到Vue3+TypeScript+Pinia+TailwindCSS+WotUI+i18n技术栈的"我的书单"功能。 - -## 功能列表 - -### 1. 书单列表 (`pages/book/index.vue`) -- ✅ 显示用户已购买的所有书籍 -- ✅ 分页加载 -- ✅ 空状态处理 -- ✅ 支持跳转到详情、阅读器、听书、书评页面 -- ✅ iOS平台自动隐藏书评按钮 - -### 2. 书籍详情 (`pages/book/detail.vue`) -- ✅ 显示书籍封面、标题、作者、简介 -- ✅ 显示阅读数、听书数、购买数统计 -- ✅ 显示前2条书评(非iOS) -- ✅ 显示相关推荐书籍 -- ✅ 根据购买状态显示不同操作按钮 -- ✅ 购买弹窗 - -### 3. 书评系统 (`pages/book/review.vue`) -- ✅ 评论列表展示 -- ✅ 发表评论(富文本编辑器) -- ✅ 点赞/取消点赞 -- ✅ 回复评论 -- ✅ 删除评论 -- ✅ 分页加载更多 -- ✅ Emoji支持(待完善) - -### 4. 阅读器 (`pages/book/reader.vue`) -- ✅ 上下滚动模式 -- ✅ 左右翻页模式 -- ✅ 字体大小调节(8个级别) -- ✅ 主题切换(5种主题) -- ✅ 章节目录 -- ✅ 阅读进度保存和恢复 -- ✅ 图片内容显示 -- ✅ 试读限制提示 - -### 5. 听书功能 -#### 章节列表 (`pages/book/listen/index.vue`) -- ✅ 显示书籍信息 -- ✅ 章节列表 -- ✅ 章节锁定状态 -- ✅ 音频文件检查 - -#### 音频播放器 (`pages/book/listen/player.vue`) -- ✅ 音频播放/暂停 -- ✅ 进度条控制 -- ✅ 快进/快退(15秒) -- ✅ 上一章/下一章 -- ✅ 播放速度调节(0.5x - 2x) -- ✅ 自动播放下一章 -- ✅ 封面旋转动画 - -## 技术栈 - -- **框架**: Vue3 Composition API -- **语言**: TypeScript -- **状态管理**: Pinia -- **UI组件**: WotUI -- **样式**: SCSS + TailwindCSS -- **国际化**: vue-i18n - -## 文件结构 - -``` -pages/book/ -├── index.vue # 书单列表 -├── detail.vue # 书籍详情 -├── review.vue # 书评页面 -├── reader.vue # 阅读器 -└── listen/ - ├── index.vue # 听书章节列表 - └── player.vue # 音频播放器 - -components/book/ -├── CustomNavbar.vue # 自定义导航栏 -├── BookCard.vue # 书籍卡片 -└── CommentList.vue # 评论列表 - -api/modules/ -└── book.ts # 书籍API - -stores/ -└── book.ts # 书籍状态管理 - -types/ -└── book.d.ts # 类型定义 -``` - -## API接口 - -所有API接口保持与原项目完全一致: - -- `bookAbroad/home/getbooks` - 获取我的书单 -- `bookAbroad/home/getBookInfo` - 获取书籍详情 -- `bookAbroad/home/getBookReadCount` - 获取统计数据 -- `bookAbroad/home/getRecommendBook` - 获取推荐书籍 -- `bookAbroad/getBookAbroadCommentTree` - 获取评论列表 -- `bookAbroad/insertBookAbroadComment` - 发表评论 -- `bookAbroad/insertBookAbroadCommentLike` - 点赞 -- `bookAbroad/delBookAbroadCommentLike` - 取消点赞 -- `bookAbroad/delBookAbroadComment` - 删除评论 -- `bookAbroad/home/getBookChapter` - 获取章节列表 -- `bookAbroad/home/getBookChapterContent` - 获取章节内容 -- `bookAbroad/home/getBookReadRate` - 获取阅读进度 -- `bookAbroad/home/insertBookReadRate` - 保存阅读进度 - -## 国际化 - -支持中文和英文两种语言,所有文本通过i18n配置管理。 - -### 翻译键 -- `book.*` - 书单相关 -- `details.*` - 详情相关 -- `listen.*` - 听书相关 -- `common.*` - 通用文本 - -## 平台适配 - -### iOS特殊处理 -- 书评功能在iOS平台自动隐藏 -- 使用条件编译 `#ifdef APP-PLUS` 判断平台 - -### 刘海屏适配 -- 所有页面自动适配状态栏高度 -- 使用 `uni.getSystemInfoSync().safeArea` 获取安全区域 - -## 使用说明 - -### 1. 从书单列表进入 -```typescript -uni.navigateTo({ - url: '/pages/book/index' -}) -``` - -### 2. 直接进入书籍详情 -```typescript -uni.navigateTo({ - url: `/pages/book/detail?id=${bookId}` -}) -``` - -### 3. 进入阅读器 -```typescript -// 已购买 -uni.navigateTo({ - url: `/pages/book/reader?isBuy=0&bookId=${bookId}` -}) - -// 试读 -uni.navigateTo({ - url: `/pages/book/reader?isBuy=1&bookId=${bookId}&count=${freeChapterCount}` -}) -``` - -### 4. 进入听书 -```typescript -uni.navigateTo({ - url: `/pages/book/listen/index?bookId=${bookId}` -}) -``` - -## 注意事项 - -1. **不要修改API接口**:所有接口地址和参数必须与原项目保持一致 -2. **UI组件使用WotUI**:不要使用uView或uni-ui组件 -3. **国际化文本**:所有文本必须通过i18n配置,不能硬编码 -4. **iOS平台**:注意书评功能的隐藏处理 -5. **类型安全**:充分利用TypeScript类型检查 - -## 待优化项 - -1. Emoji选择器组件需要集成完整的Emoji库 -2. 阅读器可以添加更多主题 -3. 音频播放器可以添加播放列表功能 -4. 可以添加书签功能 -5. 可以添加笔记功能 - -## 测试清单 - -- [ ] 书单列表加载和分页 -- [ ] 书籍详情所有信息显示 -- [ ] 书评发表、点赞、删除 -- [ ] 阅读器两种模式切换 -- [ ] 阅读器字体和主题设置 -- [ ] 阅读进度保存和恢复 -- [ ] 听书播放控制 -- [ ] 听书速度调节 -- [ ] iOS平台书评隐藏 -- [ ] 试读/试听限制 -- [ ] 国际化文本切换 - -## 更新日志 - -### v1.0.0 (2024-01-XX) -- ✅ 完成从Vue2到Vue3的迁移 -- ✅ 完成TypeScript类型定义 -- ✅ 完成Pinia状态管理 -- ✅ 完成WotUI组件替换 -- ✅ 完成国际化配置 -- ✅ 完成所有功能页面 diff --git a/pages/book/index.vue b/pages/book/index.vue index 1da8775..0d7b8d7 100644 --- a/pages/book/index.vue +++ b/pages/book/index.vue @@ -1,24 +1,844 @@ - diff --git a/pages/book/reader.vue b/pages/book/reader.vue index dc07b6a..bbd1386 100644 --- a/pages/book/reader.vue +++ b/pages/book/reader.vue @@ -99,6 +99,8 @@ + + @@ -108,7 +110,7 @@ {{ $t('book.language') }} - + {{ lang.language }} @@ -162,10 +164,9 @@ - - - + + @@ -407,7 +408,7 @@ async function loadChapterContent(chapterId: number, index: number) { } // 切换章节 -function switchChapter(chapter: IChapter, index: number) { +async function switchChapter(chapter: IChapter, index: number) { if (isLocked(index)) { uni.showToast({ title: t('book.afterPurchase'), @@ -416,7 +417,8 @@ function switchChapter(chapter: IChapter, index: number) { return } - loadChapterContent(chapter.id, index) + await loadChapterContent(chapter.id, index) + showControls.value = false } // 判断章节是否锁定 @@ -796,6 +798,10 @@ function goBack() { .setting-item { margin-bottom: 40rpx; + + &:last-child { + margin-bottom: 0; + } .setting-label { display: block; @@ -866,11 +872,6 @@ function goBack() { } } } - - /* 底部占位 */ - .setting-ooter-placeholder { - height: 80rpx; - } } .empty-state { @@ -884,5 +885,10 @@ function goBack() { color: #999; } } + + /* 底部占位 */ + .setting-ooter-placeholder { + height: 55px; + } } diff --git a/pages/book/search.vue b/pages/book/search.vue new file mode 100644 index 0000000..438d247 --- /dev/null +++ b/pages/book/search.vue @@ -0,0 +1,293 @@ + + + + + diff --git a/pages/index/index.vue b/pages/index/index.vue index 6feac22..442b6ec 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,6 +1,6 @@