refactor!: 升级 @nuxt/ui@3,重构所有页面和组件,调整配置,移除不在需求中的页面

This commit is contained in:
2026-02-10 18:07:44 +08:00
parent d0bca215c1
commit 75f1987be3
49 changed files with 4892 additions and 6599 deletions

View File

@@ -5,9 +5,8 @@ import ModalDigitalHumanSelect from '~/components/ModalDigitalHumanSelect.vue'
import type { FormSubmitEvent } from '#ui/types'
import { useFetchWrapped } from '~/composables/useFetchWrapped'
const emit = defineEmits(['success'])
const emit = defineEmits(['success', 'close'])
const slide = useSlideover()
const toast = useToast()
const loginState = useLoginState()
@@ -65,14 +64,14 @@ const onCreateCourseSubmit = async (
toast.add({
title: '未选择文件',
description: '请先选择 PPTX 文件',
color: 'red',
color: 'error',
icon: 'i-tabler-alert-triangle',
})
return
}
creationPending.value = true
// upload PPTX file
useFileGo(selected_file.value[0], 'ppt').then((url) => {
useFileGo(selected_file.value[0]!, 'ppt').then((url) => {
useFetchWrapped<
req.gen.CourseGenCreate & AuthedRequest,
BaseResponse<resp.gen.CourseGenCreate>
@@ -93,16 +92,16 @@ const onCreateCourseSubmit = async (
toast.add({
title: '创建成功',
description: '已加入生成队列',
color: 'green',
color: 'success',
icon: 'i-tabler-check',
})
emit('success')
slide.close()
emit('close')
} else {
toast.add({
title: '创建失败',
description: res.msg || '未知错误',
color: 'red',
color: 'error',
icon: 'i-tabler-alert-triangle',
})
}
@@ -113,7 +112,7 @@ const onCreateCourseSubmit = async (
toast.add({
title: '创建失败',
description: e.message || '未知错误',
color: 'red',
color: 'error',
icon: 'i-tabler-alert-triangle',
})
})
@@ -122,239 +121,229 @@ const onCreateCourseSubmit = async (
</script>
<template>
<USlideover prevent-close>
<UCard
:ui="{
body: { base: 'flex-1' },
ring: '',
divide: 'divide-y divide-gray-100 dark:divide-gray-800',
}"
class="flex flex-col flex-1"
>
<template #header>
<div class="flex items-center justify-between">
<h3
class="text-base font-semibold leading-6 text-gray-900 dark:text-white"
>
新建微课视频
</h3>
<UButton
class="-my-1"
color="gray"
icon="i-tabler-x"
variant="ghost"
@click="slide.close()"
/>
</div>
</template>
<UForm
ref="creationForm"
:schema="createCourseSchema"
:state="createCourseState"
class="space-y-4"
@submit="onCreateCourseSubmit"
<USlideover
:dismissible="false"
title="新建微课视频"
>
<template #content>
<UCard
:ui="{
body: 'flex-1',
}"
class="flex flex-1 flex-col"
>
<div class="flex justify-between gap-2 *:flex-1">
<UFormGroup
label="微课标题"
name="task_title"
required
>
<UInput
v-model="createCourseState.task_title"
placeholder="请输入微课标题"
<template #header>
<div class="flex items-center justify-between">
<h3
class="text-base font-semibold leading-6 text-gray-900 dark:text-white"
>
新建微课视频
</h3>
<UButton
class="-my-1"
color="neutral"
icon="i-tabler-x"
variant="ghost"
@click="$emit('close')"
/>
</UFormGroup>
</div>
</div>
</template>
<div class="grid grid-cols-2 gap-2">
<UFormGroup
label="数字人"
name="digital_human_id"
<UForm
ref="creationForm"
:schema="createCourseSchema"
:state="createCourseState"
class="space-y-4"
@submit="onCreateCourseSubmit"
>
<div class="flex justify-between gap-2 *:flex-1">
<UFormField
label="微课标题"
name="task_title"
required
>
<UInput
v-model="createCourseState.task_title"
placeholder="请输入微课标题"
/>
</UFormField>
</div>
<div class="grid grid-cols-2 gap-2">
<UFormField
label="数字人"
name="digital_human_id"
required
>
<div
:class="{ 'shadow-inner': !!selected_digital_human }"
class="flex cursor-pointer select-none items-center gap-2 rounded-md bg-neutral-100 p-2 transition-all dark:bg-neutral-800"
@click="isDigitalSelectorOpen = true"
>
<div
class="flex aspect-square w-12 items-center justify-center overflow-hidden rounded-md border dark:border-neutral-700"
>
<UIcon
v-if="!selected_digital_human"
class="text-2xl opacity-50"
name="i-tabler-user-screen"
/>
<NuxtImg
v-else
:src="selected_digital_human?.avatar"
/>
</div>
<div class="flex flex-col text-sm font-medium text-neutral-400">
<span
:class="!!selected_digital_human ? 'text-neutral-600' : ''"
>
{{ selected_digital_human?.name || '点击选择数字人' }}
</span>
<span
v-if="selected_digital_human?.description"
class="text-2xs"
>
{{ selected_digital_human?.description }}
</span>
</div>
</div>
</UFormField>
<UFormField
label="视频片头片尾"
name="opening"
>
<div
:class="{ 'shadow-inner': !!selected_titles }"
class="flex cursor-pointer select-none items-center gap-2 rounded-md bg-neutral-100 p-2 transition-all dark:bg-neutral-800"
@click="isTitlesSelectorOpen = true"
>
<div
class="flex aspect-square w-12 items-center justify-center overflow-hidden rounded-md border dark:border-neutral-700"
>
<UIcon
v-if="!selected_titles"
class="text-2xl opacity-50"
name="i-tabler-brackets-contain"
/>
<NuxtImg
v-else
:src="selected_titles?.opening_url"
/>
</div>
<div class="flex flex-col text-sm font-medium text-neutral-400">
<span :class="!!selected_titles ? 'text-neutral-600' : ''">
{{ selected_titles?.title || '点击选择片头' }}
</span>
<span
v-if="selected_titles?.description"
class="text-2xs"
>
{{ selected_titles?.description }}
</span>
</div>
</div>
</UFormField>
</div>
<UFormField
label="PPT 文件"
required
>
<div
:class="{ 'shadow-inner': !!selected_digital_human }"
class="flex items-center gap-2 bg-neutral-100 dark:bg-neutral-800 p-2 rounded-md cursor-pointer select-none transition-all"
@click="isDigitalSelectorOpen = true"
>
<div
class="w-12 aspect-square border dark:border-neutral-700 rounded-md flex justify-center items-center overflow-hidden"
>
<UIcon
v-if="!selected_digital_human"
class="text-2xl opacity-50"
name="i-tabler-user-screen"
/>
<NuxtImg
v-else
:src="selected_digital_human?.avatar"
/>
</div>
<div class="flex flex-col text-neutral-400 text-sm font-medium">
<span
:class="!!selected_digital_human ? 'text-neutral-600' : ''"
>
{{ selected_digital_human?.name || '点击选择数字人' }}
</span>
<span
v-if="selected_digital_human?.description"
class="text-2xs"
>
{{ selected_digital_human?.description }}
</span>
</div>
</div>
</UFormGroup>
<UFormGroup
label="视频片头片尾"
name="opening"
<template #help>
<p class="text-xs text-neutral-400">仅支持 .pptx 格式</p>
</template>
<FileDnD
accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"
@change="(file) => (selected_file = file)"
/>
</UFormField>
<UAccordion
:items="[{ label: '高级选项' }]"
color="neutral"
size="lg"
>
<div
:class="{ 'shadow-inner': !!selected_titles }"
class="flex items-center gap-2 bg-neutral-100 dark:bg-neutral-800 p-2 rounded-md cursor-pointer select-none transition-all"
@click="isTitlesSelectorOpen = true"
>
<template #content>
<div
class="w-12 aspect-square border dark:border-neutral-700 rounded-md flex justify-center items-center overflow-hidden"
class="space-y-4 rounded-lg border p-4 pb-6 dark:border-neutral-700"
>
<UIcon
v-if="!selected_titles"
class="text-2xl opacity-50"
name="i-tabler-brackets-contain"
/>
<NuxtImg
v-else
:src="selected_titles?.opening_url"
/>
</div>
<div class="flex flex-col text-neutral-400 text-sm font-medium">
<span :class="!!selected_titles ? 'text-neutral-600' : ''">
{{ selected_titles?.title || '点击选择片头' }}
</span>
<span
v-if="selected_titles?.description"
class="text-2xs"
<UFormField
label="生成线路"
name="gen_server"
>
{{ selected_titles?.description }}
</span>
<USelectMenu
v-model="createCourseState.gen_server"
:items="[
{
label: '主线路',
value: 'main',
},
{
label: '备用线路',
value: 'standby1',
},
]"
value-key="value"
/>
</UFormField>
<UFormField
:label="`视频倍速:${createCourseState.speed}`"
name="speed"
>
<USlider
v-model="createCourseState.speed"
:max="1.5"
:min="0.5"
:step="0.1"
class="pt-4"
size="sm"
/>
</UFormField>
</div>
</div>
</UFormGroup>
<!-- <UFormGroup label="视频片头片尾" name="opening">
<div
class="flex items-center gap-2 bg-neutral-100 dark:bg-neutral-800 p-2 rounded-md cursor-pointer select-none transition-all"
>
<div
class="w-12 aspect-square border dark:border-neutral-700 rounded-md flex justify-center items-center">
<UIcon class="text-2xl opacity-50" name="i-tabler-brackets-contain"/>
</div>
<div class="flex flex-col text-neutral-400 text-sm font-medium">
<span>点击选择</span>
</div>
</div>
</UFormGroup> -->
</div>
</template>
</UAccordion>
</UForm>
<UFormGroup
label="PPT 文件"
required
>
<template #help>
<p class="text-xs text-neutral-400">仅支持 .pptx 格式</p>
</template>
<FileDnD
accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"
@change="(file) => (selected_file = file)"
/>
</UFormGroup>
<ModalDigitalHumanSelect
:is-open="isDigitalSelectorOpen"
@close="isDigitalSelectorOpen = false"
@select="
(digitalHumans) => {
selected_digital_human = digitalHumans as DigitalHumanItem
}
"
/>
<ModalVideoTitleSelect
:is-open="isTitlesSelectorOpen"
@close="isTitlesSelectorOpen = false"
@select="
(titles) => {
selected_titles = titles as TitlesTemplate
}
"
/>
<UAccordion
:items="[{ label: '高级选项' }]"
color="gray"
size="lg"
>
<template #item>
<div
class="border dark:border-neutral-700 rounded-lg space-y-4 p-4 pb-6"
>
<UFormGroup
label="生成线路"
name="gen_server"
>
<USelectMenu
v-model="createCourseState.gen_server"
:options="[
{
label: '主线路',
value: 'main',
},
{
label: '备用线路',
value: 'standby1',
},
]"
option-attribute="label"
value-attribute="value"
/>
</UFormGroup>
<UFormGroup
:label="`视频倍速:${createCourseState.speed}`"
name="speed"
>
<URange
v-model="createCourseState.speed"
:max="1.5"
:min="0.5"
:step="0.1"
class="pt-4"
size="sm"
/>
</UFormGroup>
</div>
</template>
</UAccordion>
</UForm>
<template #footer>
<div class="flex justify-end space-x-4">
<UButton
color="gray"
label="取消"
size="lg"
variant="ghost"
@click="slide.close()"
/>
<UButton
:loading="creationPending"
color="primary"
label="提交"
size="lg"
variant="solid"
@click="creationForm?.submit()"
/>
</div>
</template>
</UCard>
<ModalDigitalHumanSelect
:is-open="isDigitalSelectorOpen"
@close="isDigitalSelectorOpen = false"
@select="
(digitalHumans) => {
selected_digital_human = digitalHumans as DigitalHumanItem
}
"
/>
<ModalVideoTitleSelect
:is-open="isTitlesSelectorOpen"
@close="isTitlesSelectorOpen = false"
@select="
(titles) => {
selected_titles = titles as TitlesTemplate
}
"
/>
<template #footer>
<div class="flex justify-end space-x-4">
<UButton
color="neutral"
label="取消"
size="lg"
variant="ghost"
@click="$emit('close')"
/>
<UButton
:loading="creationPending"
color="primary"
label="提交"
size="lg"
variant="solid"
@click="creationForm?.submit()"
/>
</div>
</template>
</UCard>
</template>
</USlideover>
</template>