diff --git a/src/app/preview/page.tsx b/src/app/preview/page.tsx index 77b8e7a567..e3238bc2ff 100644 --- a/src/app/preview/page.tsx +++ b/src/app/preview/page.tsx @@ -66,16 +66,16 @@ export default function PreviewPage() { const search = location.search const searchParams = new URLSearchParams(search) - let targinOrigin = searchParams.get('origin') + let targetOrigin = searchParams.get('origin') - if (!targinOrigin) { + if (!targetOrigin) { return } - targinOrigin = decodeURIComponent(targinOrigin) - window.opener.postMessage('Preview Page Ready', targinOrigin) + targetOrigin = decodeURIComponent(targetOrigin) + window.opener.postMessage('Preview Page Ready', targetOrigin) const handler = debounce((e) => { - if (e.origin !== targinOrigin) { + if (e.origin !== targetOrigin) { return } @@ -93,7 +93,6 @@ export default function PreviewPage() { const previewData = useAtomValue(previewDataAtom) - // console.log(previewData) if (!previewData) { return null } @@ -166,6 +165,8 @@ const NotePreview = () => { next: undefined, data: { ...data, + + created: new Date().toISOString(), images: data.images ?? [], count: data.count ?? { read: 0, diff --git a/src/components/widgets/peek/NotePreview.tsx b/src/components/widgets/peek/NotePreview.tsx index 1bb846a38f..8ad9965523 100644 --- a/src/components/widgets/peek/NotePreview.tsx +++ b/src/components/widgets/peek/NotePreview.tsx @@ -23,7 +23,8 @@ import { queries } from '~/queries/definition' import { NoteHideIfSecret, NoteMetaBar, NoteRootBanner } from '../note' import { BanCopyWrapper } from '../shared/BanCopyWrapper' -import { SummarySwitcher } from '../shared/SummarySwitcher' +import { XLogSummary } from '../xlog' +import { getCidForBaseModel } from '../xlog/utils' interface NotePreviewProps { noteId: number @@ -56,7 +57,7 @@ export const NotePreview: FC = (props) => { - + diff --git a/src/components/widgets/peek/PostPreview.tsx b/src/components/widgets/peek/PostPreview.tsx index 56912daf5b..bd6e01b577 100644 --- a/src/components/widgets/peek/PostPreview.tsx +++ b/src/components/widgets/peek/PostPreview.tsx @@ -20,7 +20,8 @@ import { WrappedElementProvider } from '~/providers/shared/WrappedElementProvide import { queries } from '~/queries/definition' import { PostOutdate } from '../post' -import { SummarySwitcher } from '../shared/SummarySwitcher' +import { XLogSummary } from '../xlog' +import { getCidForBaseModel } from '../xlog/utils' interface PostPreviewProps { category: string @@ -43,11 +44,8 @@ export const PostPreview: FC = (props) => {

{data.title}

- - - - + diff --git a/src/components/widgets/shared/SummarySwitcher.tsx b/src/components/widgets/shared/SummarySwitcher.tsx index 45902e5b60..a79b283111 100644 --- a/src/components/widgets/shared/SummarySwitcher.tsx +++ b/src/components/widgets/shared/SummarySwitcher.tsx @@ -1,3 +1,5 @@ +'use client' + import { memo } from 'react' import type { FC } from 'react' import type { AiSummaryProps } from '../ai/Summary' diff --git a/src/components/widgets/xlog/XLogSummaryRSC.tsx b/src/components/widgets/xlog/XLogSummaryRSC.tsx deleted file mode 100644 index adea2c3d11..0000000000 --- a/src/components/widgets/xlog/XLogSummaryRSC.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { clsxm } from '~/lib/helper' - -const headers = { - referer: `https://link.bilibili.com/p/center/index?visit_id=22ast2mb9zhc`, - 'User-Agent': `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Shiro`, -} - -const fetchData = async (cid: string) => { - if (!cid) { - return null - } - const abortController = new AbortController() - - setTimeout(() => { - abortController.abort() - }, 3000) - - return fetch( - `https://xlog.app/api/summary?cid=${cid}&lang=${navigator.language}`, - { - headers: new Headers(headers), - signal: abortController.signal, - next: { - revalidate: 60 * 10, - }, - }, - ) - .then((res) => res.json()) - .catch(() => null) -} - -export const XLogSummary = async ( - props: ComponentType<{ - cid: string - }>, -) => { - const { cid } = props - if (!cid) return null - - const data = await fetchData(cid) - if (!data) return null - return ( -
-
- - AI 生成的摘要 -
- -

- {data?.data} -

-

- (此服务由{' '} - - xLog - {' '} - 驱动) -

-
- ) -}