-
-
Notifications
You must be signed in to change notification settings - Fork 323
fix(uploader): openFileDialogOnClick支持传入函数 #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次变更将 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UploadComponent
participant AjaxUploader
User->>UploadComponent: 点击上传区域
UploadComponent->>AjaxUploader: 触发 onClick/onKeyDown 事件
AjaxUploader->>AjaxUploader: 调用 eventHandler(fn, originFn, event)
alt fn 为 boolean 或函数
AjaxUploader->>AjaxUploader: 判断 fn 或 fn()
alt 返回 true
AjaxUploader->>AjaxUploader: 执行 originFn(event)
else 返回 false
AjaxUploader-->>AjaxUploader: 不执行 originFn
end
end
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/AjaxUploader.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate Unit Tests
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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
README.md
(1 hunks)src/AjaxUploader.tsx
(2 hunks)src/interface.tsx
(1 hunks)tests/uploader.spec.tsx
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/AjaxUploader.tsx
[error] 308-308: Don't use 'Function' as a type.
Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.
(lint/complexity/noBannedTypes)
🔇 Additional comments (4)
README.md (1)
86-86
: 文档更新正确反映了新功能API文档正确地反映了
openFileDialogOnClick
属性类型的增强,支持布尔值或返回布尔值的函数。src/interface.tsx (1)
34-34
: 类型定义增强实现得当联合类型
boolean | (() => boolean)
正确地扩展了功能,同时保持了向后兼容性。tests/uploader.spec.tsx (1)
1190-1235
: 测试覆盖全面且实现正确新增的测试套件全面覆盖了
openFileDialogOnClick
的各种使用场景:
- 布尔值 true/false 的行为验证
- 函数返回 true/false 的行为验证
- 动态函数返回值的行为验证
测试实现使用了正确的模拟和断言方式,为新功能提供了可靠的质量保障。
src/AjaxUploader.tsx (1)
347-348
: 事件处理逻辑实现正确使用新的
eventHandler
方法正确地实现了条件事件处理,支持了openFileDialogOnClick
的布尔值和函数两种类型。逻辑清晰且向后兼容。
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #637 +/- ##
==========================================
+ Coverage 89.10% 91.83% +2.72%
==========================================
Files 6 6
Lines 303 306 +3
Branches 84 81 -3
==========================================
+ Hits 270 281 +11
+ Misses 33 25 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
新功能
openFileDialogOnClick
属性现支持传入布尔值或返回布尔值的函数,提升了文件对话框打开行为的灵活性。文档
openFileDialogOnClick
属性类型的变化。测试
openFileDialogOnClick
属性不同用法的测试用例,确保其行为符合预期。