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

refactor: upload函数 #115

Merged
merged 1 commit into from
Nov 6, 2019
Merged

Conversation

donaldshen
Copy link
Contributor

@donaldshen donaldshen commented Nov 6, 2019

Why

原来的upload函数有150行,难以把握

How

  1. 抽离httpRequest函数
    a. httpRequest函数接受一个File,返回上传后的url地址
    b. 原本的upload方法也有这样的逻辑,所以可以抽离处理
  2. 重构newClient方法
    a. 现在会精确告知缺了哪个oss配置属性
    b. 直接返回一个AliOSS对象。这样就不需要存在data里了
  3. 移除handleCatchError
    a. 因为现在统一抽离了httpRequest方法,所以一个try catch block就可以处理错误了

Test

  1. 总体代码行数减少25行(708 => 683)
  2. upload方法行数减少50行(144 => 94)
  3. preview的案例basichttpRequest均正常

@netlify
Copy link

netlify bot commented Nov 6, 2019

Deploy preview for upload-to-ali ready!

Built with commit 592760e

https://deploy-preview-115--upload-to-ali.netlify.com

@levy9527 levy9527 merged commit 205d615 into FEMessage:dev Nov 6, 2019
@donaldshen donaldshen deleted the refactor/upload branch November 6, 2019 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants