From 5097db2b25c4f08ff8244e18afd8b532c35267a5 Mon Sep 17 00:00:00 2001 From: JimmyLv Date: Wed, 1 Mar 2023 02:45:46 +0800 Subject: [PATCH] fix: support enter --- pages/[...slug].tsx | 72 ++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/pages/[...slug].tsx b/pages/[...slug].tsx index 781ba14e..0b8ee290 100644 --- a/pages/[...slug].tsx +++ b/pages/[...slug].tsx @@ -9,10 +9,10 @@ import Footer from "../components/Footer"; import Header from "../components/Header"; import SquigglyLines from "../components/SquigglyLines"; -let isSecureContext = false +let isSecureContext = false; -if (typeof window !== 'undefined') { - isSecureContext = window.isSecureContext +if (typeof window !== "undefined") { + isSecureContext = window.isSecureContext; } export const Home: NextPage = () => { @@ -39,6 +39,10 @@ export const Home: NextPage = () => { const curUrl = String(curVideo.split(".com")[1]); + const onFormSubmit = async (e: any) => { + e.preventDefault(); + await generateSummary(); + }; const generateSummary = async (url?: string) => { setSummary(""); if (url) { @@ -181,36 +185,38 @@ export const Home: NextPage = () => {

- setCurVideo(e.target.value)} - className="mx-auto mt-10 w-full appearance-none rounded-lg rounded-md border bg-transparent py-2 pl-2 text-sm leading-6 text-slate-900 shadow-sm ring-1 ring-slate-200 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" - placeholder={"输入我的 bilibili.com 视频链接"} - /> - {!loading && ( - - )} - {loading && ( - - )} +
+ setCurVideo(e.target.value)} + className="mx-auto mt-10 w-full appearance-none rounded-lg rounded-md border bg-transparent py-2 pl-2 text-sm leading-6 text-slate-900 shadow-sm ring-1 ring-slate-200 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder={"输入 bilibili.com 视频链接,按下「回车」"} + /> + {!loading && ( + + )} + {loading && ( + + )} +