百度UEditor(圖片、文件等)上傳所依賴的后端服務,支持.Net Core 2.0+,簡單易用,
#支持前后端分離
使用教程
當前后台服務接口地址為http://localhost:58898時
1.建議使用NuGet安裝:Install-Package UEditor.Server.Core -Version 1.0.2
源碼:https://github.com/mfkuyg61/UEditor.Server.Core
2.在ConfigureServices中添加
services.AddUEditor(a => { a.WebRootPath = _hostingEnvironment.WebRootPath;//為_hostingEnvironment為IHostingEnvironment或IWebHostEnvironment a.ConfigFile = "ueditor\ueditor.json";//配置文件相對路徑 a.IsCache = false;//不使用緩存 a.ControllerName = "/controller";//后台接口 a.WithOrigins = new string[] { "http://localhost:58898" };//訪問白名單 });
3.在Configure中添加
app.UseUEditor();//百度編輯器,請放在app.UseCors()前面
4.UEditor配置,以UEditor.Server.Core.Demo為例
ueditor.config.js中配置
window.UEDITOR_HOME_URL = '/ueditor/' window.UEDITOR_CONFIG={ serverUrl:'http://localhost:58898/controller' }
注意:如果是前后端分離配置文件需要修改,否則空字符即可,demo改名為ueditor.json
{ "imageUrlPrefix":"http://localhost:58898/", "scrawlUrlPrefix": "http://localhost:58898/", "snapscreenUrlPrefix": "http://localhost:58898/", "catcherUrlPrefix": "http://localhost:58898/", "videoUrlPrefix": "http://localhost:58898/", "fileUrlPrefix": "http://localhost:58898/", "imageManagerUrlPrefix": "http://localhost:58898/", "fileManagerUrlPrefix": "http://localhost:58898/", }