Commit 318d8afd authored by lijin's avatar lijin

优化上传

parent 94603d86
......@@ -416,21 +416,21 @@ export function backhaul(params) {
export function getGoogleTokenList() {
return request({
// url: 'http://localhost:8567/youtube/getTokenList',
url: 'https://putinapi.zhangxindiet.com/youtube/getTokenList',
url: process.env.PUTIN_API + '/youtube/getTokenList',
method: "get",
})
}
export function getYoutubeAccountList() {
return request({
// url: 'http://localhost:8567/youtube/getYoutubeAccount',
url: 'https://putinapi.zhangxindiet.com/youtube/getYoutubeAccount',
url: process.env.PUTIN_API + '/youtube/getYoutubeAccount',
method: "get",
})
}
export function getYoutubeCategoryId(params) {
return request({
// url: 'http://localhost:8567/youtube/getYoutubeCategoryId',
url: 'https://putinapi.zhangxindiet.com/youtube/getYoutubeCategoryId',
url: process.env.PUTIN_API + '/youtube/getYoutubeCategoryId',
method: "get",
params
})
......@@ -438,7 +438,7 @@ export function getYoutubeCategoryId(params) {
export function getListMyPlaylists(params) {
return request({
// url: 'http://localhost:8567/youtube/getListMyPlaylists',
url: 'https://putinapi.zhangxindiet.com/youtube/getListMyPlaylists',
url: process.env.PUTIN_API + '/youtube/getListMyPlaylists',
method: "get",
params
})
......@@ -446,7 +446,7 @@ export function getListMyPlaylists(params) {
export function getVideo(params) {
return request({
// url: 'http://localhost:8567/material/business/video/list',
url: 'https://putinapi.zhangxindiet.com/material/business/video/list',
url: process.env.PUTIN_API + '/material/business/video/list',
method: "get",
params
})
......@@ -455,14 +455,14 @@ export function getVideo(params) {
export function getTotalVideoNumber() {
return request({
// url: 'http://localhost:8567/material/business/video/total',
url: 'https://putinapi.zhangxindiet.com/material/business/video/total',
url: process.env.PUTIN_API + '/material/business/video/total',
method: 'get'
})
}
export function uploadFromOss(data) {
return request({
// url: 'http://localhost:8567/youtube/uploadFromOss',
url: 'https://putinapi.zhangxindiet.com/youtube/uploadFromOss',
url: process.env.PUTIN_API + '/youtube/uploadFromOss',
method: 'post',
data
})
......@@ -471,7 +471,7 @@ export function uploadFromOss(data) {
export function getVideoLog(params) {
return request({
// url: 'http://localhost:8567/youtube/getYoutubeUploadLogList',
url: 'https://putinapi.zhangxindiet.com/youtube/getYoutubeUploadLogList',
url: process.env.PUTIN_API + '/youtube/getYoutubeUploadLogList',
method: 'get',
params
})
......@@ -481,7 +481,7 @@ export function getVideoLog(params) {
export function getVideoLogCount() {
return request({
// url: 'http://localhost:8567/youtube/getCount',
url: 'https://putinapi.zhangxindiet.com/youtube/getCount',
url: process.env.PUTIN_API + '/youtube/getCount',
method: 'get',
})
}
......@@ -500,7 +500,7 @@ export function fetchConversionAction(data) {
export function getMaterialDirectoriesTree() {
return request({
// url: 'http://localhost:8567/material/business/youtube/directories/tree',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/directories/tree',
url: process.env.PUTIN_API + '/material/business/youtube/directories/tree',
method: 'get',
})
}
......@@ -508,7 +508,7 @@ export function getMaterialDirectoriesTree() {
export function getDirectoryById(params) {
return request({
// url: 'http://localhost:8567/material/business/youtube/getDirectoryById',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/getDirectoryById',
url: process.env.PUTIN_API + '/material/business/youtube/getDirectoryById',
method: 'get',
params
})
......@@ -516,7 +516,7 @@ export function getDirectoryById(params) {
export function createDirectory(params) {
return request({
// url: 'http://localhost:8567/material/business/youtube/createdirectories',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/createdirectories',
url: process.env.PUTIN_API + '/material/business/youtube/createdirectories',
method: 'get',
params
})
......@@ -525,7 +525,7 @@ export function createDirectory(params) {
export function updateDirectory() {
return request({
// url: 'http://localhost:8567/business/youtube/updateDirectory',
url: 'https://putinapi.zhangxindiet.com/business/youtube/updateDirectory',
url: process.env.PUTIN_API + '/business/youtube/updateDirectory',
method: 'get',
})
}
......@@ -533,7 +533,7 @@ export function updateDirectory() {
export function getMaterialCount(params) {
return request({
// url: 'http://localhost:8567/material/count',
url: 'https://putinapi.zhangxindiet.com/material/count',
url: process.env.PUTIN_API + '/material/count',
method: 'get',
params
})
......@@ -542,7 +542,7 @@ export function getMaterialCount(params) {
export function movematerial(params) {
return request({
// url: 'http://localhost:8567/material/business/youtube/movematerial',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/movematerial',
url: process.env.PUTIN_API + '/material/business/youtube/movematerial',
method: 'get',
params
})
......@@ -552,7 +552,7 @@ export function movematerial(params) {
export function deleteDirectory(params) {
return request({
// url: 'http://localhost:8567/material/business/youtube/deleteDirectory',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/deleteDirectory',
url: process.env.PUTIN_API + '/material/business/youtube/deleteDirectory',
method: 'get',
params
})
......@@ -561,7 +561,7 @@ export function deleteDirectory(params) {
export function uploadMaterial(body,params){
return request({
// url: 'http://localhost:8567/material/business/youtube/uploadVideo',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/uploadVideo',
url: process.env.PUTIN_API + '/material/business/youtube/uploadVideo',
method: 'post',
headers: { 'Content-Type': 'multipart/form-data' },
data: body, // Body 数据
......@@ -573,7 +573,7 @@ export function uploadMaterial(body,params){
export function getMaterialDesigners() {
return request({
// url: 'http://localhost:8567/material/getMaterialDesigners',
url: 'https://putinapi.zhangxindiet.com/material/getMaterialDesigners',
url: process.env.PUTIN_API + '/material/getMaterialDesigners',
method: 'get',
})
......@@ -581,7 +581,7 @@ export function getMaterialDesigners() {
export function getMaterialsByTag(params) {
return request({
// url: 'http://localhost:8567/material/business/youtube/getMaterialsByTag',
url: 'https://putinapi.zhangxindiet.com/material/business/youtube/getMaterialsByTag',
url: process.env.PUTIN_API + '/material/business/youtube/getMaterialsByTag',
method: 'get',
params
......@@ -590,7 +590,7 @@ export function getMaterialsByTag(params) {
export function getAllTags() {
return request({
// url: 'http://localhost:8567/material/getAllTags',
url: 'https://putinapi.zhangxindiet.com/material/getAllTags',
url: process.env.PUTIN_API + '/material/getAllTags',
method: 'get',
})
......@@ -598,7 +598,7 @@ export function getAllTags() {
export function getYoutubeUploadDetaillist() {
return request({
// url: 'http://localhost:8567/material/getYoutubeUploadDetaillist',
url: 'https://putinapi.zhangxindiet.com/material/getYoutubeUploadDetaillist',
url: process.env.PUTIN_API + '/material/getYoutubeUploadDetaillist',
method: 'get',
})
......
......@@ -678,27 +678,35 @@ export default {
return;
}
// 2. 创建 FormData 对象
const formData = new FormData();
// 2. 逐个上传文件
try {
for (let i = 0; i < this.fileList.length; i++) {
const file = this.fileList[i];
// 3. 添加文件到 FormData
this.fileList.forEach(file => {
// 3. 创建 FormData 对象
const formData = new FormData();
formData.append('files', file.raw);
});
formData.append('tags', this.uploadVideoForm.tags);
formData.append('director', this.uploadVideoForm.director);
formData.append('resType', this.uploadVideoForm.resType);
formData.append('directoryId', this.uploadVideoForm.directoryId);
// 5. 发送上传请求
try {
// 4. 发送上传请求
const response = await uploadMaterial(formData);
if (response && response.status === 200) {
this.$message.success('上传成功');
this.$message.success(`文件 ${file.name} 上传成功`);
} else {
this.$message.error(`文件 ${file.name} 上传失败: ${response.msg || '未知错误'}`);
return; // 如果某个文件上传失败,停止后续文件的上传
}
}
// 5. 所有文件上传成功后的操作
this.$message.success('所有文件上传成功');
this.uploadVideoDialogVisible = false;
this.fetchMaterialsByDirectoryId(this.currentDirectory); // 刷新文件列表
// 6. 清空表单和文件列表
this.uploadVideoForm = {
materialName: '',
......@@ -709,9 +717,7 @@ export default {
};
this.fileList = [];
this.$refs.uploadVideo.clearFiles(); // 清空 el-upload 组件的文件列表
} else {
this.$message.error(response.msg || '上传失败');
}
} catch (error) {
this.$message.error('上传失败');
console.error('上传失败:', error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment