feat: 写手端上传接口替换
This commit is contained in:
@ -144,3 +144,17 @@ export const postWorksByLinkWriter = (writerCode: string, params = {}) => {
|
|||||||
export const postWorksByFileWriter = (params = {}, config = {}) => {
|
export const postWorksByFileWriter = (params = {}, config = {}) => {
|
||||||
return Http.post('/v1/writer/works/by-file', params, config);
|
return Http.post('/v1/writer/works/by-file', params, config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取图片上传地址
|
||||||
|
export const getImagePreSignedUrlWriter = (writerCode: string,params = {}) => {
|
||||||
|
return Http.get('/v1/writer/oss/image-pre-signed-url', params, {
|
||||||
|
headers: { 'writer-code': writerCode },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取视频上传地址
|
||||||
|
export const getVideoPreSignedUrlWriter = (writerCode: string,params = {}) => {
|
||||||
|
return Http.get('/v1/writer/oss/video-pre-signed-url', params, {
|
||||||
|
headers: { 'writer-code': writerCode },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@ -7,9 +7,8 @@ import TextOverTips from '@/components/text-over-tips';
|
|||||||
import ImgBox from './img-box';
|
import ImgBox from './img-box';
|
||||||
|
|
||||||
import { formatFileSize, getVideoInfo, formatDuration, formatUploadSpeed } from '@/utils/tools';
|
import { formatFileSize, getVideoInfo, formatDuration, formatUploadSpeed } from '@/utils/tools';
|
||||||
import { getProjectList } from '@/api/all/propertyMarketing';
|
|
||||||
import { EnumManuscriptType } from '@/views/creative-generation-workshop/manuscript/list/constants.ts';
|
import { EnumManuscriptType } from '@/views/creative-generation-workshop/manuscript/list/constants.ts';
|
||||||
import { getImagePreSignedUrl, getVideoPreSignedUrl } from '@/api/all/common';
|
import { getVideoPreSignedUrlWriter, getImagePreSignedUrlWriter } from '@/api/all/generationWorkshop-writer';
|
||||||
|
|
||||||
// import icon1 from '@/assets/img/creative-generation-workshop/icon-close.png';
|
// import icon1 from '@/assets/img/creative-generation-workshop/icon-close.png';
|
||||||
|
|
||||||
@ -56,6 +55,7 @@ export default {
|
|||||||
},
|
},
|
||||||
emits: ['reValidate', 'change', 'update:modelValue', 'updateVideoInfo'],
|
emits: ['reValidate', 'change', 'update:modelValue', 'updateVideoInfo'],
|
||||||
setup(props, { emit, expose }) {
|
setup(props, { emit, expose }) {
|
||||||
|
const route = useRoute();
|
||||||
const formRef = ref(null);
|
const formRef = ref(null);
|
||||||
const formData = ref({});
|
const formData = ref({});
|
||||||
const uploadRef = ref(null);
|
const uploadRef = ref(null);
|
||||||
@ -65,6 +65,8 @@ export default {
|
|||||||
return match ? match[1].toLowerCase() : '';
|
return match ? match[1].toLowerCase() : '';
|
||||||
}
|
}
|
||||||
const isVideo = computed(() => formData.value.type === EnumManuscriptType.Video);
|
const isVideo = computed(() => formData.value.type === EnumManuscriptType.Video);
|
||||||
|
const writerCode = computed(() => route.params.writerCode);
|
||||||
|
|
||||||
const setVideoInfo = (file) => {
|
const setVideoInfo = (file) => {
|
||||||
formData.value.videoInfo.percent = 0;
|
formData.value.videoInfo.percent = 0;
|
||||||
formData.value.videoInfo.name = file.name;
|
formData.value.videoInfo.name = file.name;
|
||||||
@ -133,7 +135,7 @@ export default {
|
|||||||
} = option;
|
} = option;
|
||||||
setVideoInfo(file);
|
setVideoInfo(file);
|
||||||
|
|
||||||
const response = await getVideoPreSignedUrl({ suffix: getFileExtension(file.name) });
|
const response = await getVideoPreSignedUrlWriter(writerCode.value, { suffix: getFileExtension(file.name) });
|
||||||
const { file_name, upload_url, file_url } = response?.data;
|
const { file_name, upload_url, file_url } = response?.data;
|
||||||
if (!upload_url) {
|
if (!upload_url) {
|
||||||
throw new Error('未能获取有效的预签名上传地址');
|
throw new Error('未能获取有效的预签名上传地址');
|
||||||
@ -171,7 +173,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { name, size, type } = file;
|
const { name, size, type } = file;
|
||||||
const response = await getImagePreSignedUrl({ suffix: getFileExtension(name) });
|
const response = await getImagePreSignedUrlWriter(writerCode.value, { suffix: getFileExtension(name) });
|
||||||
const { file_name, upload_url, file_url } = response?.data;
|
const { file_name, upload_url, file_url } = response?.data;
|
||||||
|
|
||||||
const blob = new Blob([file], { type });
|
const blob = new Blob([file], { type });
|
||||||
|
|||||||
Reference in New Issue
Block a user