From d637442fda33cd54620edc97b3a31f88f092ddb1 Mon Sep 17 00:00:00 2001 From: HoshinoSuzumi Date: Tue, 2 Jul 2024 01:25:56 +0800 Subject: [PATCH] feat: subtitles editor --- .../aigc/course-generate/CGTaskCard.vue | 29 +- components/aigc/course-generate/SRTEditor.vue | 277 ++++++++++++++++++ tailwind.config.ts | 30 +- 3 files changed, 329 insertions(+), 7 deletions(-) create mode 100644 components/aigc/course-generate/SRTEditor.vue diff --git a/components/aigc/course-generate/CGTaskCard.vue b/components/aigc/course-generate/CGTaskCard.vue index 32cc615..aba9a24 100644 --- a/components/aigc/course-generate/CGTaskCard.vue +++ b/components/aigc/course-generate/CGTaskCard.vue @@ -3,10 +3,13 @@ import type { PropType } from 'vue' import dayjs from 'dayjs' import { useDownload } from '~/composables/useDownload' import gsap from 'gsap' +import SRTEditor from '~/components/aigc/course-generate/SRTEditor.vue' const toast = useToast() const { metaSymbol } = useShortcuts() +const srtEditor = ref() + const props = defineProps({ course: { type: Object as PropType, @@ -25,6 +28,14 @@ defineShortcuts({ } }, }, + 'meta_d': { + handler: () => { + if (isDropdownOpen.value && isDownloadable.value) { + srtEditor.value.open() + isDropdownOpen.value = false + } + }, + }, 'meta_s': { handler: () => { if (isDropdownOpen.value && isDownloadable.value) { @@ -73,9 +84,6 @@ watch(generateProgress, (newValue) => { }, { immediate: true, }) -watch(tweenedGenerateProgress, val => { - console.log(val) -}) const downloadProgress = ref(0) @@ -117,8 +125,8 @@ const startDownload = async ( download() } -const copyTaskId = () => { - navigator.clipboard.writeText(props.course.task_id) +const copyTaskId = (extraMessage?: string) => { + navigator.clipboard.writeText(props.course.task_id + (extraMessage ? ` ${ extraMessage }` : '')) toast.add({ title: '复制成功', description: '已复制任务 ID', @@ -181,10 +189,11 @@ const copyTaskId = () => {

{{ dayjs(course.create_time * 1000).format('YYYY-MM-DD HH:mm:ss') }} @@ -215,6 +224,10 @@ const copyTaskId = () => { icon: 'i-solar-subtitles-linear', shortcuts: [metaSymbol, 'D'], disabled: !isDownloadable, + click: () => { + srtEditor.open() + isDropdownOpen = false + } }, { label: '下载字幕', icon: 'i-tabler-file-download', @@ -272,6 +285,10 @@ const copyTaskId = () => { /> + diff --git a/components/aigc/course-generate/SRTEditor.vue b/components/aigc/course-generate/SRTEditor.vue new file mode 100644 index 0000000..8705c80 --- /dev/null +++ b/components/aigc/course-generate/SRTEditor.vue @@ -0,0 +1,277 @@ + + + + + \ No newline at end of file diff --git a/tailwind.config.ts b/tailwind.config.ts index ec0389c..9e20c2e 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -20,9 +20,37 @@ export default >{ sidebar: 'inset -2px 0 2px 0 rgba(0, 0, 0, .05)', sidebar_dark: 'inset -2px 0 2px 0 rgba(255, 255, 255, .05)', }, + textShadow: { + 'default': '2px 2px 5px grey', + 'md': '4px 4px 10px grey', + 'lg': '6px 6px 15px grey', + }, }, }, - plugins: [typography], + plugins: [ + typography, + function ({ addUtilities }: { addUtilities: Function }) { + const newUtilities = { + '.text-shadow': { + textShadow: '2px 2px 5px grey', + }, + '.text-shadow-md': { + textShadow: '4px 4px 10px grey', + }, + '.text-shadow-lg': { + textShadow: '6px 6px 15px grey', + }, + '.text-stroke': { + '-webkit-text-stroke': '1px black', + }, + '.text-stroke-2': { + '-webkit-text-stroke': '2px black', + }, + } + + addUtilities(newUtilities, ['responsive', 'hover']) + }, + ], safelist: [ { pattern: /^bg-/,