From 7cdae82357aeda45af9a61f0334acb905d035cc0 Mon Sep 17 00:00:00 2001 From: zhangminghao <2275599059@qq.com> Date: Fri, 5 Sep 2025 15:14:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=8F=E9=9D=92=E5=A3=B3=E9=98=85=E8=AF=BB?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=8F=8A=E8=AF=AD=E9=9F=B3=E6=92=AD=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SwipeToNext.vue | 187 ++++++++++++++++ components/SwipeToNext使用文档.md | 293 ++++++++++++++++++++++++++ package-lock.json | 27 ++- pages.json | 60 ++++++ pages/index/readingBody.vue | 1 + project.config.json | 25 +++ project.private.config.json | 14 ++ xqk/chapter1/index.vue | 218 +++++++++++++++++++ xqk/chapter2/index.vue | 216 +++++++++++++++++++ xqk/chapter3/index.vue | 244 +++++++++++++++++++++ xqk/chapter4/index.vue | 132 ++++++++++++ xqk/chapter5/index.vue | 188 +++++++++++++++++ xqk/chapter6/index.vue | 216 +++++++++++++++++++ xqk/chapter7/index.vue | 143 +++++++++++++ xqk/chapter8/index.vue | 75 +++++++ xqk/components/NavMenu.vue | 248 ++++++++++++++++++++++ xqk/components/SinglePlayGif.vue | 95 +++++++++ xqk/home/home.vue | 171 +++++++++++++++ 18 files changed, 2552 insertions(+), 1 deletion(-) create mode 100644 components/SwipeToNext.vue create mode 100644 components/SwipeToNext使用文档.md create mode 100644 project.config.json create mode 100644 project.private.config.json create mode 100644 xqk/chapter1/index.vue create mode 100644 xqk/chapter2/index.vue create mode 100644 xqk/chapter3/index.vue create mode 100644 xqk/chapter4/index.vue create mode 100644 xqk/chapter5/index.vue create mode 100644 xqk/chapter6/index.vue create mode 100644 xqk/chapter7/index.vue create mode 100644 xqk/chapter8/index.vue create mode 100644 xqk/components/NavMenu.vue create mode 100644 xqk/components/SinglePlayGif.vue create mode 100644 xqk/home/home.vue diff --git a/components/SwipeToNext.vue b/components/SwipeToNext.vue new file mode 100644 index 0000000..f918e49 --- /dev/null +++ b/components/SwipeToNext.vue @@ -0,0 +1,187 @@ + + + + + \ No newline at end of file diff --git a/components/SwipeToNext使用文档.md b/components/SwipeToNext使用文档.md new file mode 100644 index 0000000..beb649f --- /dev/null +++ b/components/SwipeToNext使用文档.md @@ -0,0 +1,293 @@ +# SwipeToNext 组件使用文档 + +## 组件介绍 + +`SwipeToNext` 是一个通用的触底跳转组件,封装了手势检测、延迟防抖、提示文字等功能,可以在任何需要滑动跳转的页面中使用。 + +## 组件特性 + +- ✅ 手势滑动检测 +- ✅ 防误触发机制(延迟允许跳转) +- ✅ 可配置的滑动阈值 +- ✅ 自定义提示文字 +- ✅ 支持事件监听 +- ✅ 完全可配置的参数 + +## 使用方法 + +### 1. 引入组件 + +```vue + +``` + +### 2. 基础使用 + +```vue + + + +``` + +### 3. 完整配置使用 + +```vue + +``` + +## Props 参数 + +| 参数名 | 类型 | 默认值 | 必填 | 说明 | +|--------|------|--------|------|------| +| `isLastSlide` | Boolean | `false` | ✅ | 是否在最后一页/最后一个状态 | +| `targetPath` | String | - | ✅ | 跳转的目标路径 | +| `showTip` | Boolean | `true` | ❌ | 是否显示提示文字 | +| `tipText` | String | `'继续向上滑动进入下一章节'` | ❌ | 提示文字内容 | +| `swipeThreshold` | Number | `80` | ❌ | 滑动阈值(像素) | +| `delayTime` | Number | `500` | ❌ | 延迟允许跳转的时间(毫秒) | +| `enableDelay` | Boolean | `true` | ❌ | 是否启用延迟机制 | +| `alwaysEnable` | Boolean | `false` | ❌ | 是否总是启用跳转(忽略isLastSlide状态) | + +## Events 事件 + +| 事件名 | 参数 | 说明 | +|--------|------|------| +| `swipe-to-next` | `targetPath` | 触发跳转时的回调事件 | + +## 使用场景示例 + +### 场景1:图片轮播页面 + +```vue + + + +``` + +### 场景2:文章阅读页面 + +```vue + + + +``` + +### 场景4:单张图片或总是启用触底跳转 + +```vue + + + +``` + +```vue + + + +``` + +## 特殊情况处理 + +### 单张图片问题 + +当只有一张图片时,传统的 `isLastSlide` 逻辑不适用。这时可以使用 `alwaysEnable` 参数: + +```vue + + + + +``` + +### 参数优先级 + +当 `alwaysEnable="true"` 时: +- 忽略 `isLastSlide` 的值 +- 总是显示提示文字 +- 总是允许触底跳转 +- 建议设置 `enableDelay="false"` 以获得更好的响应速度 + + + +1. **确保正确设置 `isLastSlide`**:这是控制是否允许跳转的关键属性 +2. **路径格式**:`targetPath` 需要是有效的 uni-app 路由路径 +3. **性能考虑**:如果不需要延迟机制,可以设置 `enableDelay: false` 来提高响应速度 +4. **样式覆盖**:组件内的提示文字样式可以通过全局样式覆盖 +5. **事件监听**:建议监听 `swipe-to-next` 事件进行数据统计或其他操作 + +## 自定义样式 + +如果需要自定义提示文字的样式,可以在页面中添加: + +```scss +// 覆盖组件样式 +.swipe-to-next .bottom-tip { + bottom: 200rpx !important; // 调整位置 + background: rgba(255, 255, 255, 0.9) !important; // 改变背景色 + + text { + color: #333 !important; // 改变文字颜色 + font-size: 32rpx !important; // 改变字体大小 + } +} +``` + +这个组件极大地简化了触底跳转功能的实现,让你可以专注于业务逻辑而不用重复编写相同的手势检测代码。 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 50708b2..53483a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,33 @@ { "name": "cgc_wechat", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "cgc_wechat", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "moment": "^2.30.1", + "ydui-district": "^1.1.0" + }, + "devDependencies": {} + }, + "node_modules/moment": { + "version": "2.30.1", + "resolved": "https://registry.npmmirror.com/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "engines": { + "node": "*" + } + }, + "node_modules/ydui-district": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/ydui-district/-/ydui-district-1.1.0.tgz", + "integrity": "sha512-MBhvfaR5Gkn6MUmEnrH1A7IFB5igALuDgtIF+gz3dRwNwW9+KOmih7z+xZFfGluMsEbWaT7C3lWOckYsLZQnFg==" + } + }, "dependencies": { "moment": { "version": "2.30.1", diff --git a/pages.json b/pages.json index 303bc79..420a58a 100644 --- a/pages.json +++ b/pages.json @@ -553,6 +553,66 @@ } } ] + }, + { + "root": "xqk", + "pages": [{ + "path": "home/home", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter1/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter2/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter3/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter4/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter5/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter6/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "chapter7/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + } + ] } ], "tabBar": { diff --git a/pages/index/readingBody.vue b/pages/index/readingBody.vue index b31743a..b68e37b 100644 --- a/pages/index/readingBody.vue +++ b/pages/index/readingBody.vue @@ -60,6 +60,7 @@ + diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..3c63362 --- /dev/null +++ b/project.config.json @@ -0,0 +1,25 @@ +{ + "setting": { + "es6": true, + "postcss": true, + "minified": true, + "uglifyFileName": false, + "enhance": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "useCompilerPlugins": false, + "minifyWXML": true + }, + "compileType": "miniprogram", + "simulatorPluginLibVersion": {}, + "packOptions": { + "ignore": [], + "include": [] + }, + "appid": "wx8954209bb3ad489e", + "editorSetting": {} +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..d64d056 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,14 @@ +{ + "libVersion": "3.10.0", + "projectname": "EpicSoul", + "setting": { + "urlCheck": true, + "coverView": true, + "lazyloadPlaceholderEnable": false, + "skylineRenderEnable": false, + "preloadBackgroundData": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/xqk/chapter1/index.vue b/xqk/chapter1/index.vue new file mode 100644 index 0000000..ab3b9f0 --- /dev/null +++ b/xqk/chapter1/index.vue @@ -0,0 +1,218 @@ + + + + + \ No newline at end of file diff --git a/xqk/chapter2/index.vue b/xqk/chapter2/index.vue new file mode 100644 index 0000000..45dc55b --- /dev/null +++ b/xqk/chapter2/index.vue @@ -0,0 +1,216 @@ + + + + + diff --git a/xqk/chapter3/index.vue b/xqk/chapter3/index.vue new file mode 100644 index 0000000..8de0ea1 --- /dev/null +++ b/xqk/chapter3/index.vue @@ -0,0 +1,244 @@ + + + + + diff --git a/xqk/chapter4/index.vue b/xqk/chapter4/index.vue new file mode 100644 index 0000000..e6b4e0e --- /dev/null +++ b/xqk/chapter4/index.vue @@ -0,0 +1,132 @@ + + + + + \ No newline at end of file diff --git a/xqk/chapter5/index.vue b/xqk/chapter5/index.vue new file mode 100644 index 0000000..3c9132d --- /dev/null +++ b/xqk/chapter5/index.vue @@ -0,0 +1,188 @@ + + + + + \ No newline at end of file diff --git a/xqk/chapter6/index.vue b/xqk/chapter6/index.vue new file mode 100644 index 0000000..a9ea516 --- /dev/null +++ b/xqk/chapter6/index.vue @@ -0,0 +1,216 @@ + + + + + \ No newline at end of file diff --git a/xqk/chapter7/index.vue b/xqk/chapter7/index.vue new file mode 100644 index 0000000..5c804af --- /dev/null +++ b/xqk/chapter7/index.vue @@ -0,0 +1,143 @@ + + + + + \ No newline at end of file diff --git a/xqk/chapter8/index.vue b/xqk/chapter8/index.vue new file mode 100644 index 0000000..0b339f9 --- /dev/null +++ b/xqk/chapter8/index.vue @@ -0,0 +1,75 @@ + + + + + \ No newline at end of file diff --git a/xqk/components/NavMenu.vue b/xqk/components/NavMenu.vue new file mode 100644 index 0000000..ac3e469 --- /dev/null +++ b/xqk/components/NavMenu.vue @@ -0,0 +1,248 @@ + + + + + \ No newline at end of file diff --git a/xqk/components/SinglePlayGif.vue b/xqk/components/SinglePlayGif.vue new file mode 100644 index 0000000..a3d56a8 --- /dev/null +++ b/xqk/components/SinglePlayGif.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/xqk/home/home.vue b/xqk/home/home.vue new file mode 100644 index 0000000..3dfbd33 --- /dev/null +++ b/xqk/home/home.vue @@ -0,0 +1,171 @@ + + + + + \ No newline at end of file