Conversation
|
@cnguu is attempting to deploy a commit to the weisheng's projects Team on Vercel. A member of the Team first needs to authorize it. |
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Walkthrough此 PR 为弹窗(wd-popup)、选择器和日期时间选择器增加返回键(backpress)处理,新增组合式函数 useTimeout、useTopPopup 及工具函数 uniqID,用于弹窗栈管理、延时可视状态与唯一 ID 生成,并扩展相关文档与导出。 Changes
Sequence Diagram(s)sequenceDiagram
participant User as 用户 (按返回键)
participant Popup as wd-popup 组件
participant UseTopPopup as useTopPopup (栈管理)
participant UseTimeout as useTimeout (延迟可视)
participant Emitter as 事件发射/父组件
User->>Popup: 按下返回键
Popup->>UseTopPopup: 查询 isTopPopup
alt 是顶层弹窗
Popup->>UseTimeout: 启动 50ms 延时
UseTimeout-->>Popup: 将 backpressVisible 置 true
Popup->>Emitter: emit('backpress')
alt backpress == 'close'
Emitter->>Popup: 触发 onCancel / 关闭
else backpress == 'stop'
Popup->>Popup: 切换可见性 (toggle)
else backpress == 'back'
Popup->>Platform: 平台默认返回处理(不额外关闭)
end
else 非顶层弹窗
Popup->>Popup: 忽略返回键处理
end
Estimated code review effort🎯 3 (中等) | ⏱️ ~20 分钟 Possibly related PRs
Suggested reviewers
诗
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/uni_modules/wot-design-uni/components/composables/useTimeout.ts`:
- Around line 27-38: The immediate callback path in start currently calls cb()
without forwarding the provided arguments, causing inconsistent behavior vs the
delayed path which uses cb(...args); update start so that when immediateCb is
truthy it calls cb(...args) instead of cb(), ensuring the same
Parameters<CallbackFn> are passed for both immediate and delayed executions
(refer to the start function, immediateCb flag, cb callback, and the args rest
parameter).
In `@src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts`:
- Around line 4-5: The module calls uni.getAppBaseInfo() at top-level (isApp)
causing tests to fail when uni isn't mocked; change to a lazy/safe accessor:
remove the top-level isApp usage, add a function getIsApp() that checks uni and
uni.getAppBaseInfo existence before calling and returns a boolean, and update
callers to use getIsApp() (specifically replace uses of isApp inside
handlePopupHide with getIsApp()). Ensure the new function is exported/available
where needed and avoid any top-level invocation of uni.getAppBaseInfo.
🧹 Nitpick comments (3)
src/uni_modules/wot-design-uni/components/common/util.ts (1)
233-235: 唯一ID生成逻辑正确。使用随机数和递增计数器组合生成唯一ID的方式是可靠的。
~~是位运算截断,功能正确,但可读性稍差。考虑使用
Math.floor()提高可读性(可选):♻️ 可选的可读性改进
export function uniqID(prefix = '__wot_'): string { - return prefix + (~~(Math.random() * 10e8)).toString(36) + '-' + (++context.id).toString(36) + return prefix + Math.floor(Math.random() * 10e8).toString(36) + '-' + (++context.id).toString(36) }src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts (1)
20-28: 页面弹窗栈缺少清理机制
pagePopupStacks记录每个页面的弹窗栈,但当页面销毁时,对应的栈条目不会被清理,可能导致内存逐渐增长。可以考虑在页面卸载时清理对应的栈条目,或者使用
WeakMap(如果适用)来自动管理生命周期。src/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue (1)
193-203: 建议统一使用useTimeout替代原生setTimeout
onBackpressBeforeLeave中使用了原生setTimeout,但文件中已导入并使用了useTimeout组合式函数。建议统一使用useTimeout以保持代码一致性,并获得更好的清理管理。♻️ 建议修改
+const { start: resetBackpressVisible } = useTimeout(() => { + backpressVisible.value = true +}, 50) + const onBackpressBeforeLeave = () => { emit('backpress') if (props.backpress === 'stop') { backpressVisible.value = false - setTimeout(() => { - backpressVisible.value = true - }, 50) + resetBackpressVisible() } else { close() } }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/uni_modules/wot-design-uni/components/common/util.tssrc/uni_modules/wot-design-uni/components/composables/index.tssrc/uni_modules/wot-design-uni/components/composables/useTimeout.tssrc/uni_modules/wot-design-uni/components/composables/useTopPopup.tssrc/uni_modules/wot-design-uni/components/wd-datetime-picker/types.tssrc/uni_modules/wot-design-uni/components/wd-datetime-picker/wd-datetime-picker.vuesrc/uni_modules/wot-design-uni/components/wd-picker/types.tssrc/uni_modules/wot-design-uni/components/wd-picker/wd-picker.vuesrc/uni_modules/wot-design-uni/components/wd-popup/types.tssrc/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-02-20T05:57:28.165Z
Learnt from: chen-ziwen
Repo: Moonofweisheng/wot-design-uni PR: 909
File: src/uni_modules/wot-design-uni/components/wd-input-number/wd-input-number.vue:276-281
Timestamp: 2025-02-20T05:57:28.165Z
Learning: In Vue components, cleanup of one-time timers (setTimeout) during component unmount is optional as they will be automatically cleaned up by the garbage collector. Prefer simpler code unless explicit cleanup is necessary.
Applied to files:
src/uni_modules/wot-design-uni/components/composables/useTimeout.tssrc/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。
Applied to files:
src/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue
📚 Learning: 2024-12-05T15:55:35.371Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 761
File: src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue:166-182
Timestamp: 2024-12-05T15:55:35.371Z
Learning: 在文件 `wd-message-box.vue` 的 `toggleModal` 方法中,当 `isPass` 为 `false` 时,应阻止执行 `confirm`,但不触发 `cancel` 操作。
Applied to files:
src/uni_modules/wot-design-uni/components/wd-datetime-picker/wd-datetime-picker.vuesrc/uni_modules/wot-design-uni/components/wd-picker/wd-picker.vue
🧬 Code graph analysis (3)
src/uni_modules/wot-design-uni/components/composables/useTimeout.ts (1)
src/uni_modules/wot-design-uni/components/composables/index.ts (1)
useTimeout(13-13)
src/uni_modules/wot-design-uni/components/wd-picker/types.ts (1)
src/uni_modules/wot-design-uni/components/wd-popup/types.ts (1)
BackpressType(15-27)
src/uni_modules/wot-design-uni/components/wd-datetime-picker/types.ts (1)
src/uni_modules/wot-design-uni/components/wd-popup/types.ts (1)
BackpressType(15-27)
🪛 GitHub Check: Test Components (wd-datetime-picker)
src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts
[failure] 5-5: tests/components/wd-datetime-picker.test.ts
TypeError: uni.getAppBaseInfo is not a function
❯ src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts:5:19
❯ src/uni_modules/wot-design-uni/components/composables/index.ts:42:32
🪛 GitHub Check: Test Components (wd-picker)
src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts
[failure] 5-5: tests/components/wd-picker.test.ts
TypeError: uni.getAppBaseInfo is not a function
❯ src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts:5:19
❯ src/uni_modules/wot-design-uni/components/composables/index.ts:42:32
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test Components (wd-popup)
- GitHub Check: Test Components (common)
🔇 Additional comments (20)
src/uni_modules/wot-design-uni/components/wd-popup/types.ts (2)
15-27: 类型定义清晰,LGTM!
BackpressType联合类型定义良好,每个选项都有清晰的中文注释说明其行为。类型设计合理,涵盖了返回拦截的三种场景。
117-123: 属性定义正确,默认值合理。
backpress属性使用makeStringProp<BackpressType>('back')定义,与其他属性风格一致。默认值'back'保持了原有行为,不会造成破坏性变更。src/uni_modules/wot-design-uni/components/wd-picker/types.ts (2)
5-5: 导入正确。从
wd-popup/types导入BackpressType类型,实现了类型复用,避免重复定义。
165-172: 属性扩展一致性良好。
backpress属性的定义与wd-popup组件保持一致,文档注释完整。这使得 picker 组件能够将返回拦截行为透传给内部的 popup 组件。src/uni_modules/wot-design-uni/components/wd-datetime-picker/types.ts (2)
5-5: 导入正确,与 picker 组件保持一致。
204-211: API 设计一致性良好。
datetime-picker与picker组件的backpress属性定义完全一致,提供了统一的 API 体验。src/uni_modules/wot-design-uni/components/composables/useTimeout.ts (2)
44-46: 清理逻辑正确。使用
onUnmounted钩子清理定时器,防止组件卸载后定时器仍在执行,这是正确的做法。
48-52: 返回值设计合理。使用
shallowReadonly包装pending状态防止外部误修改,同时暴露start和stop方法提供完整的控制能力。src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts (2)
52-66: 监听逻辑实现正确
watch配置了immediate: true,确保初始状态正确处理。栈管理逻辑通过includes检查避免重复添加,实现合理。
75-93: 生命周期管理和返回值实现正确事件监听在
onMounted注册、onUnmounted清理,符合 Vue 组合式 API 最佳实践。isTopPopup计算属性能正确反映当前弹窗是否为顶层。src/uni_modules/wot-design-uni/components/composables/index.ts (1)
13-14: LGTM!新增的导出遵循现有的 barrel 文件模式,保持了一致的代码风格。
src/uni_modules/wot-design-uni/components/wd-picker/wd-picker.vue (3)
41-52: 返回拦截集成实现正确
wd-popup的backpress属性和@backpress事件绑定正确,与其他 picker 组件保持一致。
109-109: 事件声明正确添加
defineEmits中添加了'backpress'事件,与模板中的使用保持一致。
404-409:onBackpress处理逻辑清晰当
backpress === 'close'时调用onCancel()关闭弹窗,符合预期的交互行为。实现与wd-datetime-picker保持一致。src/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue (3)
2-13: 小程序返回拦截实现使用
page-container组件配合条件编译 (#ifdef MP) 实现小程序端的返回拦截。同时绑定@beforeleave和@before-leave事件以兼容不同平台的事件命名,考虑周全。
183-190:useTopPopup集成实现正确
- 传入
modelValue作为可见性状态- 当
backpress === 'back'时禁用功能(保持默认返回行为)onHide回调正确触发backpress事件并关闭弹窗
204-217: 延迟显示逻辑实现合理使用
useTimeout管理backpressVisible的延迟设置,确保page-container不会过早拦截返回事件。在modelValue变为false时正确清理状态和取消延迟。src/uni_modules/wot-design-uni/components/wd-datetime-picker/wd-datetime-picker.vue (3)
55-66: 返回拦截集成实现正确
wd-popup的backpress属性和@backpress事件绑定与wd-picker保持一致,实现了统一的返回拦截机制。
182-182: 事件声明正确添加
defineEmits中新增'backpress'事件,与模板使用保持一致。
794-799:onBackpress处理逻辑与wd-picker保持一致实现模式相同:先 emit
backpress事件,当backpress === 'close'时调用onCancel()关闭弹窗。代码风格统一,易于维护。
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| function start(...args: Parameters<CallbackFn> | []) { | ||
| if (immediateCb) { | ||
| cb() | ||
| } | ||
| clear() | ||
| pending.value = true | ||
| timer = setTimeout(() => { | ||
| pending.value = false | ||
| timer = null | ||
| cb(...args) | ||
| }, toValue(ms)) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n src/uni_modules/wot-design-uni/components/composables/useTimeout.tsRepository: Moonofweisheng/wot-design-uni
Length of output: 1508
🏁 Script executed:
find . -type f \( -name "*.test.ts" -o -name "*.spec.ts" -o -name "*.test.js" -o -name "*.spec.js" \) | xargs grep -l "useTimeout" 2>/dev/null | head -5Repository: Moonofweisheng/wot-design-uni
Length of output: 55
🏁 Script executed:
rg "useTimeout" --type ts --type js -A 3 -B 1 | head -100Repository: Moonofweisheng/wot-design-uni
Length of output: 1952
🏁 Script executed:
rg "start\(" src/uni_modules/wot-design-uni/components/wd-popup/wd-popup.vue -A 1 -B 1Repository: Moonofweisheng/wot-design-uni
Length of output: 55
🏁 Script executed:
rg "immediateCb" . --type ts --type js -B 2 -A 2Repository: Moonofweisheng/wot-design-uni
Length of output: 1500
🏁 Script executed:
rg "useTimeout" src/uni_modules/wot-design-uni/components --type vue -A 10 | head -50Repository: Moonofweisheng/wot-design-uni
Length of output: 100
🏁 Script executed:
find src/uni_modules/wot-design-uni/components -name "*.vue" -exec grep -A 10 "useTimeout" {} + | head -60Repository: Moonofweisheng/wot-design-uni
Length of output: 2000
🏁 Script executed:
find . -type f \( -name "*.test.*" -o -name "*.spec.*" \) -exec grep -l "useTimeout" {} \;Repository: Moonofweisheng/wot-design-uni
Length of output: 55
🏁 Script executed:
rg "immediateCb\s*:\s*true" . --type ts --type jsRepository: Moonofweisheng/wot-design-uni
Length of output: 55
immediateCb 回调参数传递不一致。
当 immediateCb 为 true 时,第 29 行调用 cb() 不传递参数,但延迟回调(第 36 行)调用 cb(...args) 传递参数。这导致两种执行路径的回调参数不一致。
建议统一参数传递:
修复建议
function start(...args: Parameters<CallbackFn> | []) {
if (immediateCb) {
- cb()
+ cb(...args)
}
clear()
pending.value = true
timer = setTimeout(() => {
pending.value = false
timer = null
cb(...args)
}, toValue(ms))
}🤖 Prompt for AI Agents
In `@src/uni_modules/wot-design-uni/components/composables/useTimeout.ts` around
lines 27 - 38, The immediate callback path in start currently calls cb() without
forwarding the provided arguments, causing inconsistent behavior vs the delayed
path which uses cb(...args); update start so that when immediateCb is truthy it
calls cb(...args) instead of cb(), ensuring the same Parameters<CallbackFn> are
passed for both immediate and delayed executions (refer to the start function,
immediateCb flag, cb callback, and the args rest parameter).
| // TODO 安卓端 | ||
| const isApp = uni.getAppBaseInfo().uniPlatform === 'app' |
There was a problem hiding this comment.
测试失败:uni.getAppBaseInfo 在模块加载时被调用
静态分析显示测试失败,原因是 uni.getAppBaseInfo() 在模块顶层作用域被调用。在测试环境中,uni 对象可能未完全 mock,导致 TypeError: uni.getAppBaseInfo is not a function。
建议将此调用延迟到实际需要时执行,或添加防御性检查:
🐛 建议修复
-// TODO 安卓端
-const isApp = uni.getAppBaseInfo().uniPlatform === 'app'
+// TODO 安卓端
+const getIsApp = () => {
+ try {
+ return uni.getAppBaseInfo?.()?.uniPlatform === 'app'
+ } catch {
+ return false
+ }
+}然后在 handlePopupHide 中使用 getIsApp() 替代 isApp。
🧰 Tools
🪛 GitHub Check: Test Components (wd-datetime-picker)
[failure] 5-5: tests/components/wd-datetime-picker.test.ts
TypeError: uni.getAppBaseInfo is not a function
❯ src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts:5:19
❯ src/uni_modules/wot-design-uni/components/composables/index.ts:42:32
🪛 GitHub Check: Test Components (wd-picker)
[failure] 5-5: tests/components/wd-picker.test.ts
TypeError: uni.getAppBaseInfo is not a function
❯ src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts:5:19
❯ src/uni_modules/wot-design-uni/components/composables/index.ts:42:32
🤖 Prompt for AI Agents
In `@src/uni_modules/wot-design-uni/components/composables/useTopPopup.ts` around
lines 4 - 5, The module calls uni.getAppBaseInfo() at top-level (isApp) causing
tests to fail when uni isn't mocked; change to a lazy/safe accessor: remove the
top-level isApp usage, add a function getIsApp() that checks uni and
uni.getAppBaseInfo existence before calling and returns a boolean, and update
callers to use getIsApp() (specifically replace uses of isApp inside
handlePopupHide with getIsApp()). Ensure the new function is exported/available
where needed and avoid any top-level invocation of uni.getAppBaseInfo.
There was a problem hiding this comment.
Actionable comments posted: 12
🤖 Fix all issues with AI agents
In `@docs/component/datetime-picker.md`:
- Line 329: Add explicit descriptions for the backpress prop: explain the three
option values back, close, and stop and their behaviors (back = default navigate
back to previous page; close = intercept and close the picker popup; stop =
block the back action entirely), state that back is the default, and include a
short usage example showing how to set backpress on the component; also replace
the version placeholder $LOWEST_VERSION$ with the actual minimum supported
version number for this feature in the table.
- Line 348: Update the backpress event doc entry for the datetime-picker:
clarify when it fires (e.g., when the platform back key or header back button is
pressed), list any event parameters (specify if none or describe payload fields
and types), and replace the $LOWEST_VERSION$ placeholder with the actual minimum
supported version number; update the table row for the "backpress" event and any
adjacent explanatory text to include these details for clarity.
In `@docs/component/picker.md`:
- Line 296: Update the table row for the backpress event (the "backpress" entry)
to expand its description: state the trigger timing (e.g., "触发时机:用户按下返回键时"),
list the event parameters and their types/meanings (e.g., event.detail with
fields like reason, timestamp, etc., or "无参数" if none), and replace the
placeholder $LOWEST_VERSION$ with the actual minimum supported version number;
ensure the entry clarifies that the event is only for 小程序 and follows the same
parameter naming conventions used elsewhere in the docs.
In `@docs/component/popup.md`:
- Line 139: Update the backpress event documentation row: replace the
$LOWEST_VERSION$ placeholder with the actual minimum supported version, and
expand the cell for the backpress event to briefly describe the trigger
conditions (e.g., when the hardware back button or system back gesture is
invoked in the mini-program), common usage scenarios (e.g., intercepting
navigation to show confirmation, preventing accidental exits, custom modal close
behavior), and any important notes (whether the event is cancelable, propagation
details, and platform-specific limitations). Ensure the description is concise
and fits the table cell or add a footnote reference if it becomes multi-line.
- Line 125: The docs row for the popup component's backpress property is
incomplete: expand the backpress documentation to describe each allowed value
(back / close / stop) and their behaviors, add usage scenarios and an example
using the wd-popup component with backpress (e.g., show how to close the popup
on back vs let navigation proceed), and replace the $LOWEST_VERSION$ placeholder
with the actual minimum supported version; update the table cell and add a new
"返回键拦截" or "Back key interception" subsection that documents the three options
and a short code snippet using the wd-popup component and v-model to demonstrate
usage.
In `@docs/en-US/component/datetime-picker.md`:
- Line 342: Update the table row for the backpress event: replace the terse
description "Triggered when back(only mp)" with "Triggered when the back button
is pressed (mini-program only)" and replace the $LOWEST_VERSION$ placeholder
with the actual minimum supported version for this event (use the component's
real version number rather than the placeholder).
- Line 323: Update the backpress prop row: replace the terse description "handle
back(only mp)" with "Back button behavior (mini-program only)"; add a brief
explanation of the three allowed values — "back" (default: navigate back one
page), "close" (close the picker/modal immediately), and "stop" (prevent default
back action) — and ensure these option descriptions match the Chinese doc;
finally replace the version placeholder `$LOWEST_VERSION$` with the actual
minimum supported version string used across other docs.
In `@docs/en-US/component/picker.md`:
- Line 294: The table row for the "backpress" event has placeholder and
formatting issues: replace $LOWEST_VERSION$ with the actual minimum version
number, normalize spacing around pipe characters, and update the description
text to "Triggered when back button is pressed (Mini Program only)" (add a short
clause about when it fires, e.g., "fires when the user presses the
hardware/software back button to navigate away") so the row for the backpress
event is clear and properly formatted.
- Line 275: Update the table row that currently reads "|backpress|handle
back(only mp)|string|back/close/stop|back|$LOWEST_VERSION$|" by replacing the
placeholder $LOWEST_VERSION$ with the actual lowest version (e.g., 1.3.0),
normalizing spacing around pipe characters to match other rows, and changing the
label to "Handle back press behavior (Mini Program only)" (ensure a space before
the parenthesis). Also add a short explanatory note after the table that defines
the options: "back: Navigate back to previous page", "close: Close the picker
popup only", and "stop: Prevent default back behavior".
In `@docs/en-US/component/popup.md`:
- Line 141: Update the table row for the backpress event: replace the terse
description "Triggered when back(only mp)" with a clearer phrase such as
"Triggered when the back button is pressed (mini-program only)" (or "Emitted
when hardware/navigation back button is pressed (mini-program only)"), and
replace the version placeholder "$LOWEST_VERSION$" with the actual minimum
supported version number for the backpress event so the table entry for
"backpress" is descriptive and accurate.
- Line 127: The backpress attribute row is unclear: update the table entry for
backpress to use a clearer description like "Back button behavior (mini-program
only)", replace the version placeholder $LOWEST_VERSION$ with the actual minimum
supported version, and add a short options description block after the
Attributes table explaining the three possible values for backpress (reference
the attribute name backpress and the values back/close/stop) with one-line
semantics for each (default behavior, close popup, prevent action) so readers
can pick the correct option.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/component/datetime-picker.mddocs/component/picker.mddocs/component/popup.mddocs/en-US/component/datetime-picker.mddocs/en-US/component/picker.mddocs/en-US/component/popup.md
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| | use-second | 是否显示秒选择,仅在 time 和 datetime 类型下生效 | boolean | - | false | 1.10.0 | | ||
| | clearable | 显示清空按钮 | boolean | - | false | 1.11.0 | | ||
| | root-portal | 是否从页面中脱离出来,用于解决各种 fixed 失效问题 | boolean | - | false | 1.11.0 | | ||
| | backpress | 返回拦截(仅小程序) | string | back / close / stop | back | $LOWEST_VERSION$ | |
There was a problem hiding this comment.
补充 backpress 属性的选项说明
当前文档仅列出了 backpress 属性的基本信息,但缺少对三个选项值的具体说明:
back、close、stop三个选项的具体行为和区别未说明- 用户无法理解何时应该使用哪个选项
- 版本占位符
$LOWEST_VERSION$需要替换为实际版本号
建议在属性表格后添加详细说明,例如:
**backpress 选项说明:**
- `back`:执行默认返回行为,返回上一页(默认值)
- `close`:拦截返回操作,关闭当前选择器弹窗
- `stop`:阻止返回操作,不执行任何行为同时建议添加使用示例展示如何配置此属性。
🤖 Prompt for AI Agents
In `@docs/component/datetime-picker.md` at line 329, Add explicit descriptions for
the backpress prop: explain the three option values back, close, and stop and
their behaviors (back = default navigate back to previous page; close =
intercept and close the picker popup; stop = block the back action entirely),
state that back is the default, and include a short usage example showing how to
set backpress on the component; also replace the version placeholder
$LOWEST_VERSION$ with the actual minimum supported version number for this
feature in the table.
| | cancel | 点击左侧按钮触发 | - | - | | ||
| | toggle | 在区域选择模式下,tab标签切换时触发 | 切换到当前picker选中的值 | - | | ||
| | clear | 点击清空按钮触发 | - | 1.11.0 | | ||
| | backpress | 返回触发(仅小程序) | - | $LOWEST_VERSION$ | |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
完善 backpress 事件文档
建议为 backpress 事件添加更详细的说明:
- 说明该事件在什么场景下触发(按下返回键/返回按钮时)
- 说明事件参数(如果有的话)
- 替换版本占位符
$LOWEST_VERSION$为实际版本号
🤖 Prompt for AI Agents
In `@docs/component/datetime-picker.md` at line 348, Update the backpress event
doc entry for the datetime-picker: clarify when it fires (e.g., when the
platform back key or header back button is pressed), list any event parameters
(specify if none or describe payload fields and types), and replace the
$LOWEST_VERSION$ placeholder with the actual minimum supported version number;
update the table row for the "backpress" event and any adjacent explanatory text
to include these details for clarity.
| | immediate-change | 是否在手指松开时立即触发picker-view的 change 事件。若不开启则会在滚动动画结束后触发 change 事件,1.2.25版本起提供,仅微信小程序和支付宝小程序支持 | boolean | - | false | 1.2.25 | | ||
| | clearable | 显示清空按钮 | boolean | - | false | 1.11.0 | | ||
| | root-portal | 是否从页面中脱离出来,用于解决各种 fixed 失效问题 | boolean | - | false | 1.11.0 | | ||
| | backpress | 返回拦截(仅小程序) | string | back / close / stop | back | $LOWEST_VERSION$ | |
There was a problem hiding this comment.
补充 backpress 属性的详细说明
与 datetime-picker 组件文档类似,picker 组件的 backpress 属性文档也存在以下问题:
- 缺少对
back、close、stop三个选项的具体说明 - 用户无法理解各选项的行为差异和适用场景
- 版本占位符
$LOWEST_VERSION$需要替换为实际版本号
建议添加选项说明和使用示例,保持与其他组件文档的一致性。
| | cancel | 点击左侧按钮触发 | - | - | | ||
| | open | 打开选择器弹出层时触发 | - | - | | ||
| | clear | 点击清空按钮时触发 | - | 1.11.0 | | ||
| | backpress | 返回触发(仅小程序) | - | $LOWEST_VERSION$ | |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
完善 backpress 事件说明
建议补充 backpress 事件的详细说明,包括:
- 触发时机(用户按下返回键时)
- 事件参数说明
- 实际版本号替换
$LOWEST_VERSION$
🤖 Prompt for AI Agents
In `@docs/component/picker.md` at line 296, Update the table row for the backpress
event (the "backpress" entry) to expand its description: state the trigger
timing (e.g., "触发时机:用户按下返回键时"), list the event parameters and their
types/meanings (e.g., event.detail with fields like reason, timestamp, etc., or
"无参数" if none), and replace the placeholder $LOWEST_VERSION$ with the actual
minimum supported version number; ensure the entry clarifies that the event is
only for 小程序 and follows the same parameter naming conventions used elsewhere in
the docs.
| | transition | 动画类型,参见 wd-transition 组件的name | string | fade / fade-up / fade-down / fade-left / fade-right / slide-up / slide-down / slide-left / slide-right / zoom-in | - | - | | ||
| | lock-scroll | 是否锁定背景滚动,锁定时蒙层里的内容也将无法滚动 | boolean | - | true | 0.1.30 | | ||
| | root-portal | 是否从页面中脱离出来,用于解决各种 fixed 失效问题 | boolean | - | false | 1.11.0 | | ||
| | backpress | 返回拦截(仅小程序) | string | back / close / stop | back | $LOWEST_VERSION$ | |
There was a problem hiding this comment.
补充 backpress 属性的完整说明
作为 popup 组件的核心新特性,backpress 属性的文档应该更加完善:
- 缺少对三个选项值(back/close/stop)的详细说明,这是文档的关键缺失
- 建议添加使用场景说明,帮助开发者理解何时使用此功能
- 版本占位符
$LOWEST_VERSION$需要替换为实际版本号
建议在文档中添加专门的章节说明此功能,例如:
## 返回键拦截
在小程序中,可以通过 `backpress` 属性控制按下返回键时的行为。
**backpress 选项:**
- `back`:默认行为,返回上一页
- `close`:拦截返回,关闭弹窗
- `stop`:阻止返回操作
\`\`\`html
<wd-popup v-model="show" backpress="close">
<text>按返回键将关闭弹窗而不是返回上一页</text>
</wd-popup>
\`\`\`🤖 Prompt for AI Agents
In `@docs/component/popup.md` at line 125, The docs row for the popup component's
backpress property is incomplete: expand the backpress documentation to describe
each allowed value (back / close / stop) and their behaviors, add usage
scenarios and an example using the wd-popup component with backpress (e.g., show
how to close the popup on back vs let navigation proceed), and replace the
$LOWEST_VERSION$ placeholder with the actual minimum supported version; update
the table cell and add a new "返回键拦截" or "Back key interception" subsection that
documents the three options and a short code snippet using the wd-popup
component and v-model to demonstrate usage.
| | cancel | Triggered when clicking left button | - | - | | ||
| | toggle | In range selection mode, triggered when switching tab labels | Currently selected value of the switched picker | - | | ||
| | clear | Triggered when clicking clear button | - | 1.11.0 | | ||
| |backpress|Triggered when back(only mp)|-|$LOWEST_VERSION$| |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
改进 backpress 事件描述
事件描述 "Triggered when back(only mp)" 过于简略,建议改为:
- "Triggered when the back button is pressed (mini-program only)"
同时需要替换版本占位符为实际版本号。
🤖 Prompt for AI Agents
In `@docs/en-US/component/datetime-picker.md` at line 342, Update the table row
for the backpress event: replace the terse description "Triggered when back(only
mp)" with "Triggered when the back button is pressed (mini-program only)" and
replace the $LOWEST_VERSION$ placeholder with the actual minimum supported
version for this event (use the component's real version number rather than the
placeholder).
| | immediate-change | Trigger picker-view change event immediately on touch release (supported in WeChat Mini Program and Alipay Mini Program from v1.2.25) | boolean | - | false | 1.2.25 | | ||
| | clearable | Show clear button | boolean | - | false | 1.11.0 | | ||
| | root-portal | Detach from page to resolve fixed positioning issues | boolean | - | false | 1.11.0 | | ||
| |backpress|handle back(only mp)|string|back/close/stop|back|$LOWEST_VERSION$| |
There was a problem hiding this comment.
修复文档质量问题和占位符
此行存在多个问题:
- 占位符未替换:
$LOWEST_VERSION$应替换为实际的版本号(例如 1.3.0) - 格式不一致:缺少管道符号周围的空格,与表格其他行不一致
- 语法错误:
- "handle back(only mp)" 应为 "Handle back press behavior (Mini Program only)"
- 括号前缺少空格
- 描述不清晰:应说明每个选项的作用:
back: 触发返回上一页close: 仅关闭选择器弹窗stop: 阻止默认返回行为
📝 建议的文档修复
-|backpress|handle back(only mp)|string|back/close/stop|back|$LOWEST_VERSION$|
+| backpress | Handle back press behavior (Mini Program only) | string | back/close/stop | back | 1.3.0 |并建议在表格后添加详细说明:
back: Navigate back to previous pageclose: Close the picker popup onlystop: Prevent default back behavior
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| |backpress|handle back(only mp)|string|back/close/stop|back|$LOWEST_VERSION$| | |
| | backpress | Handle back press behavior (Mini Program only) | string | back/close/stop | back | 1.3.0 | |
🤖 Prompt for AI Agents
In `@docs/en-US/component/picker.md` at line 275, Update the table row that
currently reads "|backpress|handle back(only
mp)|string|back/close/stop|back|$LOWEST_VERSION$|" by replacing the placeholder
$LOWEST_VERSION$ with the actual lowest version (e.g., 1.3.0), normalizing
spacing around pipe characters to match other rows, and changing the label to
"Handle back press behavior (Mini Program only)" (ensure a space before the
parenthesis). Also add a short explanatory note after the table that defines the
options: "back: Navigate back to previous page", "close: Close the picker popup
only", and "stop: Prevent default back behavior".
| | cancel | Triggered on cancel button click | - | - | | ||
| | open | Triggered when picker popup opens | - | - | | ||
| | clear | Triggered on clear button click | - | 1.11.0 | | ||
| |backpress|Triggered when back(only mp)|-|$LOWEST_VERSION$| |
There was a problem hiding this comment.
修复文档质量问题和占位符
此行存在与属性表格类似的问题:
- 占位符未替换:
$LOWEST_VERSION$应替换为实际的版本号 - 格式不一致:缺少管道符号周围的空格
- 语法错误和描述不清:
- "Triggered when back(only mp)" 应为 "Triggered when back button is pressed (Mini Program only)"
- 括号前缺少空格
- 应说明事件的触发时机和用途
📝 建议的文档修复
-|backpress|Triggered when back(only mp)|-|$LOWEST_VERSION$|
+| backpress | Triggered when back button is pressed (Mini Program only) | - | 1.3.0 |📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| |backpress|Triggered when back(only mp)|-|$LOWEST_VERSION$| | |
| | backpress | Triggered when back button is pressed (Mini Program only) | - | 1.3.0 | |
🤖 Prompt for AI Agents
In `@docs/en-US/component/picker.md` at line 294, The table row for the
"backpress" event has placeholder and formatting issues: replace
$LOWEST_VERSION$ with the actual minimum version number, normalize spacing
around pipe characters, and update the description text to "Triggered when back
button is pressed (Mini Program only)" (add a short clause about when it fires,
e.g., "fires when the user presses the hardware/software back button to navigate
away") so the row for the backpress event is clear and properly formatted.
| |transition|Transition type|string|fade/fade-up/fade-down/fade-left/fade-right/slide-up/slide-down/slide-left/slide-right/zoom-in|-|-| | ||
| |lock-scroll|Whether to lock background scroll|boolean|-|true|0.1.30| | ||
| |root-portal|Whether to mount to root node|boolean|-|false|1.11.0| | ||
| |backpress|handle back(only mp)|string|back/close/stop|back|$LOWEST_VERSION$| |
There was a problem hiding this comment.
补充 backpress 属性选项说明和改进描述文字
当前文档存在以下问题:
- 描述文字 "handle back(only mp)" 不够清晰,建议改为 "Back button behavior (mini-program only)" 或 "Handle back button press (mini-program only)"
- 缺少对三个选项值(back/close/stop)的具体说明,用户无法理解它们的区别和使用场景
- 版本占位符
$LOWEST_VERSION$需要替换为实际版本号
建议在 Attributes 表格后或 backpress 行添加说明,例如:
|backpress|Back button behavior (mini-program only)|string|back/close/stop|back|1.X.X|
**backpress options:**
- `back`: Navigate back to previous page (default behavior)
- `close`: Close the popup when back button is pressed
- `stop`: Prevent back button action🤖 Prompt for AI Agents
In `@docs/en-US/component/popup.md` at line 127, The backpress attribute row is
unclear: update the table entry for backpress to use a clearer description like
"Back button behavior (mini-program only)", replace the version placeholder
$LOWEST_VERSION$ with the actual minimum supported version, and add a short
options description block after the Attributes table explaining the three
possible values for backpress (reference the attribute name backpress and the
values back/close/stop) with one-line semantics for each (default behavior,
close popup, prevent action) so readers can pick the correct option.
| |before-leave|Triggered before leave transition starts|-|-| | ||
| |leave|Triggered when leave transition starts|-|-| | ||
| |after-leave|Triggered when leave transition ends|-|-| | ||
| |backpress|Triggered when back(only mp)|-|$LOWEST_VERSION$| |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
改进 backpress 事件描述
事件描述 "Triggered when back(only mp)" 过于简略。建议改为更清晰的描述,例如:
- "Triggered when the back button is pressed (mini-program only)"
- "Emitted when hardware/navigation back button is pressed (mini-program only)"
同时需要替换版本占位符 $LOWEST_VERSION$ 为实际版本号。
🤖 Prompt for AI Agents
In `@docs/en-US/component/popup.md` at line 141, Update the table row for the
backpress event: replace the terse description "Triggered when back(only mp)"
with a clearer phrase such as "Triggered when the back button is pressed
(mini-program only)" (or "Emitted when hardware/navigation back button is
pressed (mini-program only)"), and replace the version placeholder
"$LOWEST_VERSION$" with the actual minimum supported version number for the
backpress event so the table entry for "backpress" is descriptive and accurate.
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
#1100
💡 需求背景和解决方案
返回关闭弹出层而不是返回上一页,符合移动端交互行为
☑️ 请求合并前的自查清单
Summary by CodeRabbit
发版说明
✏️ Tip: You can customize this high-level summary in your review settings.