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

wildfire-im-sdk

v0.1.9

Published

野火IM SDK for Vue3 projects

Downloads

34

Readme

野火IM SDK

野火IM的Vue3版本SDK,用于在Vue3项目中快速集成野火IM的即时通讯功能。

安装

npm install wildfire-im-sdk --save
# 或者
yarn add wildfire-im-sdk

使用

基本用法

import { createApp } from 'vue';
import App from './App.vue';
import { init, connect } from 'wildfire-im-sdk';

// 初始化SDK
init();

// 连接IM服务器
connect('your-user-id', 'your-token');

// 创建Vue应用
createApp(App).mount('#app');

自定义配置

import { createApp } from 'vue';
import App from './App.vue';
import { init, connect, Config } from 'wildfire-im-sdk';

// 自定义配置
const customConfig = {
  APP_SERVER: 'https://your-im-server.com',
  DEFAULT_USER_ID: 'custom-user',
  DEFAULT_TOKEN: 'custom-token',
  AUTO_CONNECT: true
};

// 初始化SDK,传入自定义配置
init(customConfig);

// 创建Vue应用
createApp(App).mount('#app');

在组件中使用

<template>
  <div>
    <div>连接状态: {{ connectionStatusText }}</div>
    <button @click="sendMessage">发送消息</button>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { wfc, EventType, ConnectionStatus, ConversationType, TextMessageContent } from 'wildfire-im-sdk';

// 状态变量
const connectionStatus = ref(wfc.getConnectionStatus());

// 计算属性
const connectionStatusText = computed(() => {
  switch (connectionStatus.value) {
    case ConnectionStatus.ConnectionStatusUnconnected:
      return '未连接';
    case ConnectionStatus.ConnectionStatusConnecting:
      return '连接中...';
    case ConnectionStatus.ConnectionStatusConnected:
      return '已连接';
    case ConnectionStatus.ConnectionStatusAuthenticated:
      return '已认证';
    default:
      return '未知状态';
  }
});

// 发送消息
const sendMessage = () => {
  // 创建会话
  const conversation = {
    type: ConversationType.Single,
    target: 'user123',
    line: 0
  };
  
  // 创建消息内容
  const content = new TextMessageContent('Hello, this is a test message!');
  
  // 发送消息
  wfc.sendMessage(conversation, content, [], 
    undefined, undefined, 
    (messageUid, timestamp) => {
      console.log('消息发送成功', messageUid, timestamp);
    }, 
    (error) => {
      console.error('消息发送失败', error);
    }
  );
};

// 生命周期
onMounted(() => {
  // 监听连接状态变化
  wfc.eventEmitter.on(EventType.ConnectionStatusChanged, (status) => {
    connectionStatus.value = status;
  });
});

onUnmounted(() => {
  // 移除监听器
  wfc.eventEmitter.off(EventType.ConnectionStatusChanged);
});
</script>

API 参考

初始化和连接

| 函数 | 描述 | | --- | --- | | init(config?) | 初始化SDK,可选传入自定义配置 | | connect(userId, token) | 连接到IM服务器 | | disconnect() | 断开连接 | | getConnectionStatus() | 获取当前连接状态 |

事件类型

可以通过 wfc.eventEmitter.on(EventType.xxx, callback) 来监听各种事件。

| 事件 | 描述 | | --- | --- | | EventType.ConnectionStatusChanged | 连接状态变化 | | EventType.ReceiveMessage | 接收到新消息 | | EventType.SendMessage | 发送消息 | | EventType.RecallMessage | 撤回消息 | | ... | 更多事件类型 |

会话类型

| 类型 | 值 | 描述 | | --- | --- | --- | | ConversationType.Single | 0 | 单聊 | | ConversationType.Group | 1 | 群聊 | | ConversationType.ChatRoom | 2 | 聊天室 | | ConversationType.Channel | 3 | 频道 |

开发

# 安装依赖
npm install

# 启动示例项目
npm run serve

# 构建SDK
npm run build:lib

许可证

MIT