Commit 318d8afd authored by lijin's avatar lijin

优化上传

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