
语言 🇨🇳 简体中文
文档
入门
用法
Add Comment Widgets to Your React Native App
这是 FastComments 的官方 React Native 库。
在你的 React Native 应用中嵌入实时评论、聊天和点评小部件。
仓库
实时演示 
要查看针对公共 demo 租户在本地运行的每个小部件和流程,请克隆仓库并运行:
yarn bootstrap
cd example
yarn ios # 或:yarn android, yarn web
The showcase entry point is example/src/ShowcaseApp.tsx — a single app that exposes all widgets, themes, and flows.
The yarn web target uses react-native-web + react-native-web-webview (which renders the WebView as an iframe). Useful for quick visual smoke tests in a browser; native-only WebView APIs like injectJavaScript and onShouldStartLoadWithRequest won't fully behave on web.
考虑使用原生 SDK 
此库在 VanillaJS 库外层使用了一个 webview。
FastComments 现在在 fastcomments-react-native-sdk 中支持我们客户端的完全原生实现。 如果您想要完全的原生实现,建议查看该项目。
使用 - 实时评论小部件 
与 fastcomments-react 相比,API 略有不同。在原生环境中,我们传入一个遵循 此结构 的配置对象。
import { FastCommentsCommentWidget } from 'fastcomments-react-native';
// ...
const myTenantId = 'demo'; // 您的租户 ID。可以从 https://fastcomments.com/auth/my-account/api-secret 获取
const myAppPageId = 'native-test'; // 您应用中评论线程的 ID 或 URL。
const myAppPageUrl = 'https://example.com/external-page'; // 您可以可选地为外部页面设置一个 URL
const myAppPageTitle = 'Example Title'; // … 并且您可能想为此内容设置标题
const [config, setConfig] = useState({
tenantId: myTenantId,
urlId: myAppPageId,
url: myAppPageUrl,
pageTitle: myAppPageTitle
});
// 通过调用 setConfig(),我们可以做诸如更改当前页面或当前登录用户之类的操作
// 参见 example/src/App.tsx
return (
<FastCommentsCommentWidget config={config}/>
);
使用 - 实时聊天小部件 
import { FastCommentsLiveChatWidget } from 'fastcomments-react-native';
// ...
const myTenantId = 'demo'; // 您的租户 id。可以从 https://fastcomments.com/auth/my-account/api-secret 获取
const myAppPageId = 'native-test'; // 在您的应用中评论线程的 ID 或 URL。
const myAppPageUrl = 'https://example.com/external-page'; // 您可以可选地设置指向外部页面的 url
const myAppPageTitle = 'Example Title'; // ... 并且您可能希望为此内容设置一个标题
const config = {
tenantId: myTenantId,
urlId: myAppPageId,
url: myAppPageUrl,
pageTitle: myAppPageTitle
};
return (
<FastCommentsLiveChatWidget config={config}/>
);
使用 - 单点登录 (SSO) 
FastComments 使用 HMAC 来实现安全的 SSO。
要使用,请让你的后端创建 SSO 对象 (sso 配置属性) 并将其传递给评论小部件。
你可以在这里找到各种后端的示例: https://github.com/FastComments/fastcomments-code-examples/tree/master/sso
对等依赖 
fastcomments-react-native 依赖 react-native-webview。因此,你应当遵循 react-native-webview 的安装步骤。
账户区域(注意:欧盟客户)
如果你的账户位于欧盟,请在小部件配置中将 region = 'eu' 设置。
否则,你无需定义 region。
维护状态 
这些组件是围绕我们核心 VanillaJS 组件的包装器。我们可以自动更新这些组件(修复错误、添加功能),而无需发布此库,因此即便它可能一段时间不会发布,这并不意味着 FastComments 没有在积极开发!欢迎查看我们的博客以获取更新。除非同时提升本库的版本号,否则破坏性 API 更改或新功能绝不会被推送到底层核心库。
需要帮助?
如果在使用 React Native 库时遇到任何问题或有疑问,请:
贡献
欢迎贡献!有关贡献指南,请访问 GitHub 仓库。