feat(community): 友圈动态支持上传短视频,可与图片同发
- 新增 /api/upload/video 独立上传接口:仅 MP4/MOV、单条 30MB、独立限流、登录鉴权 - posts 表新增 video_url / video_cover,发布接口支持视频与图片同时落库 - 小程序发布器支持选择/预览/删除视频(≤60 秒),动态卡片与详情页支持播放 - 后台动态管理新增视频预览弹窗 - 新增短视频链路与上传鉴权回归测试,125 套件/818 用例全绿
这个提交包含在:
@@ -1008,13 +1008,15 @@ function authHeader() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 真实上传本地图片至服务端持久化静态存储
|
||||
* @param {string} tempFilePath 本地图片临时路径 (如 wxfile://tmp_xxx 或 blob:xxx)
|
||||
* @returns {Promise<string>} 返回持久化公网图片访问路径 (形如 /uploads/img_xxx.png)
|
||||
* 上传本地临时文件至服务端持久化静态存储
|
||||
* @param {string} tempFilePath 本地临时路径 (如 wxfile://tmp_xxx 或 blob:xxx)
|
||||
* @param {string} endpoint 上传接口路径 (图片 / 视频分别使用独立接口)
|
||||
* @param {string} kindLabel 媒体类型中文名,用于错误提示
|
||||
* @returns {Promise<string>} 返回持久化公网访问路径 (形如 /uploads/xxx)
|
||||
*/
|
||||
export function uploadImage(tempFilePath) {
|
||||
function uploadMediaFile(tempFilePath, endpoint, kindLabel) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!tempFilePath) return reject(new Error('图片路径为空'));
|
||||
if (!tempFilePath) return reject(new Error(`${kindLabel}路径为空`));
|
||||
|
||||
// 微信开发者工具临时路径形如 http://tmp/ 或 http://usr/
|
||||
// 微信真机临时路径形如 wxfile://tmp_xxx 或 wxfile://clientdata/xxx
|
||||
@@ -1042,10 +1044,10 @@ export function uploadImage(tempFilePath) {
|
||||
}
|
||||
|
||||
// #ifdef H5
|
||||
const uploadUrl = '/api/upload';
|
||||
const uploadUrl = endpoint;
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
const uploadUrl = 'https://peiww.gynhc.com/api/upload';
|
||||
const uploadUrl = `https://peiww.gynhc.com${endpoint}`;
|
||||
// #endif
|
||||
|
||||
uni.uploadFile({
|
||||
@@ -1058,7 +1060,7 @@ export function uploadImage(tempFilePath) {
|
||||
const data = JSON.parse(uploadRes.data);
|
||||
if (data && data.code === 20000 && data.data && data.data.url) {
|
||||
let finalUrl = data.data.url;
|
||||
// 非H5平台(小程序端)图片访问需补全公网域名
|
||||
// 非H5平台(小程序端)媒体访问需补全公网域名
|
||||
// #ifndef H5
|
||||
if (finalUrl.startsWith('/uploads/')) {
|
||||
finalUrl = `https://peiww.gynhc.com${finalUrl}`;
|
||||
@@ -1066,14 +1068,14 @@ export function uploadImage(tempFilePath) {
|
||||
// #endif
|
||||
resolve(finalUrl);
|
||||
} else {
|
||||
reject(new Error((data && data.message) || '上传解析异常'));
|
||||
reject(new Error((data && data.message) || `${kindLabel}上传解析异常`));
|
||||
}
|
||||
} catch (e) {
|
||||
reject(new Error('上传数据返回格式错误'));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(new Error(err.errMsg || '图片上传网络异常'));
|
||||
reject(new Error(err.errMsg || `${kindLabel}上传网络异常`));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1081,6 +1083,25 @@ export function uploadImage(tempFilePath) {
|
||||
|
||||
/**
|
||||
* 客户端前端前置检测文本安全 (对接 security.msgSecCheck)
|
||||
/**
|
||||
* 真实上传本地图片至服务端持久化静态存储
|
||||
* @param {string} tempFilePath 本地图片临时路径
|
||||
* @returns {Promise<string>} 返回持久化公网图片访问路径 (形如 /uploads/img_xxx.png)
|
||||
*/
|
||||
export function uploadImage(tempFilePath) {
|
||||
return uploadMediaFile(tempFilePath, '/api/upload', '图片');
|
||||
}
|
||||
|
||||
/**
|
||||
* 真实上传本地短视频至服务端持久化静态存储
|
||||
* @param {string} tempFilePath 本地视频临时路径
|
||||
* @returns {Promise<string>} 返回持久化公网视频访问路径 (形如 /uploads/video_xxx.mp4)
|
||||
*/
|
||||
export function uploadVideo(tempFilePath) {
|
||||
return uploadMediaFile(tempFilePath, '/api/upload/video', '视频');
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
export async function checkTextSecurity(content) {
|
||||
try {
|
||||
|
||||
在新工单中引用
屏蔽一个用户