Explorar o código

1.更新文件的上传和可见范围修改相关接口
2.在 .env 文件中将各上传 channel 设置为全局变量

reghao %!s(int64=2) %!d(string=hai) anos
pai
achega
5f35428e1e

+ 5 - 0
.env.development

@@ -1,2 +1,7 @@
 VUE_APP_SERVER_URL=//api.reghao.cn
 VUE_APP_OSS_URL=//oss.reghao.cn/
+VUE_APP_UPLOAD_VIDEO_CHANNEL=104
+VUE_APP_UPLOAD_COVER_CHANNEL=105
+VUE_APP_UPLOAD_AUDIO_CHANNEL=106
+VUE_APP_UPLOAD_AVATAR_CHANNEL=107
+VUE_APP_UPLOAD_PHOTO_CHANNEL=106

+ 5 - 0
.env.production

@@ -1,2 +1,7 @@
 VUE_APP_SERVER_URL=//api.reghao.cn
 VUE_APP_OSS_URL=//oss.reghao.cn/
+VUE_APP_UPLOAD_VIDEO_CHANNEL=104
+VUE_APP_UPLOAD_COVER_CHANNEL=105
+VUE_APP_UPLOAD_AUDIO_CHANNEL=106
+VUE_APP_UPLOAD_AVATAR_CHANNEL=107
+VUE_APP_UPLOAD_PHOTO_CHANNEL=108

+ 11 - 9
src/components/upload/PublishImage.vue

@@ -7,13 +7,13 @@
         </div>
         <div class="text item">
           <el-upload
-            :action="actionUrl"
+            :action="imgOssUrl"
             :headers="imgHeaders"
             :data="imgData"
             :file-list="uploadImages"
             :multiple="true"
             :limit="40"
-            :with-credentials="true"
+            :with-credentials="false"
             list-type="picture-card"
             :before-upload="handleBeforeUpload"
             :on-success="handleOnSuccess"
@@ -72,13 +72,13 @@ export default {
   components: {},
   data() {
     return {
-      actionUrl: process.env.VUE_APP_OSS_URL,
+      imgOssUrl: '',
       // ****************************************************************************************************************
       imgHeaders: {
         Authorization: ''
       },
       imgData: {
-        channelId: 6
+        channelId: process.env.VUE_APP_UPLOAD_PHOTO_CHANNEL
       },
       dialogImageUrl: '',
       dialogVisible: false,
@@ -87,6 +87,7 @@ export default {
       submitForm: {
         imageFileIds: [],
         albumName: null,
+        channelId: process.env.VUE_APP_UPLOAD_PHOTO_CHANNEL,
         scope: '1',
         scheduledPubDate: null
       },
@@ -101,19 +102,20 @@ export default {
     getServerInfo(this.imgData.channelId).then(res => {
       if (res.code === 0) {
         const resData = res.data
+        this.imgOssUrl = resData.ossUrl
         this.imgHeaders.Authorization = 'Bearer ' + resData.token
       } else {
         this.$notify({
-          title: '失败提示',
-          message: res.msg,
-          type: 'warning',
+          title: '提示',
+          message: '获取 OSS 服务器地址失败, 暂时无法上传图片',
+          type: 'error',
           duration: 3000
         })
       }
     }).catch(error => {
       this.$notify({
-        title: '错误提示',
-        message: error.message,
+        title: '提示',
+        message: '获取 OSS 服务器地址失败, 暂时无法上传图片',
         type: 'warning',
         duration: 3000
       })

+ 2 - 21
src/components/upload/PublishVideo.vue

@@ -125,21 +125,6 @@ export default {
     return {
       // ****************************************************************************************************************
       options: null,
-      options1: {
-        target: '',
-        chunkSize: 1024 * 1024 * 1024 * 10, // 10GiB
-        fileParameterName: 'file',
-        testChunks: false,
-        query: (file, chunk) => {
-          return {
-            channelId: 104
-          }
-        },
-        headers: {
-          Authorization: ''
-        },
-        withCredentials: false
-      },
       attrs: {
         accept: 'video/*'
       },
@@ -149,7 +134,7 @@ export default {
         Authorization: ''
       },
       imgData: {
-        channelId: 105
+        channelId: process.env.VUE_APP_UPLOAD_COVER_CHANNEL
       },
       coverUrl: null,
       // ****************************************************************************************************************
@@ -166,7 +151,7 @@ export default {
       ],
       form: {
         videoFileId: null,
-        channelId: 104,
+        channelId: process.env.VUE_APP_UPLOAD_VIDEO_CHANNEL,
         coverUrl: null,
         title: null,
         description: null,
@@ -197,10 +182,6 @@ export default {
           },
           withCredentials: false
         }
-
-        /*this.options.target = resData.ossUrl
-        this.options.chunkSize = resData.maxSize
-        this.options.headers.Authorization = 'Bearer ' + resData.token*/
       } else {
         this.$notify({
           title: '提示',

+ 3 - 4
src/views/my/MyProfile.vue

@@ -10,7 +10,7 @@
             <el-tooltip class="item" effect="dark" content="点击更新我的头像" placement="top-end">
               <el-upload
                 class="avatar-uploader"
-                :action="actionUrl"
+                :action="imgOssUrl"
                 :headers="imgHeaders"
                 :data="imgData"
                 :with-credentials="true"
@@ -60,13 +60,12 @@ export default {
   name: 'MyProfile',
   data() {
     return {
-      actionUrl: process.env.VUE_APP_OSS_URL,
-      imgOssUrl: null,
+      imgOssUrl: '',
       imgHeaders: {
         Authorization: ''
       },
       imgData: {
-        channelId: 4
+        channelId: process.env.VUE_APP_UPLOAD_AVATAR_CHANNEL
       },
       coverUrl: null,
       // ****************************************************************************************************************

+ 8 - 1
src/views/post/ImagePost.vue

@@ -213,7 +213,14 @@ export default {
         if (res.code === 0) {
           this.$notify({
             title: '提示',
-            message: '相册可见范围已更新',
+            message: res.msg,
+            type: 'warning',
+            duration: 3000
+          })
+        } else {
+          this.$notify({
+            title: '提示',
+            message: res.msg,
             type: 'warning',
             duration: 3000
           })