
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
dwk-sse-chat
Advanced tools
一个基于Vue3的聊天组件库,支持在Vue项目中导入使用,也支持在普通HTML页面中通过脚本标签直接引入使用。
# npm
npm install dwk-sse-chat
# yarn
yarn add dwk-sse-chat
# pnpm
pnpm add dwk-sse-chat
<script src="https://你的域名/chat.js"></script>
<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>
<!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 | 是否以全屏模式显示 |
显示聊天窗口。
chat.show();
隐藏聊天窗口。
chat.hide();
发送一条消息。
chat.sendMessage('你好,AI助手!');
更新配置。
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
FAQs
一个基于Vue3的聊天组件库,支持在Vue项目中导入使用,也支持在普通HTML页面中通过脚本标签直接引入使用。
The npm package dwk-sse-chat receives a total of 23 weekly downloads. As such, dwk-sse-chat popularity was classified as not popular.
We found that dwk-sse-chat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.