# @eshal-bot/chat-widget 中文文档

规范地址：https://npmcn.com/package/%40eshal-bot/chat-widget/

版本：0\.2\.54
npm 元数据更新时间：2026-11-13T11:47:24.894Z
中文译文更新时间：2026-11-13T22:14:14.649Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40eshal-bot/chat-widget
原文对照：https://npmcn.com/package/%40eshal-bot/chat-widget/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：10.2 MB，14 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：10 个
- peer 依赖：react \>=16\.8\.0，react-dom \>=16\.8\.0
- 首次发布：2025-11-10T13:31:57.292Z
- 最新版本发布：2026-11-13T11:47:24.627Z
- 近 30 天下载量：7153（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：174（近 12 个月 170 个）

## 中文简介

带有暗模式支持的美丽可嵌入式聊天部件

## 安装

```sh
npm install @eshal-bot/chat-widget
```

也可以使用：`pnpm add @eshal-bot/chat-widget`、`yarn add @eshal-bot/chat-widget`、`bun add @eshal-bot/chat-widget`

## README

# Eshal 聊天部件

一个美丽的,生产准备的聊天部件, 带有暗模式支持, 快速提问, 和平滑的动画.

## 特征

-   🎨 **美丽的设计** - 受Intercom启发的现代专业UI
-   🌓 **黑暗模式** - 有平稳过渡的全暗模式支持
-   ⚡ **快速问题** - 用户的预定义可点击问题
-   🤖 **博特·阿凡达** - 助理信息自定义的模拟器
-   📱 **响应** - 在所有设备上完美工作
-   🚀 **轻巧** - 最佳捆绑尺寸和性能

## 快速启动

### 安装

```bash
npm install
npm run build
```

### 使用量

```html
<!-- Include the widget -->
<link rel="stylesheet" href="dist/index.css">
<script src="dist/chat-widget.min.js"></script>

<script>
  ChatWidget.init({
    companyName: "Your Company",
    companyLogo: "https://example.com/logo.png",
    primaryColor: "#2563eb",
    quickQuestions: [
      "What are your business hours?",
      "How can I contact support?",
      "What services do you offer?"
    ],
    apiBaseUrl: "https://your-api.com",
    organizationId: "your-org-id"
  });
</script>
```

## 配置

| 选项 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `companyName` | 字符串 | "支援队" | 公司/小组名称 |
| `companyLogo` | 字符串 | 无效 | 公司标志 URL |
| `primaryColor` | 字符串 | "#2563eb" (中文(简体) ) | 主要品牌颜色 |
| `quickQuestions` | 字符串 \[\] | \[ | 一系列快速问题 |
| `darkMode` | 布尔 | 虚假 | 启用暗模式 |
| `position` | 字符串 | "从下到上" | 部件位置 |
| `apiBaseUrl` | 字符串 | 无效 | API 端点 URL |
| `organizationId` | 字符串 | 无效 | 组织标识 |

## API 方法

```javascript
// Open the widget
ChatWidget.open();

// Close the widget
ChatWidget.close();

// Toggle theme
ChatWidget.toggleTheme();

// Update configuration
ChatWidget.updateConfig({ primaryColor: "#ff0000" });

// Send message programmatically
ChatWidget.sendMessage("Hello!");

// Destroy the widget
ChatWidget.destroy();
```

## 发展

```bash
# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

# Generate TypeScript definitions
npm run generate-types
```

## 许可证

麻省理工学院

## 常见问题

### @eshal-bot/chat-widget 是什么？

带有暗模式支持的美丽可嵌入式聊天部件

### 如何安装 @eshal-bot/chat-widget？

在项目目录运行 npm install @eshal-bot/chat-widget，或使用 pnpm add / yarn add / bun add。

### @eshal-bot/chat-widget 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @eshal-bot/chat-widget 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @eshal-bot/chat-widget 可以商用吗？

@eshal-bot/chat-widget 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @eshal-bot/chat-widget 的下载量有多少？

根据 npm 官方下载统计，@eshal-bot/chat-widget 在 2026/10/14 – 2026/11/12 这 30 天内被下载 7,153 次，日均约 238 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @eshal-bot/chat-widget 还在维护吗？

最新版本 0\.2\.54 发布于 2026/11/13（今天）；至今共发布 174 个版本，其中过去 12 个月发布了 170 个；首次发布于 2025/11/10。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

