From 4f7e206e428b543c0cb5dc21df7c64c30be6b854 Mon Sep 17 00:00:00 2001 From: Timothy Yin Date: Mon, 10 Feb 2025 18:45:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=AE=E8=AF=BE=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=89=87=E5=A4=B4=E6=A8=A1=E6=9D=BF=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ModalVideoTitleSelect.vue | 187 ++++++++++++++++++++++ components/SlideCreateCourse.vue | 226 ++++++++++++++++++++------- 2 files changed, 354 insertions(+), 59 deletions(-) create mode 100644 components/ModalVideoTitleSelect.vue diff --git a/components/ModalVideoTitleSelect.vue b/components/ModalVideoTitleSelect.vue new file mode 100644 index 0000000..01e3e4f --- /dev/null +++ b/components/ModalVideoTitleSelect.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/components/SlideCreateCourse.vue b/components/SlideCreateCourse.vue index 020d887..63f5604 100644 --- a/components/SlideCreateCourse.vue +++ b/components/SlideCreateCourse.vue @@ -14,10 +14,17 @@ const loginState = useLoginState() const creationForm = ref() const creationPending = ref(false) const isDigitalSelectorOpen = ref(false) +const isTitlesSelectorOpen = ref(false) const createCourseSchema = object({ - task_title: string().trim().min(4, '标题必须大于4个字符').max(20, '标题不能超过20个字符').required('请输入微课标题'), + task_title: string() + .trim() + .min(4, '标题必须大于4个字符') + .max(20, '标题不能超过20个字符') + .required('请输入微课标题'), digital_human_id: number().not([0], '请选择数字人'), + opening_url: string().url().notRequired().default(''), + ending_url: string().url().notRequired().default(''), gen_server: string().required(), speed: number().default(1.0).min(0.5).max(1.5).required(), }) @@ -27,20 +34,30 @@ type CreateCourseSchema = InferType const createCourseState = reactive({ task_title: undefined, digital_human_id: 0, + opening_url: '', + ending_url: '', gen_server: 'main', speed: 1.0, }) const selected_file = ref(null) const selected_digital_human = ref(null) +const selected_titles = ref(null) watchEffect(() => { if (selected_digital_human.value) { - createCourseState.digital_human_id = selected_digital_human.value.model_id || selected_digital_human.value.id! + createCourseState.digital_human_id = + selected_digital_human.value.model_id || selected_digital_human.value.id! + } + if (selected_titles.value) { + createCourseState.opening_url = selected_titles.value.opening_file + createCourseState.ending_url = selected_titles.value.ending_file } }) -const onCreateCourseSubmit = async (event: FormSubmitEvent) => { +const onCreateCourseSubmit = async ( + event: FormSubmitEvent +) => { if (!selected_file.value) { toast.add({ title: '未选择文件', @@ -52,8 +69,11 @@ const onCreateCourseSubmit = async (event: FormSubmitEvent) } creationPending.value = true // upload PPTX file - useFileGo(selected_file.value[0]).then(url => { - useFetchWrapped>('App.Digital_Convert.Create', { + useFileGo(selected_file.value[0]).then((url) => { + useFetchWrapped< + req.gen.CourseGenCreate & AuthedRequest, + BaseResponse + >('App.Digital_Convert.Create', { token: loginState.token!, user_id: loginState.user.id, task_title: event.data.task_title, @@ -62,36 +82,38 @@ const onCreateCourseSubmit = async (event: FormSubmitEvent) ppt_url: url, digital_human_id: event.data.digital_human_id, custom_video: '[]', - opening_url: '', - ending_url: '', - }).then(res => { - if (res.data.record_status === 1) { - toast.add({ - title: '创建成功', - description: '已加入生成队列', - color: 'green', - icon: 'i-tabler-check', - }) - emit('success') - slide.close() - } else { + opening_url: event.data.opening_url || '', + ending_url: event.data.opening_url || '', + }) + .then((res) => { + if (res.data.record_status === 1) { + toast.add({ + title: '创建成功', + description: '已加入生成队列', + color: 'green', + icon: 'i-tabler-check', + }) + emit('success') + slide.close() + } else { + toast.add({ + title: '创建失败', + description: res.msg || '未知错误', + color: 'red', + icon: 'i-tabler-alert-triangle', + }) + } + creationPending.value = false + }) + .catch((e) => { + creationPending.value = false toast.add({ title: '创建失败', - description: res.msg || '未知错误', + description: e.message || '未知错误', color: 'red', icon: 'i-tabler-alert-triangle', }) - } - creationPending.value = false - }).catch(e => { - creationPending.value = false - toast.add({ - title: '创建失败', - description: e.message || '未知错误', - color: 'red', - icon: 'i-tabler-alert-triangle', }) - }) }) } @@ -99,12 +121,18 @@ const onCreateCourseSubmit = async (event: FormSubmitEvent)