reghao 4 лет назад
Родитель
Сommit
4fd834361d

+ 6 - 1
src/api/media/video.js

@@ -5,7 +5,8 @@ const videoApi = {
   similarVideoApi: '/api/media/video/post/similar',
   videoInfoApi: '/api/media/video/post',
   videoUrlApi: '/api/media/video/url',
-  videoCategoryApi: '/api/media/video/category'
+  videoCategoryApi: '/api/media/video/category',
+  videoPostSubmitApi: '/api/media/video/submit'
 }
 
 // 视频推荐接口
@@ -32,3 +33,7 @@ export function videoUrl(videoId) {
 export function videoCategory() {
   return $axios.get(videoApi.videoCategoryApi)
 }
+
+export function submitVideoPost(videoPost) {
+  return $axios.post(videoApi.videoPostSubmitApi, videoPost)
+}

+ 1 - 1
src/components/upload/filepond-upload.vue

@@ -50,7 +50,7 @@ export default {
       videMessage: {},
       myFiles: [],
       server: {
-        url: '/api/file/upload/video',
+        url: process.env.VUE_APP_BASE_API + '/api/file/upload/video',
         process: {
           headers: {
             'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')

+ 9 - 15
src/components/upload/upload-video.vue

@@ -123,7 +123,7 @@
 
 <script>
 import FilePondUpload from '@/components/upload/filepond-upload.vue'
-import { videoCategory } from '@/api/media/video'
+import { videoCategory, submitVideoPost } from '@/api/media/video'
 export default {
   components: {
     FilePondUpload
@@ -173,32 +173,26 @@ export default {
         this.showMessage = true
         return
       }
+
       if (this.videoInfo.tags.length > 6) {
         this.message = '标签超过6个'
         this.showMessage = true
         return
       }
-      fetch(`/api/media/video/submit`, {
-        headers: {
-          'Content-Type': 'application/json; charset=UTF-8',
-          'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
-        },
-        method: 'POST',
-        credentials: 'include',
-        body: JSON.stringify(this.videoInfo)
-      }).then(response => response.json())
-        .then(json => {
-          if (json.code === 0) {
+
+      submitVideoPost(this.videoInfo)
+        .then(res => {
+          if (res.code === 0) {
             this.message = '投稿成功,等待审核通过后你就可以看到你的视频了'
             this.showMessage = true
             this.$router.push('/studio')
           } else {
-            this.message = json.msg
+            this.message = res.msg
             this.showMessage = true
           }
         })
-        .catch(e => {
-          return null
+        .catch(error => {
+          this.$message.error(error.message)
         })
     },
     setFile(value) {