Skip to content
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

upload-imgs: 实现图片上传成功、失败的钩子函数 #274

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zhangxiaoshang
Copy link
Contributor

No description provided.

@quanquan2100
Copy link
Contributor

我看代码了, 你应该没有理解中间的处理流程. 首先, 多图上传每一项图片的成功失败还是对于整个组件(一次性上传多图)成功失败. 你的钩子也没有考虑到用户使用 async 函数的模式. 并且添加的地方是单个图片处理结束的地方.

图片上传逻辑有做一层代理, 也就是如果连续多次调用图片上传, 那么一定数量内图片上传的请求会合并为一个.

可以详细查看以下几个方法 uploadCatch, originUpload, uploadImg 的处理

@zhangxiaoshang
Copy link
Contributor Author

zhangxiaoshang commented Dec 9, 2019

是单个图片上传完成状态的钩子,用户关心的也应该是单个图片的上传状态。

图片上传逻辑有做一层代理, 也就是如果连续多次调用图片上传, 那么一定数量内图片上传的请求会合并为一个.

多图片上传合并为一个请求是底层实现。且如果在这里(uploadCatch)设置钩子,当单次上传文件数量超出 uploadLimit 会多次触发钩子。

你的钩子也没有考虑到用户使用 async 函数的模式

这里没太理解什么意思

@quanquan2100
Copy link
Contributor

这个需求确实有道理, 就是我感觉你的实现方式并不是很完美. 有些问题可以考虑更细致一点.

那另一个问题, 你想的是提供hook, 为什么不是事件呢?

@zhangxiaoshang
Copy link
Contributor Author

这个参考了elementui
具体两种方式有什么差异 暂时还没发现 有懂的大佬可以指导一下

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.

None yet

2 participants