npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

chat-bot-for-cirs

v1.1.48

Published

A chat bot component for CIRS

Readme

ChatBot for CIRS

一个基于 React 和 Ant Design 的聊天机器人组件,专为 CIRS 系统设计。

安装

npm install chat-bot-for-cirs

使用方法

基本用法

import React from 'react';
import ChatBot from 'chat-bot-for-cirs';

function App() {
  return (
    <div>
      <h1>我的应用</h1>
      <ChatBot />
    </div>
  );
}

export default App;

高级用法

import React, { useState } from 'react';
import ChatBot from 'chat-bot-for-cirs';

function App() {
  const [expanded, setExpanded] = useState(false);

  const handleExpandedChange = (newExpanded) => {
    setExpanded(newExpanded);
    console.log('聊天窗口状态:', newExpanded ? '展开' : '收起');
  };

  return (
    <div>
      <h1>我的应用</h1>
      <ChatBot
        expanded={expanded}
        onExpandedChange={handleExpandedChange}
        config={{
          apiEndpoint: 'https://api.example.com/chat',
          headers: {
            'Authorization': 'Bearer your-token'
          }
        }}
        style={{
          zIndex: 9999
        }}
      />
    </div>
  );
}

export default App;

在 HTML 中直接使用

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ChatBot 示例</title>
  <!-- 引入 React -->
  <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
  <!-- 引入 Ant Design -->
  <script src="https://unpkg.com/[email protected]/dist/antd.min.js"></script>
  <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/antd.min.css">
  <!-- 引入 Ant Design Icons -->
  <script src="https://unpkg.com/@ant-design/[email protected]/lib/index.js"></script>
  <!-- 引入 React Markdown -->
  <script src="https://unpkg.com/[email protected]/dist/react-markdown.min.js"></script>
  <!-- 引入 ChatBot -->
  <script src="https://unpkg.com/chat-bot-for-cirs@latest/dist/index.umd.js"></script>
</head>
<body>
  <div id="root"></div>
  <script>
    const { createElement: h } = React;
    const { createRoot } = ReactDOM;
    
    function App() {
      return h('div', null, [
        h('h1', null, '我的应用'),
        h(ChatBotForCirs.default, null)
      ]);
    }
    
    const root = createRoot(document.getElementById('root'));
    root.render(h(App));
  </script>
</body>
</html>

API

ChatBot Props

| 属性 | 类型 | 默认值 | 描述 | |------|------|--------|------| | expanded | boolean | false | 是否展开聊天窗口 | | onExpandedChange | (expanded: boolean) => void | - | 展开状态变化回调 | | className | string | - | 自定义样式类名 | | style | React.CSSProperties | - | 自定义样式 | | config | object | - | 聊天机器人配置 |

Config 配置

| 属性 | 类型 | 默认值 | 描述 | |------|------|--------|------| | apiEndpoint | string | - | API 端点 | | headers | Record<string, string> | - | 请求头 |

构建产物

  • dist/index.js - CommonJS 格式
  • dist/index.esm.js - ES Module 格式
  • dist/index.umd.js - UMD 格式(未压缩)
  • dist/index.min.js - UMD 格式(压缩版)
  • dist/index.d.ts - TypeScript 类型声明

依赖

Peer Dependencies

  • React >= 18.0.0
  • ReactDOM >= 18.0.0

Dependencies

  • antd ^4.24.16
  • @ant-design/icons
  • react-markdown

许可证

MIT