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

@mini-code-tools/voices-libs

v1.0.0

Published

基于 Vue3 + Pinia + Vite 的 VoiceService 前端依赖库,为多端应用和 PC 端提供底层服务。

Readme

voices-libs

基于 Vue3 + Pinia + Vite 的 VoiceService 前端依赖库,为多端应用和 PC 端提供底层服务。

功能特性

  • API 封装 - 完整的 VoiceService HTTP API 封装
  • WebSocket 支持 - 实时意图识别和消息推送
  • 状态管理 - 基于 Pinia 的状态管理模块
  • 模块化设计 - 智能体、知识库、系统监控、数据备份四大核心模块
  • 工具函数 - 常用的工具函数和辅助方法

安装

npm install voices-libs

或从本地构建:

cd voices-libs
npm install
npm run build

快速开始

1. 在 Vue 项目中引入

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'

const app = createApp(App)
const pinia = createPinia()

app.use(pinia)
app.mount('#app')

2. 使用 API 模块

import { agentAPI, knowledgeBaseAPI } from 'voices-libs'

// 获取智能体列表
const agents = await agentAPI.getAgents({ page: 1, pageSize: 10 })

// 创建智能体
const newAgent = await agentAPI.createAgent({
  name: '我的智能体',
  description: '这是一个测试智能体',
  language_style: 'friendly'
})

3. 使用 Pinia Store

import { useAgentStore, useKnowledgeBaseStore } from 'voices-libs'

// 在组件中使用
const agentStore = useAgentStore()
await agentStore.fetchAgents()

const kbStore = useKnowledgeBaseStore()
await kbStore.fetchKnowledgeBases()

4. 使用 WebSocket 服务

import { websocketService } from 'voices-libs'

// 连接 WebSocket
websocketService.connect('user-session-id')

// 监听消息
websocketService.on('message', (data) => {
  console.log('收到消息:', data)
})

// 发送意图识别请求
websocketService.recognize({
  text: '查询北京天气',
  session_id: 'user-123'
})

// 断开连接
websocketService.disconnect()

5. 使用工具函数

import { formatDate, formatFileSize, storage } from 'voices-libs'

// 格式化日期
const dateStr = formatDate(new Date(), 'YYYY-MM-DD')

// 格式化文件大小
const sizeStr = formatFileSize(1024 * 1024) // "1.00 MB"

// 本地存储
storage.set('key', { data: 'value' })
const value = storage.get('key')

环境配置

创建 .env.env.local 文件:

# API 基础地址
VITE_API_BASE_URL=http://localhost:8763

# WebSocket 基础地址
VITE_WS_BASE_URL=ws://localhost:8763

模块说明

API 模块

  • agentAPI - 智能体管理(CRUD、部署、导入导出)
  • knowledgeBaseAPI - 知识库管理(CRUD、文档管理)
  • systemAPI - 系统监控(状态、健康、指标)
  • backupAPI - 数据备份(备份、恢复、设置)
  • intentAPI - 意图识别(HTTP 方式)

Pinia Stores

  • useAgentStore - 智能体状态管理
  • useKnowledgeBaseStore - 知识库状态管理
  • useSystemMonitorStore - 系统监控状态
  • useBackupStore - 备份管理状态

工具函数

  • formatDate - 日期格式化
  • formatFileSize - 文件大小格式化
  • formatPercent - 百分比格式化
  • debounce - 防抖函数
  • throttle - 节流函数
  • deepClone - 深拷贝
  • generateUUID - 生成 UUID
  • storage - 本地存储工具

开发

# 安装依赖
npm install

# 启动开发服务器
npm run dev

# 构建库
npm run build

# 预览构建结果
npm run preview

技术栈

  • Vue 3.5.25+
  • Pinia 2.1.7+
  • Axios 1.6.0+
  • Vite 4.5.0+

许可证

MIT