diff --git a/packages/frontend/src/components/SearchBox.svelte b/packages/frontend/src/components/SearchBox.svelte index 4fb563b..c9ecb1d 100644 --- a/packages/frontend/src/components/SearchBox.svelte +++ b/packages/frontend/src/components/SearchBox.svelte @@ -2,15 +2,16 @@ import SearchIcon from "src/components/icon/SearchIcon.svelte"; import CloseIcon from "src/components/icon/CloseIcon.svelte"; - let inputBox: HTMLInputElement | null = null; - export let close = () => {}; + let inputValue = ""; // 使用一个变量来绑定 input 的值 + export let close = () => { + }; export function changeFocusState(target: boolean) { - if (!inputBox) return; + if (!inputElement) return; // 使用 inputElement 而不是 inputBox if (target) { - inputBox.focus(); + inputElement.focus(); } else { - inputBox.blur(); + inputElement.blur(); } } @@ -21,12 +22,13 @@ function handleKeydown(event: KeyboardEvent) { if (event.key === "Enter") { event.preventDefault(); - const input = event.target as HTMLInputElement; - const value = input.value.trim(); + const value = inputValue.trim(); // 使用绑定的变量 if (!value) return; search(value); } } + + let inputElement: HTMLInputElement; // 引用 input 元素 -
ID | +ID | {videoInfo?.id} |
AID | +AID | {videoInfo?.aid} |
BVID | +BVID | {videoInfo?.bvid} |
标题 | +标题 | {videoInfo?.title} |
描述 | +描述 | {videoInfo?.description} |
UID | +UID | {videoInfo?.uid} |
标签 | +标签 | {videoInfo?.tags} |
发布时间 | +发布时间 | {videoInfo?.published_at ? format(new Date(videoInfo.published_at), 'yyyy-MM-dd HH:mm:ss', { locale: zhCN }) : '-'} |
时长 (秒) | +时长 (秒) | {videoInfo?.duration} |
创建时间 | +创建时间 | {videoInfo?.created_at ? format(new Date(videoInfo.created_at), 'yyyy-MM-dd HH:mm:ss', { locale: zhCN }) : '-'} |
封面 | +封面 | {videoInfo?.cover_url ? videoInfo.cover_url : '-'} |