diff --git a/src/app/srt-player/components/UploadArea.tsx b/src/app/srt-player/components/UploadArea.tsx index 530f299..dc4d0b9 100644 --- a/src/app/srt-player/components/UploadArea.tsx +++ b/src/app/srt-player/components/UploadArea.tsx @@ -1,5 +1,5 @@ import { useRef, useState } from "react"; -import Button from "./Button"; +import Button from "../../../components/Button"; export default function UploadArea( { diff --git a/src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx b/src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx index 3714ee6..f7f34e6 100644 --- a/src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx +++ b/src/app/srt-player/components/VideoPlayer/SubtitleDisplay.tsx @@ -1,14 +1,7 @@ +import inspect from "@/utilities"; + export default function SubtitleDisplay({ subtitle }: { subtitle: string }) { const words = subtitle.match(/\b[\w']+(?:-[\w']+)*\b/g) || []; - const goto = (url: string) => { - window.open(url, '_blank'); - } - const inspect = (word: string) => { - return () => { - word = word.toLowerCase(); - goto(`https://www.youdao.com/result?word=${word}&lang=en`); - } - } let i = 0; return (
diff --git a/src/app/srt-player/components/VideoPlayer/VideoPanel.tsx b/src/app/srt-player/components/VideoPlayer/VideoPanel.tsx index 712b5b9..1cebb14 100644 --- a/src/app/srt-player/components/VideoPlayer/VideoPanel.tsx +++ b/src/app/srt-player/components/VideoPlayer/VideoPanel.tsx @@ -1,5 +1,5 @@ import { useState, useRef, forwardRef, useEffect, KeyboardEvent, useCallback } from "react"; -import Button from "../Button"; +import Button from "../../../../components/Button"; import { getIndex, getNearistIndex, parseSrt } from "../../subtitle"; import SubtitleDisplay from "./SubtitleDisplay"; diff --git a/src/app/word-board/Button.tsx b/src/app/word-board/Button.tsx deleted file mode 100644 index 74f88fb..0000000 --- a/src/app/word-board/Button.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function Button({ label, onClick }: { label: string, onClick?: () => void }) { - return ( - - ); -} \ No newline at end of file diff --git a/src/app/word-board/WordBoard.tsx b/src/app/word-board/WordBoard.tsx index 252558f..bfb4819 100644 --- a/src/app/word-board/WordBoard.tsx +++ b/src/app/word-board/WordBoard.tsx @@ -1,14 +1,29 @@ 'use client'; +import Word from "@/interfaces/Word"; +import inspect from "@/utilities"; +import { Dispatch, SetStateAction } from "react"; + +function DraggableWord({ word }: { word: Word }) { + return (({word.word})) +} + export default function WordBoard( - { words }: { + { words, setWords }: { words: [ { word: string, x: number, y: number } - ] + ], + setWords: Dispatch> } ) { const inspect = (word: string) => { @@ -28,14 +43,7 @@ export default function WordBoard( x: number, y: number }, i: number) => { - return ({v.word}) + return () })}
) diff --git a/src/app/word-board/page.tsx b/src/app/word-board/page.tsx index c0773a8..95caeaa 100644 --- a/src/app/word-board/page.tsx +++ b/src/app/word-board/page.tsx @@ -1,13 +1,8 @@ 'use client'; import WordBoard from "@/app/word-board/WordBoard"; -import Button from "./Button"; +import Button from "../../components/Button"; import { useRef, useState } from "react"; - -interface Word { - word: string, - x: number, - y: number -} +import Word from "@/interfaces/Word"; export default function Home() { const inputRef = useRef(null); @@ -79,7 +74,7 @@ export default function Home() { } return (
- +
diff --git a/src/app/srt-player/components/Button.tsx b/src/components/Button.tsx similarity index 100% rename from src/app/srt-player/components/Button.tsx rename to src/components/Button.tsx diff --git a/src/interfaces/Word.ts b/src/interfaces/Word.ts new file mode 100644 index 0000000..9bd176c --- /dev/null +++ b/src/interfaces/Word.ts @@ -0,0 +1,5 @@ +export default interface Word { + word: string, + x: number, + y: number +} \ No newline at end of file diff --git a/src/utilities.ts b/src/utilities.ts new file mode 100644 index 0000000..1110b76 --- /dev/null +++ b/src/utilities.ts @@ -0,0 +1,9 @@ +export default function inspect(word: string) { + const goto = (url: string) => { + window.open(url, '_blank'); + } + return () => { + word = word.toLowerCase(); + goto(`https://www.youdao.com/result?word=${word}&lang=en`); + } +} \ No newline at end of file