egg-ueditor,基於egg的UEditor百度編輯器後端實現,支持圖片/文件上傳、列表及圖片遠程抓取

egg-ueditor

基於egg的UEditor百度編輯器後端實現,支持圖片/文件上傳、列表及圖片遠程抓取
源碼:https://github.com/inmyjs/egg-ueditor

安裝

 npm install egg-ueditor --save

使用方法

  1. 在app/router.js中如下使用

const ueditor = require('egg-ueditor')

app.all('/ueditor', ueditor())

注意:默認上傳至egg靜態資源目錄app/public,若需要上傳至其他目錄,如下使用:

app.all('/ueditor', ueditor(['assets/public','public']))

參數爲一個數組,第1個參數爲靜態資源相對目錄,第2個參數爲靜態資源url映射路徑。

返回的圖片/文件url爲完整http地址,以方便前後端分佈部署,比如:http://127.0.0.1:7001/public/upload/ueditor/image/20181223/1545560529310279850.png

  1. 可以修改 UEditor 配置,具體的參數請參考 UEditor 官方的文檔
// 需要傳UEditor 配置對象
router.all('/ueditor', ueditor({
	"imageAllowFiles": [".png", ".jpg", ".jpeg"]
	"imagePathFormat": "/upload/ueditor/image/{yyyy}{mm}{dd}/{filename}"  // 保存爲原文件名
}))

或者

// 需要傳UEditor 配置對象
router.all('/ueditor', ueditor(['app/public','public']{
	"imageAllowFiles": [".png", ".jpg", ".jpeg"]
	"imagePathFormat": "/upload/ueditor/image/{yyyy}{mm}{dd}/{filename}"  // 保存爲原文件名
}))

非常感謝您的支持

擼碼不易,如果對你有所幫助,歡迎您的讚賞!微信讚賞碼:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章