wip: create course generate
This commit is contained in:
@@ -6,6 +6,7 @@ import { type InferType, number, object, string } from 'yup'
|
||||
import type { FormSubmitEvent } from '#ui/types'
|
||||
|
||||
const loginState = useLoginState()
|
||||
const toast = useToast()
|
||||
|
||||
const isCreateCourseModalOpen = ref(false)
|
||||
|
||||
@@ -23,7 +24,9 @@ const {
|
||||
to_user_id: loginState.user.id,
|
||||
page: 1,
|
||||
perpage: 10,
|
||||
}),
|
||||
}), {
|
||||
transform: res => res?.data.items || [],
|
||||
},
|
||||
)
|
||||
|
||||
const onCreateCourseClick = () => {
|
||||
@@ -44,8 +47,36 @@ const createCourseState = reactive({
|
||||
speed: 1.0,
|
||||
})
|
||||
|
||||
const selected_file = ref<File[] | null>(null)
|
||||
|
||||
const onCreateCourseSubmit = async (event: FormSubmitEvent<CreateCourseSchema>) => {
|
||||
console.log(event.data)
|
||||
if (!selected_file.value) {
|
||||
toast.add({
|
||||
title: '未选择文件',
|
||||
description: '请先选择 PPTX 文件',
|
||||
color: 'red',
|
||||
icon: 'i-tabler-alert-triangle',
|
||||
})
|
||||
return
|
||||
}
|
||||
// upload PPTX file
|
||||
useFileGo(selected_file.value[0]).then(url => {
|
||||
useFetchWrapped<req.gen.CourseGenCreate & AuthedRequest, resp.gen.CourseGenCreate>('App.Digital_Convert.Create', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id,
|
||||
task_title: event.data.task_title,
|
||||
gen_server: event.data.gen_server as 'main' | 'standby1',
|
||||
speed: event.data.speed,
|
||||
ppt_url: url,
|
||||
digital_human_id: '40696',
|
||||
custom_video: '[]',
|
||||
opening_url: '',
|
||||
ending_url: '',
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -63,12 +94,10 @@ const onCreateCourseSubmit = async (event: FormSubmitEvent<CreateCourseSchema>)
|
||||
/>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<pre>{{ JSON.stringify(courseList, null, 2) }}</pre>
|
||||
<div class="relative grid grid-cols-1 sm:grid-cols-2 2xl:grid-cols-4 gap-4">
|
||||
|
||||
<CGTaskCard v-for="i in [...new Array(9)]"/>
|
||||
|
||||
<CGTaskCard v-for="(course, index) in courseList" :key="index" :course="course"/>
|
||||
</div>
|
||||
<pre class="overflow-hidden">{{ JSON.stringify(courseList, null, 2) }}</pre>
|
||||
</div>
|
||||
|
||||
<UModal
|
||||
@@ -99,19 +128,19 @@ const onCreateCourseSubmit = async (event: FormSubmitEvent<CreateCourseSchema>)
|
||||
>
|
||||
<div class="flex justify-between gap-2 *:flex-1">
|
||||
<UFormGroup label="微课标题" name="task_title">
|
||||
<UInput v-model="createCourseState.task_title"/>
|
||||
<UInput v-model="createCourseState.task_title" placeholder="请输入微课标题"/>
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup label="生成线路" name="gen_server">
|
||||
<USelectMenu
|
||||
v-model="createCourseState.gen_server"
|
||||
:options="[{
|
||||
label: '主线路',
|
||||
value: 'main',
|
||||
}, {
|
||||
label: '备用线路',
|
||||
value: 'standby1',
|
||||
}]"
|
||||
label: '主线路',
|
||||
value: 'main',
|
||||
}, {
|
||||
label: '备用线路',
|
||||
value: 'standby1',
|
||||
}]"
|
||||
option-attribute="label"
|
||||
value-attribute="value"
|
||||
/>
|
||||
@@ -130,7 +159,10 @@ const onCreateCourseSubmit = async (event: FormSubmitEvent<CreateCourseSchema>)
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup label="PPT 文件">
|
||||
<FileDnD accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
|
||||
<FileDnD
|
||||
accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
||||
@change="file => selected_file = file"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<div class="flex justify-end space-x-4 pt-4">
|
||||
|
||||
Reference in New Issue
Block a user