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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dwk-sse-chat

v1.5.0

Published

一个基于Vue3的聊天组件库,支持在Vue项目中导入使用,也支持在普通HTML页面中通过脚本标签直接引入使用。

Readme

DWK SSE Chat

一个基于Vue3的聊天组件库,支持在Vue项目中导入使用,也支持在普通HTML页面中通过脚本标签直接引入使用。

特性

  • 支持多种使用方式(Vue组件、JS库)
  • 悬浮球式聊天窗口
  • 支持拖拽和边缘吸附
  • 支持全屏/小窗模式切换
  • 美观的UI和流畅的动画

安装

在Vue项目中使用

# npm
npm install dwk-sse-chat

# yarn
yarn add dwk-sse-chat

# pnpm
pnpm add dwk-sse-chat

在HTML页面中直接使用

<script src="https://你的域名/chat.js"></script>

使用方法

方法1: 直接在Vue项目中引入

<template>
  <div class="chat-wrapper">
    <ChatWindows />
  </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { ChatWindows } from 'dwk-sse-chat';

onMounted(() => {
  // 初始化配置
  window.dispatchEvent(new CustomEvent('chatConfigUpdate', { 
    detail: {
      robotname: "机器人名称",
      dwk_token: "你的token",
      title: "聊天窗口标题",
      baseUrl: "API基础URL",
      isFullScreen: false // 是否全屏显示
    }
  }));
})
</script>

<style>
/* 重要:确保包装容器有正确的定位和层级 */
.chat-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}
</style>

方法2: 使用浏览器直接引入方式

<!DOCTYPE html>
<html>
<head>
  <title>DWK Chat 示例</title>
</head>
<body>
  <h1>聊天组件示例</h1>
  
  <!-- 引入聊天组件 -->
  <script src="path/to/chat.js"></script>
  <script>
    // 初始化聊天组件
    var chat = new Chat({
      robotname: "机器人名称",
      dwk_token: "你的token",
      title: "聊天窗口标题",
      baseUrl: "API基础URL"
    });
    
    // 显示聊天窗口
    chat.show();
  </script>
</body>
</html>

配置选项

| 选项 | 类型 | 必填 | 默认值 | 说明 | |------|------|------|------|------| | robotname | string | 否 | 'AI助手' | 机器人名称 | | dwk_token | string | 是 | - | 认证token | | title | string | 否 | 'DWK SSE Chat' | 聊天窗口标题 | | baseUrl | string | 是 | - | API基础URL | | isFullScreen | boolean | 否 | false | 是否以全屏模式显示 |

API方法

show()

显示聊天窗口。

chat.show();

hide()

隐藏聊天窗口。

chat.hide();

sendMessage(message)

发送一条消息。

chat.sendMessage('你好,AI助手!');

updateConfig(config)

更新配置。

chat.updateConfig({
  title: '新标题',
  isFullScreen: true
});

常见问题

悬浮球不显示或位置不正确

确保包装组件具有正确的样式:

.chat-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

并且保证在初始化后调用配置更新事件:

window.dispatchEvent(new CustomEvent('chatConfigUpdate', { 
  detail: { /* 你的配置 */ }
}));

聊天窗口平铺在应用中

这通常是因为包装容器缺少正确的CSS定位。确保包装组件设置了position: fixed且覆盖整个视口。

如何完全自定义样式?

可以通过全局CSS覆盖组件样式:

/* 自定义悬浮球 */
.custom-floating-ball {
  background-color: #ff5500 !important; /* 自定义颜色 */
}

/* 自定义聊天窗口 */
#dwk-chat-app.dwk-chat-app {
  border-radius: 0 !important; /* 移除圆角 */
}

开发者指南

构建

npm run build

调试

npm run dev