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

@quec-wx-mp/api-msg

v1.0.0

Published

消息中心

Readme

消息中心

消息中心模块,提供消息列表查询、未读统计、已读标记、删除和消息类型统计等 API。

安装

npm install @quec-wx-mp/api-msg
import apiMsg from '@quec-wx-mp/api-msg'
const plugin = requirePlugin('quecPlugin')

plugin.use(apiMsg)

API 列表

| 方法 | 说明 | | ---------------- | ---------------------- | | getMsgList | 获取消息列表数据 | | getMsgNoReadList | 获取未读消息数量 | | msgDelete | 删除消息 | | readMsg | 标记消息已读 | | getMsgStatsV2 | 统计用户消息类型(v2) |


API 详细说明

1) 获取消息列表数据

接口名称

getMsgList

功能描述

按设备和消息类型分页查询消息列表。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------------ | -------- | ------ | ---- | ---------------------------------- | | dk | string | - | 是 | 设备 dk | | pk | string | - | 是 | 产品 pk | | msgType | number | - | 是 | 消息类型(1 通知,2 告警,3 故障) | | page | number | - | 是 | 页码 | | pageSize | number | - | 是 | 每页数量 | | firstLabelList | any | - | 否 | 一级标签筛选 | | secondaryLabelList | any | - | 否 | 二级标签筛选 | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为消息分页列表。

示例代码

plugin.msg.getMsgList({
  dk: 'device_key',
  pk: 'product_key',
  msgType: 1,
  page: 1,
  pageSize: 10,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

2) 获取未读消息数量

接口名称

getMsgNoReadList

功能描述

获取指定消息类型的未读消息数量。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------------ | -------- | ------ | ---- | ---------------------------------- | | msgType | number | - | 否 | 消息类型(1 通知,2 告警,3 故障) | | firstLabelList | any | - | 否 | 一级标签筛选 | | secondaryLabelList | any | - | 否 | 二级标签筛选 | | page | number | 1 | 否 | 页码(内部固定为 1) | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,可通过 res.data.total 或返回结构中的总数字段获取未读数。

示例代码

plugin.msg.getMsgNoReadList({
  msgType: 2,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

3) 删除消息

接口名称

msgDelete

功能描述

根据消息 ID 删除单条消息。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | msgId | string | - | 是 | 消息 ID | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.msg.msgDelete({
  msgId: 'msg_id',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

4) 标记消息已读

接口名称

readMsg

功能描述

按消息 ID 列表批量标记已读。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------------ | -------- | ------ | ---- | ---------------------------------- | | msgIdList | array | - | 是 | 消息 ID 列表 | | msgType | number | - | 是 | 消息类型(1 通知,2 告警,3 故障) | | firstLabelList | any | - | 否 | 一级标签筛选 | | secondaryLabelList | any | - | 否 | 二级标签筛选 | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应。

示例代码

plugin.msg.readMsg({
  msgIdList: ['msg_1', 'msg_2'],
  msgType: 1,
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})

5) 统计用户消息类型

接口名称

getMsgStatsV2

功能描述

统计用户消息类型数量。

参数

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------- | ------ | ---- | -------- | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |

返回数据

  • success(res):接口成功响应,res.data 为消息类型统计数据。

示例代码

plugin.msg.getMsgStatsV2({
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.log(JSON.stringify(err))
  },
  complete() {}
})