Skip to content

Conversation

@chouchouji
Copy link
Member

社区帖子

https://ask.dcloud.net.cn/question/209551

效果

esc.mp4

@chouchouji chouchouji requested a review from zhenyuWang May 21, 2025 11:07
@github-actions
Copy link

Size report

Path Size
packages/size-check/dist/size-check.es.js 47.18 KB (0%)
packages/size-check/dist/style.css 2.82 KB (0%)
packages/uni-app/dist/uni-app.es.js 2.47 KB (0%)
packages/uni-h5-vue/dist/vue.runtime.esm.js 76.41 KB (0%)
packages/uni-mp-vue/dist/vue.runtime.esm.js 43.13 KB (0%)
packages/uni-mp-alipay/dist/uni.api.esm.js 14.69 KB (0%)
packages/uni-mp-alipay/dist/uni.mp.esm.js 7.99 KB (0%)
packages/uni-mp-baidu/dist/uni.api.esm.js 11.34 KB (0%)
packages/uni-mp-baidu/dist/uni.mp.esm.js 9.68 KB (0%)
packages/uni-mp-qq/dist/uni.api.esm.js 10.65 KB (0%)
packages/uni-mp-qq/dist/uni.mp.esm.js 7.6 KB (0%)
packages/uni-mp-toutiao/dist/uni.api.esm.js 10.53 KB (0%)
packages/uni-mp-toutiao/dist/uni.mp.esm.js 9.42 KB (0%)
packages/uni-mp-weixin/dist/uni.api.esm.js 11.66 KB (0%)
packages/uni-mp-weixin/dist/uni.mp.esm.js 7.94 KB (0%)
packages/uni-quickapp-webview/dist/uni.api.esm.js 10.6 KB (0%)
packages/uni-quickapp-webview/dist/uni.mp.esm.js 8.16 KB (0%)

@zhenyuWang zhenyuWang requested a review from Copilot May 23, 2025 02:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for closing the image preview when the user presses the Escape key.

  • Imports and activates the useKeyboard hook.
  • Watches for the Escape key (Esc) to call onClick() and emit the close event.
Comments suppressed due to low confidence (2)

packages/uni-h5/src/service/api/media/previewImage/ImagePreview.tsx:48

  • [nitpick] The variable name key is very generic and may conflict or be confusing. Consider renaming it to something more descriptive like pressedKey or activeKey.
const { key } = useKeyboard()

packages/uni-h5/src/service/api/media/previewImage/ImagePreview.tsx:55

  • [nitpick] There's no test covering the new Escape-key-to-close behavior. Consider adding a unit or integration test to verify that pressing Escape triggers the close event.
watch(

watch(
() => key.value,
(value) => {
if (value === 'esc') {
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyboardEvent.key for the Escape key is typically "Escape", not "esc". Update the comparison to value === 'Escape' to ensure the handler triggers correctly.

Suggested change
if (value === 'esc') {
if (value === 'Escape') {

Copilot uses AI. Check for mistakes.
@zhenyuWang zhenyuWang merged commit 995cc4f into next May 23, 2025
4 checks passed
@chouchouji chouchouji deleted the feat-image-preview-esc branch May 23, 2025 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants