perf: ⚡ 增强 wd-drop-menu 组件,优化遮罩层闪烁#974
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更新对两个下拉菜单组件进行了调整。对于菜单项组件,修改了模板和脚本,更新了指针事件处理,并移除了模态点击关闭逻辑。对于下拉菜单组件,新增了覆盖层组件,优化了点击事件处理,并引入了新的计算属性和响应式变量以控制覆盖层显示和菜单交互。 Changes
Sequence Diagram(s)sequenceDiagram
participant U as 用户
participant O as wd-overlay
participant DM as wd-drop-menu
U->>O: 点击覆盖层
O->>DM: 触发 handleClickOverlay()
DM->>DM: 检查 closeOnClickModal 条件
DM-->>O: 隐藏覆盖层(若条件满足)
Suggested reviewers
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/uni_modules/wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue (2)
52-56: 建议使用对象形式的样式绑定以提升可维护性
现使用字符串拼接返回内联样式虽能工作,但若样式规则进一步复杂化,后续扩展和可读性可能受影响。可考虑改为返回对象形式的绑定,例如:const modalStyle = computed(() => { return props.direction === 'down' ? { top: `calc(var(--window-top) + ${offset.value}px)`, bottom: 0 } : { top: 0, bottom: `calc(var(--window-bottom) + ${offset.value}px)` } })
102-102: 空函数 noop() 的使用可通过指令修饰符简化
若仅用于阻止事件默认行为,可在模板中使用修饰符@click.prevent.stop等,减少不必要的空函数声明,提高可读性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/uni_modules/wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue(4 hunks)
🔇 Additional comments (6)
src/uni_modules/wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue (6)
2-3: 关于使用 @click.stop.prevent="noop" 的处理需要确认是否符合交互预期
此处通过同时阻止默认事件与冒泡来防止父级处理逻辑,需要确保这不会对用户操作造成意外干扰,比如导致无法滚动、阻断其他交互等。建议在不同终端上测试该修改,以确认是否符合需求。
39-45: 导入新组件及依赖在 <script setup> 场景下可直接使用
在 Vue 3 的<script setup>模式中,可以直接使用导入的组件wdOverlay。目前看来无问题,只需确保所使用的构建工具和环境已正确配置对<script setup>的支持。
62-64: showOverlay 逻辑简洁可读
基于子组件的状态来判断是否显示遮罩层,思路清晰且易于维护。
66-66: 新增 overlayVisible 状态合理
该变量与showOverlay分离,结合定时器实现延迟关闭,可降低界面闪烁问题的发生。此处设计简洁明了。
71-83: 通过 watch + setTimeout 处理遮罩层闪烁逻辑可能带来潜在兼容性问题,需要验证
使用16ms的延时可能仍会在部分终端或慢速设备上出现抖动或无效情况,建议在各端(如微信小程序、支付宝小程序等)进行验证,或考虑使用更稳妥的动画/过渡手段来处理闪烁。
146-153: handleClickOverlay 符合关闭所有打开菜单的需求
在遮罩层被点击时,根据closeOnClickModal判断后关闭所有子菜单项,逻辑清晰且易于理解,对于多菜单联动非常实用。
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
无
💡 需求背景和解决方案
处理切换 drop menu 时,overlay 闪烁问题。

☑️ 请求合并前的自查清单
Summary by CodeRabbit
新增功能
重构