Commit 599d2e2e by haojie

草稿修改

parent 05fba584
......@@ -33,6 +33,10 @@ export default defineComponent({
type: String,
default: '选择文件',
},
computedDuration: {
type: Boolean,
default: false,
},
},
emits: ['update:modelValue', 'change', 'update:totalSize', 'update:audioTotolTime'],
setup(props, { emit }) {
......@@ -82,23 +86,25 @@ export default defineComponent({
// 是否需要计算文件总时长,音频或视频
const computedTotalTime = () => {
return typeof props.audioTotolTime === 'number';
return typeof props.audioTotolTime === 'number' || props.computedDuration;
};
// 音频可以播放
const audioCanplay = (item: any, index: number) => {
if (fileList.value[index]) {
let dom: HTMLAudioElement = fileList.value[index].ref;
if (dom) {
fileList.value[index].time = dom.duration;
fileList.value[index].duration = dom.duration;
}
let total = 0;
fileList.value.forEach((item: any) => {
if (item.time && item.url) {
total += item.time;
if (item.duration && item.url) {
total += item.duration;
}
});
// 更新总时长
emit('update:audioTotolTime', total);
}
};
// 文件是否上传过
......@@ -279,8 +285,8 @@ export default defineComponent({
} else if (item.audio_url) {
list.push(item.audio_url);
}
if (item.time) {
totalTime += item.time;
if (item.duration) {
totalTime += item.duration;
}
});
submitList(list);
......
......@@ -129,3 +129,6 @@ export const emailReg = /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,8}){1,2}$/;
// 创建直播页面路由记录key
export const createLiveRouteKey = 'create_live_route_key';
// 音频上传格式限制
export const audioAccept = 'wav';
......@@ -123,7 +123,11 @@ export const processTextCallback = () => {
old_content: '',
name: '',
uuid: v4(),
duration: 0,
};
if (it.duration) {
params.duration = parseInt(it.duration);
}
// 草稿类型的
if (type == 'edit_drafts') {
if (it.children && it.children.length > 1) {
......@@ -212,6 +216,7 @@ export const processTextCallback = () => {
try {
let res: any = await createLiveTask(filterFiled());
if (res.code == 0) {
console.log('提交的参数', JSON.stringify(filterFiled()));
console.log('创建成功-', res.data.id);
live_task_id.value = res.data.id;
return true;
......
<template>
<div class="">
<Customizable
accept="wav"
:accept="audioAccept"
:submit="submit"
:dialogInfo="dialogInfo"
:icon="getIcon()"
......@@ -28,6 +28,7 @@ export default {
</script>
<script lang="tsx" setup>
import { audioAccept } from '@/constants/token';
import Record from './components/Record.vue';
import MyDigitalPerson from './components/MyDigitalPerson.vue';
import CustomTabs from '@/components/CustomTabs';
......
......@@ -102,7 +102,7 @@
v-model="tonesFile"
:config="ossConfig"
:uploadInfo="uploadInfo"
accept="wav"
:accept="audioAccept"
class="reset-upload-dialog"
></Upload>
</CustomTabPanel>
......@@ -145,6 +145,7 @@ import { onMounted, reactive, ref, watch } from 'vue';
import { show_message } from '@/utils/tool';
import { getUploadConfig, getTonesList } from '@/service/Common';
import { createLiveInteraction } from '@/utils/api/userApi';
import { audioAccept } from '@/constants/token';
const props = withDefaults(
defineProps<{
visible: boolean;
......
......@@ -148,8 +148,9 @@
<MultipleUpload
v-model="item.data"
:config="ossConfig"
:computedDuration="true"
label="选择音频"
accept="wav"
:accept="audioAccept"
@change="uploadEdit"
></MultipleUpload>
</div>
......@@ -161,8 +162,9 @@
<MultipleUpload
v-model="mp3UrlList"
:config="ossConfig"
:computedDuration="true"
label="选择音频"
accept="wav"
:accept="audioAccept"
@change="createUploadFile"
></MultipleUpload>
</div>
......@@ -193,6 +195,7 @@ import ScriptTemplate from '@/components/ScriptTemplate.vue';
import Select from '@/components/Select.vue';
import SelectionPopup from '@/components/SelectionPopup.vue';
import { show_message, isDev, ecursionDeepCopy } from '@/utils/tool';
import { audioAccept } from '@/constants/token';
import {
createLiveKeys,
scriptTypeList,
......
......@@ -80,6 +80,7 @@ import {
dimensionalConvert,
ecursionDeepCopy,
getDurationOfAudioFile,
getFile,
} from '@/utils/tool';
import { useStore } from 'vuex';
import { createLiveKeys, scriptTypeText, scriptTypePhonetics, mergeSameAudio } from '@/service/CreateLive';
......@@ -93,8 +94,17 @@ import { processTextCallback } from '@/hooks/useScript';
import CustomException from '@/utils/error';
import { v4 } from 'uuid';
import { splitAudio } from '@/utils/audio';
const { loading, initNum, currentSetp, live_task_id, openInterval, filterFiled, submitSuccessed, uploadToAly } =
processTextCallback();
const {
loading,
initNum,
currentSetp,
live_task_id,
audioStart,
openInterval,
filterFiled,
submitSuccessed,
uploadToAly,
} = processTextCallback();
const [commitInfo] = useLiveInfoSubmit();
// 音频切割时长
......@@ -448,6 +458,21 @@ const audioSplit = async () => {
// 编辑时没有修改参数
continue;
}
if (
row.duration &&
row.duration > audioSplitNum &&
row.content &&
row.content.indexOf('|') == -1 &&
row.old_content &&
!row.file?.raw
) {
console.log('大于5分钟,开始下载文件');
// 没有文件时,下载
let file = await getFile(row.old_content);
row.file = {};
row.file.raw = file;
console.log(row.file);
}
if (row.file && row.file.raw) {
// 文件时长
let fileDuration = await getDurationOfAudioFile(row.file.raw);
......
......@@ -406,10 +406,12 @@ export const getDurationOfAudioFile = (file: File) => {
// 从二维数组中合并同类
export const mergedArray = (arr: any[], key: string = 'uuid', first: string = 'is_old') => {
const list = arr.reduce((result, subArray) => {
let newSubArray = ecursionDeepCopy(subArray);
let newList = [];
arr.forEach((item: any) => {
let result = [];
let newSubArray = ecursionDeepCopy(item);
// 先找出first
const existingObj = newSubArray.filter((item) => item[first]);
const existingObj = newSubArray.filter((it) => it[first]);
existingObj.forEach((item: any) => {
item.children = [];
});
......@@ -417,17 +419,15 @@ export const mergedArray = (arr: any[], key: string = 'uuid', first: string = 'i
result.push(...existingObj);
}
newSubArray.forEach((obj) => {
const existingIndex = result.findIndex((item) => item.uuid === obj.uuid && !obj[first] && !obj.removed);
// console.log(obj, 'obj');
// console.log(existingIndex, 'index');
const existingIndex = result.findIndex((it) => it.uuid === obj.uuid && !obj[first] && !obj.removed);
if (existingIndex !== -1) {
// 标记
obj.removed = true;
result[existingIndex].children.push(obj);
}
});
return result;
}, []);
newList.push(result);
});
// 防止对象引用重复
return ecursionDeepCopy([list]);
return ecursionDeepCopy(newList);
};
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