From d92ead2d480779d3226e898c5827271795e21562 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 03 六月 2025 12:55:49 +0800
Subject: [PATCH] 视频发布封面
---
api/common.js | 11 +++++++++++
pages/tabbar/video/video.vue | 25 ++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/api/common.js b/api/common.js
index ad25f22..023c24b 100644
--- a/api/common.js
+++ b/api/common.js
@@ -36,6 +36,17 @@
}
/**
+ * 鑾峰彇鏂囦欢璁块棶鍦板潃
+ */
+ export function getFilePreviewUrl(fileKey) {
+ return http.request({
+ url: `${api.common}/lmk/file/preview`,
+ method: Method.POST,
+ data: {fileKey: fileKey}
+ });
+}
+
+/**
* 鏂囦欢涓婁紶鍦板潃
* @type {string}
*/
diff --git a/pages/tabbar/video/video.vue b/pages/tabbar/video/video.vue
index edab4fc..103a3ff 100644
--- a/pages/tabbar/video/video.vue
+++ b/pages/tabbar/video/video.vue
@@ -179,7 +179,7 @@
import USearch from '@/uview-components/uview-ui/components/u-search/u-search.vue';
import UPopup from '@/uview-components/uview-ui/components/u-popup/u-popup.vue';
import MyTag from "@/components/my-tag.vue"
-import { getSTSToken } from "@/api/common.js";
+import { getSTSToken, getFilePreviewUrl } from "@/api/common.js";
import { publish } from "@/api/video.js";
import { getRecommendTag3 } from "@/api/video-tag.js";
import { getFileKey } from "@/utils/file.js";
@@ -389,7 +389,30 @@
sizeType: ['compressed'],
sourceType: ['album'],
success: (res) => {
+ let fileName = res.tempFilePaths[0].substring(res.tempFilePaths[0].lastIndexOf('/') + 1);
+ // 澶勭悊瀹夊崜鍙兘鐨刄RI缂栫爜
+ if(fileName.indexOf('%') > -1) {
+ fileName = decodeURIComponent(fileName);
+ }
+ const fileKey = getFileKey(fileName);
this.videoInfo.cover = res.tempFilePaths[0];
+ this.cosClient.uploadFile({
+ Bucket: this.bucket,
+ Region: this.region,
+ Key: fileKey,
+ FilePath: res.tempFilePaths[0],
+ SliceSize: 1024 * 1024 * 5 /* 瑙﹀彂鍒嗗潡涓婁紶鐨勯槇鍊�,5M */
+ }, (err, data) => {
+ if (err) {
+ console.log('涓婁紶澶辫触', err);
+ } else {
+ // 鑾峰彇灏侀潰鐨勮闂湴鍧�
+ getFilePreviewUrl(fileKey).then(res => {
+ this.videoInfo.cover = res.data.data
+ this.formData.cover = fileKey
+ })
+ }
+ });
}
});
},
--
Gitblit v1.8.0