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

xuanlin-ai-chat

v0.1.2

Published

A Vue.js AI chat component for easy integration

Readme

Xuanlin AI Chat

一个简单易用的Vue.js AI聊天组件,支持消息列表显示、输入框和发送功能。

特性

  • 🚀 简单易用,开箱即用
  • 🎨 现代化UI设计,支持亮色/暗色主题
  • 📱 响应式设计,支持移动端
  • 🔧 高度可定制,支持插槽和props
  • ♿ 无障碍访问支持
  • 📦 轻量级,无额外依赖
  • 🎯 样式隔离,不会影响宿主应用

安装

npm install xuanlin-ai-chat

使用方法

全局注册

import Vue from 'vue'
import AIChat from 'xuanlin-ai-chat'

// 样式会自动引入,无需手动导入CSS
Vue.use(AIChat)

局部注册

import { AIChat } from 'xuanlin-ai-chat'

export default {
  components: {
    AIChat
  }
}

基础用法

<template>
  <div id="app">
    <AIChat
      :messages="messages"
      @send="handleSend"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      messages: [
        {
          id: '1',
          content: '你好!',
          type: 'user',
          timestamp: Date.now() - 60000
        },
        {
          id: '2',
          content: '你好!我是AI助手,有什么可以帮助你的吗?',
          type: 'ai',
          timestamp: Date.now()
        }
      ]
    }
  },
  methods: {
    handleSend(message) {
      // 添加用户消息
      this.messages.push({
        id: Date.now().toString(),
        content: message,
        type: 'user',
        timestamp: Date.now()
      })
      
      // 模拟AI回复
      setTimeout(() => {
        this.messages.push({
          id: (Date.now() + 1).toString(),
          content: `收到你的消息:${message}`,
          type: 'ai',
          timestamp: Date.now()
        })
      }, 1000)
    }
  }
}
</script>

样式说明

重要:组件样式已经自动包含,无需手动引入CSS文件。所有样式都使用.xuanlin-ai-chat前缀,确保不会与宿主应用的样式冲突。

API

Props

| 参数 | 类型 | 默认值 | 说明 | |------|------|--------|------| | messages | Array | [] | 消息列表 | | placeholder | String | '请输入消息...' | 输入框占位符 | | disabled | Boolean | false | 是否禁用输入 | | height | String | '400px' | 聊天区域高度 | | theme | String | 'light' | 主题,支持 'light' 和 'dark' |

Events

| 事件名 | 参数 | 说明 | |--------|------|------| | send | message | 发送消息时触发 | | input | value | 输入内容变化时触发 |

Slots

| 插槽名 | 说明 | |--------|------| | header | 聊天头部内容 | | footer | 聊天底部内容 |

消息格式

{
  id: String,           // 消息唯一标识
  content: String,      // 消息内容
  type: String,         // 消息类型:'user' | 'ai'
  timestamp: Number     // 时间戳
}

高级用法

自定义头部和底部

<template>
  <AIChat :messages="messages" @send="handleSend">
    <template #header>
      <div class="custom-header">
        <h3>AI助手</h3>
        <span class="status">在线</span>
      </div>
    </template>
    
    <template #footer>
      <div class="custom-footer">
        <small>© 2024 AI Chat Component</small>
      </div>
    </template>
  </AIChat>
</template>

使用子组件

<template>
  <div class="custom-chat">
    <ChatMessageList :messages="messages" height="300px" />
    <ChatInput 
      placeholder="自定义占位符"
      @send="handleSend"
    />
  </div>
</template>

<script>
import { ChatMessageList, ChatInput } from 'xuanlin-ai-chat'

export default {
  components: {
    ChatMessageList,
    ChatInput
  }
}
</script>

暗色主题

<template>
  <AIChat
    :messages="messages"
    theme="dark"
    @send="handleSend"
  />
</template>

开发

# 安装依赖
npm install

# 启动开发服务器
npm run serve

# 构建库
npm run build:lib

# 代码检查
npm run lint

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!