diff --git a/src/api/request.js b/src/api/request.js index aa7ae41..ba593cb 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -51,6 +51,11 @@ const putavideo = (id,data) => { const putavideos = (data) => { return http.posts("/admin/video", data); }; +const uploadAuthorAvatar = (file) => { + const formData = new FormData(); + formData.append('file', file); + return http.postFormData("/admin/video/author/avatar", formData); +}; const UEDITOR_SERVERURL = import.meta.env.VITE_APP_UEDITOR_SERVERURL const editorConfig = { // 后端服务地址,后端处理参考 @@ -69,5 +74,5 @@ const editorConfig = { export default { indexdata, getindex,agreement,updateagreement,gettime,updatetime,getarticle,gethospital,putarticles - ,putarticle,putstatus,getvote,getavideo,getvideovote,putvideostatus,putavideo,putavideos,editorConfig + ,putarticle,putstatus,getvote,getavideo,getvideovote,putvideostatus,putavideo,putavideos,uploadAuthorAvatar,editorConfig } \ No newline at end of file diff --git a/src/utils/http/http.js b/src/utils/http/http.js index 0bb5b50..b4f8208 100644 --- a/src/utils/http/http.js +++ b/src/utils/http/http.js @@ -57,7 +57,21 @@ const del = (url, data) => { }) } +const postFormData = (url, formData) => { + return new Promise((resolve, reject) => { + instances.post(url, formData, { + headers: { + 'Content-Type': 'multipart/form-data' + } + }).then(res => { + resolve(res) + }).catch(err => { + reject(err) + }) + }) +} + export default { - post, get, put, del,posts,puts + post, get, put, del,posts,puts,postFormData } \ No newline at end of file diff --git a/src/view/videoList.vue b/src/view/videoList.vue index 0fc10e3..c514e08 100644 --- a/src/view/videoList.vue +++ b/src/view/videoList.vue @@ -129,6 +129,20 @@ +
+ 头像: + + + + +
@@ -185,7 +199,7 @@