MCPcopy
hub / github.com/Innei/Shiro / XLogSummary

Function XLogSummary

src/components/modules/xlog/XLogSummary.tsx:14–80  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

12}
13
14export const XLogSummary: FC<XLogSummaryProps> = (props) => {
15 const { cid } = props
16 const { data, isLoading, error } = useQuery({
17 queryKey: [`getSummary`, cid],
18 queryFn: async ({ queryKey }) => {
19 const [, cid] = queryKey
20 const data = await fetch(`/api/xlog/summary?cid=${cid}`, {
21 next: {
22 revalidate: 60 * 10,
23 },
24 }).then((res) => res.json())
25 if (!data) throw new Error('请求错误')
26 if (!data.summary) throw new Error('内容暂时无法获取')
27 return data
28 },
29 enabled: !!cid,
30 staleTime: 1000 * 60 * 60 * 24 * 7,
31 retryDelay: 5000,
32 })
33
34 let Inner: ReactNode = (
35 <div
36 className={clsxm(
37 `space-y-2 rounded-xl border border-slate-200 p-4 dark:border-neutral-800`,
38 props.className,
39 )}
40 >
41 <div className="flex items-center">
42 <i className="i-mingcute-sparkles-line mr-2 text-lg" />
43 AI 生成的摘要
44 </div>
45
46 <AutoResizeHeight duration={0.3}>
47 <div className="!m-0 text-sm leading-loose text-base-content/85">
48 {isLoading ? (
49 <div className="space-y-2">
50 <span className="block h-5 w-full animate-pulse rounded-xl bg-zinc-200 dark:bg-neutral-800" />
51 <span className="block h-5 w-full animate-pulse rounded-xl bg-zinc-200 dark:bg-neutral-800" />
52 <span className="block h-5 w-full animate-pulse rounded-xl bg-zinc-200 dark:bg-neutral-800" />
53 </div>
54 ) : (
55 data?.summary
56 )}
57 </div>
58 {isLoading && (
59 <p className="mt-3 border-slate-200 text-right text-sm dark:border-slate-800 ">
60 (此服务由{' '}
61 <a href="https://xlog.app" target="_blank" rel="noreferrer">
62 xLog
63 </a>{' '}
64 驱动)
65 </p>
66 )}
67 </AutoResizeHeight>
68 </div>
69 )
70
71 if (!cid || error) {

Callers

nothing calls this directly

Calls 3

clsxmFunction · 0.90
fetchFunction · 0.85
jsonMethod · 0.80

Tested by

no test coverage detected