diff --git a/public/changelog.txt b/public/changelog.txt index 8b3b890..2e4ee83 100644 --- a/public/changelog.txt +++ b/public/changelog.txt @@ -1,4 +1,4 @@ -2025.10.07 新增文本朗读器 +2025.10.07 新增文本朗读器,优化了视频播放器UI 2025.10.06 更新了主页面UI,移除IPA生成与文本朗读功能,新增全语言翻译器 2025.10.05 新增IPA生成与文本朗读功能 2025.09.25 优化了主界面UI diff --git a/src/app/srt-player/UploadArea.tsx b/src/app/srt-player/UploadArea.tsx new file mode 100644 index 0000000..af630f4 --- /dev/null +++ b/src/app/srt-player/UploadArea.tsx @@ -0,0 +1,53 @@ +import Button from "@/components/Button"; +import { useRef, useState } from "react"; + +export default function UploadArea( + { + setVideoUrl, + setSrtUrl + }: { + setVideoUrl: (url: string | null) => void; + setSrtUrl: (url: string | null) => void; + } +) { + const inputRef = useRef(null); + + const [videoFile, setVideoFile] = useState(null); + const [SrtFile, setSrtFile] = useState(null); + + const uploadVideo = () => { + const input = inputRef.current; + if (input) { + input.setAttribute('accept', 'video/*'); + input.click(); + input.onchange = () => { + const file = input.files?.[0]; + if (file) { + setVideoFile(file); + setVideoUrl(URL.createObjectURL(file)); + } + }; + } + } + const uploadSRT = () => { + const input = inputRef.current; + if (input) { + input.setAttribute('accept', '.srt'); + input.click(); + input.onchange = () => { + const file = input.files?.[0]; + if (file) { + setSrtFile(file); + setSrtUrl(URL.createObjectURL(file)); + } + }; + } + } + return ( +
+
+ ) +} \ No newline at end of file diff --git a/src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx b/src/app/srt-player/VideoPlayer/SubtitleDisplay.tsx similarity index 81% rename from src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx rename to src/app/srt-player/VideoPlayer/SubtitleDisplay.tsx index 7931b34..f157ae1 100644 --- a/src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx +++ b/src/app/srt-player/VideoPlayer/SubtitleDisplay.tsx @@ -4,7 +4,7 @@ export default function SubtitleDisplay({ subtitle }: { subtitle: string }) { const words = subtitle.match(/\b[\w']+(?:-[\w']+)*\b/g) || []; let i = 0; return ( -
+
{ words.map((v) => ( (( } return ( -
- +
+
- - - - - + + + + +
{spanText} diff --git a/src/app/srt-player/components/AppCard.tsx b/src/app/srt-player/components/AppCard.tsx deleted file mode 100644 index 341ae0b..0000000 --- a/src/app/srt-player/components/AppCard.tsx +++ /dev/null @@ -1,25 +0,0 @@ -'use client' - -import { useRef, useState } from "react"; -import UploadArea from "./UploadArea"; -import VideoPanel from "./VideoPlayer/VideoPanel"; - -export default function AppCard() { - const videoRef = useRef(null); - - const [videoUrl, setVideoUrl] = useState(null); - const [srtUrl, setSrtUrl] = useState(null); - - return ( -
-

SRT Video Player

- - -
- ); -} diff --git a/src/app/srt-player/components/UploadArea.tsx b/src/app/srt-player/components/UploadArea.tsx deleted file mode 100644 index dc4d0b9..0000000 --- a/src/app/srt-player/components/UploadArea.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { useRef, useState } from "react"; -import Button from "../../../components/Button"; - -export default function UploadArea( - { - setVideoUrl, - setSrtUrl - }: { - setVideoUrl: (url: string | null) => void; - setSrtUrl: (url: string | null) => void; - } -) { - const inputRef = useRef(null); - - const [videoFile, setVideoFile] = useState(null); - const [SrtFile, setSrtFile] = useState(null); - - const uploadVideo = () => { - const input = inputRef.current; - if (input) { - input.setAttribute('accept', 'video/*'); - input.click(); - input.onchange = () => { - const file = input.files?.[0]; - if (file) { - setVideoFile(file); - setVideoUrl(URL.createObjectURL(file)); - } - }; - } - } - const uploadSRT = () => { - const input = inputRef.current; - if (input) { - input.setAttribute('accept', '.srt'); - input.click(); - input.onchange = () => { - const file = input.files?.[0]; - if (file) { - setSrtFile(file); - setSrtUrl(URL.createObjectURL(file)); - } - }; - } - } - return ( -
- - - - - - - - - - - - - - - - - - - - - - - -
File NameTypeSizeActions
{videoFile?.name}Video{videoFile ? (videoFile.size / 1024 / 1024).toFixed(2) + 'MB' : null}
{SrtFile?.name}SRT{SrtFile ? (SrtFile.size / 1024 / 1024).toFixed(2) + 'MB' : null}
- -
- ) -} \ No newline at end of file diff --git a/src/app/srt-player/page.tsx b/src/app/srt-player/page.tsx index 34bca58..54d0c15 100644 --- a/src/app/srt-player/page.tsx +++ b/src/app/srt-player/page.tsx @@ -1,9 +1,25 @@ -import AppCard from "./components/AppCard"; +'use client'; + +import { useRef, useState } from "react"; +import UploadArea from "./UploadArea"; +import VideoPanel from "./VideoPlayer/VideoPanel"; export default function Home() { + const videoRef = useRef(null); + + const [videoUrl, setVideoUrl] = useState(null); + const [srtUrl, setSrtUrl] = useState(null); return ( -
- +
+
+ + +
); }