-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
8 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use client' | ||
|
||
import { Suspense } from 'react' | ||
|
||
import { clsxm } from '~/lib/helper' | ||
|
||
import { AutoResizeHeight } from '../shared/AutoResizeHeight' | ||
|
||
const fetchData = async (cid: string) => { | ||
if (!cid) { | ||
return null | ||
} | ||
|
||
return fetch(`/api/xlog/summary?cid=${cid}&lang=${navigator.language}`, { | ||
next: { | ||
revalidate: 60 * 10, | ||
}, | ||
}) | ||
.then((res) => res.json()) | ||
.catch(() => null) | ||
} | ||
|
||
export const XLogSummaryAsync = async ( | ||
props: ComponentType<{ | ||
cid: string | ||
}>, | ||
) => { | ||
const { cid } = props | ||
if (!cid) return null | ||
|
||
return ( | ||
<div | ||
data-hide-print | ||
className={clsxm( | ||
`space-y-2 rounded-xl border border-slate-200 p-4 dark:border-neutral-800`, | ||
props.className, | ||
)} | ||
> | ||
<div className="flex items-center"> | ||
<i className="icon-[mingcute--sparkles-line] mr-2 text-lg" /> | ||
AI 生成的摘要 | ||
</div> | ||
|
||
<AutoResizeHeight> | ||
<Suspense fallback={LoadingSkeleton}> | ||
<RealDataRender cid={cid} /> | ||
</Suspense> | ||
</AutoResizeHeight> | ||
<p className="border-slate-200 text-right text-sm dark:border-slate-800 "> | ||
(此服务由{' '} | ||
<a href="https://xlog.app" target="_blank" rel="noreferrer"> | ||
xLog | ||
</a>{' '} | ||
驱动) | ||
</p> | ||
</div> | ||
) | ||
} | ||
|
||
const RealDataRender = async ({ cid }: { cid: string }) => { | ||
const data = await fetchData(cid) | ||
if (!data) return null | ||
|
||
return ( | ||
<p className="text-base-content/85 !m-0 text-sm leading-loose"> | ||
{data?.data} | ||
</p> | ||
) | ||
} | ||
|
||
const LoadingSkeleton = ( | ||
<div className="space-y-2"> | ||
<span className="block h-5 w-full animate-pulse rounded-xl bg-zinc-200 dark:bg-neutral-800" /> | ||
<span className="block h-5 w-full animate-pulse rounded-xl bg-zinc-200 dark:bg-neutral-800" /> | ||
<span className="block h-5 w-full animate-pulse rounded-xl bg-zinc-200 dark:bg-neutral-800" /> | ||
</div> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
659b65c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shiro – ./
shiro-git-main-innei.vercel.app
shiro-innei.vercel.app
innei.in
springtide.vercel.app