
語言 🇹🇼 繁體中文
🇺🇸
English
🇧🇬
Български
🇨🇳
简体中文
🇹🇼
繁體中文
🇭🇷
Hrvatski
🇩🇰
Dansk
🇳🇱
Nederlands
🇺🇸
English (US)
🇨🇦
Français (Canada)
🇫🇷
Français (France)
🇩🇪
Deutsch
🇨🇾
Ελληνικά (Κύπρος)
🇬🇷
Ελληνικά
🇮🇱
עברית
🇮🇹
Italiano
🇯🇵
日本語
🇰🇷
한국어
🇵🇱
Polski
🇧🇷
Português (Brasil)
🇷🇺
Русский
🇺🇦
Русский (Украина)
🇧🇦
Српски (БиХ)
🇷🇸
Srpski (Latinica)
🇲🇪
Српски (Црна Гора)
🇷🇸
Српски
🇸🇮
Slovenščina
🇪🇸
Español
🇺🇦
Українська
🇹🇷
Türkçe
文件
快速開始
使用
設定
Add Comments to Your SolidJS App
這是 FastComments 的官方 SolidJS 函式庫。
在你的 SolidJS 應用中嵌入即時評論、聊天及審閱小工具。
儲存庫
使用 
import { FastCommentsCommentWidget } from 'fastcomments-solidjs';
export default function App() {
return <FastCommentsCommentWidget tenantId="demo" urlId="some-page-id" />;
}
回應設定變更(命令式處理) 
Solid 不會自動追蹤任意物件的深層變更,因此在第一次渲染後的 config 變更必須被明確推送。每個 widget 都接受一個會回傳 handle 的 apiRef;在 createEffect 中呼叫 handle.update(partial) 以驅動反應性:
import { createEffect, createSignal } from 'solid-js';
import { FastCommentsCommentWidget, type FastCommentsCommentWidgetHandle } from 'fastcomments-solidjs';
export default function Paginated() {
const [page, setPage] = createSignal(0);
let handle: FastCommentsCommentWidgetHandle | undefined;
createEffect(() => handle?.update({ urlId: `product-${page()}` }));
return (
<>
<button onClick={() => setPage(page() + 1)}>next</button>
<FastCommentsCommentWidget
apiRef={(h) => (handle = h)}
tenantId="demo"
urlId={`product-${page()}`}
/>
</>
);
}
update() 在任何時候呼叫都是安全的:
- 在 script 載入之前:partial 會被暫存並在初始化時套用。
- 在非同步初始化期間 (reviews-summary, user-activity-feed):partial 會排入佇列,並在 callback 解決時套用。
- 在初始化之後:它會直接轉發到 live widget 的
.update()方法。
命令式 handle API
interface WidgetHandle<Config> {
getInstance: () => WidgetInstance | null; // 最新的運行中實例(或在掛載前為 null)
onInstance: (cb: (instance: WidgetInstance) => void) => void; // 在實例就緒時觸發一次
update: (partial: Partial<Config>) => void; // 合併並推送 config
}
對於 .update() 無法涵蓋的命令式操作,請使用 getInstance(),例如 openProfile:
const openProfile = () =>
(handle?.getInstance() as { openProfile?: (o: { userId: string }) => void } | null)
?.openProfile?.({ userId: 'demo' });
元件 
來自 fastcomments-react 的每個元件都以相同的名稱提供:
| Component | Handle type | Embed loaded |
|---|---|---|
FastCommentsCommentWidget |
FastCommentsCommentWidgetHandle |
旗艦即時留言元件 |
FastCommentsCommentCountWidget |
FastCommentsCommentCountWidgetHandle |
內嵌評論計數徽章 |
FastCommentsLiveChatWidget |
FastCommentsLiveChatWidgetHandle |
串流式即時聊天元件 |
FastCommentsCollabChatWidget |
FastCommentsCollabChatWidgetHandle |
以文字為錨點的協作聊天 |
FastCommentsImageChatWidget |
FastCommentsImageChatWidgetHandle |
基於區域的圖片評論 |
FastCommentsRecentCommentsWidget |
FastCommentsRecentCommentsWidgetHandle |
近期評論動態 |
FastCommentsRecentDiscussionsWidget |
FastCommentsRecentDiscussionsWidgetHandle |
近期討論動態 |
FastCommentsReviewsSummaryWidget |
FastCommentsReviewsSummaryWidgetHandle |
星級評分摘要 |
FastCommentsTopPagesWidget |
FastCommentsTopPagesWidgetHandle |
最多評論頁面排行榜 |
FastCommentsUserActivityFeedWidget |
FastCommentsUserActivityFeedWidgetHandle |
每位使用者的活動時間線 |
附加到現有元素的元件
FastCommentsCollabChatWidget and FastCommentsImageChatWidget mount into a caller-supplied
element. Pass a targetRef accessor that returns the element once mounted:
import { FastCommentsImageChatWidget } from 'fastcomments-solidjs';
export default function ImageChat() {
let img: HTMLImageElement | undefined;
return (
<>
<img ref={img} src="/screenshot.png" alt="" />
<FastCommentsImageChatWidget
tenantId="demo"
urlId="my-image"
targetRef={() => img}
/>
</>
);
}
區域
傳遞 region="eu" 以透過 EU 叢集引導元件流量。
需要幫助?
如果您在使用 SolidJS 函式庫時遇到任何問題或有任何疑問,請:
貢獻
歡迎任何貢獻!請造訪 GitHub 儲存庫 以取得貢獻指南。