From a89c348df10f034888f75f54947a5e3469e77f8d Mon Sep 17 00:00:00 2001 From: JimmyLv Date: Sun, 12 Mar 2023 14:28:53 +0800 Subject: [PATCH] fix: only convert for b23.tv url --- hooks/notes/flomo.ts | 4 ++-- pages/[...slug].tsx | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hooks/notes/flomo.ts b/hooks/notes/flomo.ts index f0d24e7b..b6f66af8 100644 --- a/hooks/notes/flomo.ts +++ b/hooks/notes/flomo.ts @@ -1,5 +1,5 @@ import { useState } from "react"; -import { useAnalytics } from '~/components/context/analytics' +import { useAnalytics } from "~/components/context/analytics"; import { useToast } from "~/hooks/use-toast"; export function useSaveToFlomo(note: string, webhook: string) { @@ -15,7 +15,7 @@ export function useSaveToFlomo(note: string, webhook: string) { "Content-Type": "application/json", }, body: JSON.stringify({ - content: note + "#BibiGpt", + content: note + "\n#BibiGpt", }), }); const json = await response.json(); diff --git a/pages/[...slug].tsx b/pages/[...slug].tsx index 5d09a3da..c0a98d44 100644 --- a/pages/[...slug].tsx +++ b/pages/[...slug].tsx @@ -140,14 +140,17 @@ export const Home: NextPage<{ const handleInputChange = async (e: any) => { const value = e.target.value; + // todo: 兼容?query参数 const regex = /((?:https?:\/\/|www\.)\S+)/g; const matches = value.match(regex); if (matches) { const url = matches[0]; - toast({ title: "正在自动转换此视频链接..." }); - const response = await fetch(`/api/b23tv?url=${url}`); - const json = await response.json(); - setCurrentVideoUrl(json.url); + if (url.includes("b23.tv")) { + toast({ title: "正在自动转换此视频链接..." }); + const response = await fetch(`/api/b23tv?url=${url}`); + const json = await response.json(); + setCurrentVideoUrl(json.url); + } } else { setCurrentVideoUrl(value); }