imgbed
imgbed 封装了常见的图床接口,调用方便
已封装图床列表
- sm.ms https://sm.ms/
- 牛图 https://www.niupic.com
- 新浪图床1 https://github.com/CitronsBlog/sinaimg/blob/master/index.html
- 新浪图床2 https://github.com/dalaolala/4to1pic/blob/master/index.html
使用方式
安装 imgbed
npm install imgbed// yarnyarn add imgbed
基本使用
const ImgBed = default ImgBed ImgBed ImgBed ImgBed
API
// jsconst ImgBed = default// ts // 上传图片await ImgBed // smawait ImgBed // 牛图await ImgBed // 新浪1await ImgBed // 新浪2
因为 sm 对上传做了限制,牛图服务器不太稳定,所以上传可能会失败,imgbed 提供了一个依次上传直到成功的方法,使用如下
// .jsconst ImgBed = default// .ts // 依次按照 sm -> nt -> sina1 -> sina2 上传await ImgBed // 自定义上传次序:nt -> sm,此时牛图上传失败则会切换到 sm 上传await ImgBed // 自定义上传次序:nt -> sinal -> sina2 -> smawait ImgBed