feat(easy-admin): add upload functionality for images and videos

- Add uploadImage and uploadVideo configurations to the editor
- Implement customInsert function for handling image and video uploads
- Display error messages for failed uploads
- Use layer.msg for showing upload success or failure messages
This commit is contained in:
wolfcode
2025-07-16 14:06:37 +08:00
parent b8194994f0
commit 2d6e5aabbd

View File

@@ -1668,6 +1668,7 @@ define(["jquery", "tableSelect", "miniTheme", "xmSelect", "lazyload"], function
html: $(this).text(),
config: {
MENU_CONF: {
// 上传图片
uploadImage: {
server: window.CONFIG.ADMIN_UPLOAD_URL,
fieldName: 'file',
@@ -1685,6 +1686,23 @@ define(["jquery", "tableSelect", "miniTheme", "xmSelect", "lazyload"], function
let href = ''
insertFn(url, alt, href)
}
},
// 上传视频
uploadVideo: {
server: window.CONFIG.ADMIN_UPLOAD_URL,
fieldName: 'file',
meta: {editor: 'editor',},
async customInsert(res, insertFn) {
let code = res.code || 0
if (code != '1') {
layer.msg(res.msg || '上传失败', {icon: 2});
return
}
let url = res.data?.url || ''
let alt = ''
let href = ''
insertFn(url, alt, href)
}
}
},
}