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

@m775/jsweixin

v1.0.2

Published

A lightweight JavaScript wrapper for WeChat JS-SDK, providing easy configuration and share API integration for web applications.

Readme

Gentbo Wxshare

微信 JS-SDK 分享工具,基于官方 jweixin 封装,采用链式调用方式快速完成微信分享配置,支持好友分享、朋友圈分享及自定义 JS-SDK 接口配置。


功能特性

  • 支持微信 JS-SDK 初始化
  • 支持链式调用
  • 支持好友分享
  • 支持朋友圈分享
  • 支持自定义 JS API
  • 支持 Debug 调试模式
  • 支持成功、取消回调
  • 支持动态修改分享内容
  • 零依赖(依赖微信官方 jweixin)

安装

直接引入:

<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="https://cloud.m775.net/js/jsweixin.js"></script>

npm:

npm i @m775/jsweixin
import "@m775/jsweixin";

快速开始

GB.Wxshare()
    .appid("wx123456789")
    .timestamp(1722040000)
    .nonce("abcdef")
    .sign("xxxxxxxxxxxxxxxx")

    .title("Gentbo")
    .desc("Gentbo 微信分享工具")
    .link("https://www.gentbo.com")
    .image("https://www.gentbo.com/logo.png")

    .run();

初始化配置

微信 JS-SDK 签名建议由服务器生成。

GB.Wxshare()
    .appid(appId)
    .timestamp(timestamp)
    .nonce(nonceStr)
    .sign(signature)
    .run();

API

debug()

开启 Debug 模式。

.debug(true)

|参数|类型|说明| |-------|------|------| |debug|Boolean|是否开启调试|


appid()

设置公众号 AppId。

.appid(appId)

|参数|类型| |-------|------| |appid|String|


timestamp()

设置时间戳。

.timestamp(timestamp)

|参数|类型| |-------|------| |timestamp|Number / String|


nonce()

设置随机字符串。

.nonce(nonceStr)

|参数|类型| |-------|------| |nonce|String|


sign()

设置签名。

.sign(signature)

|参数|类型| |-------|------| |signature|String|


api()

设置需要启用的微信 JS API。

支持数组或字符串。

.api([
    "onMenuShareAppMessage",
    "onMenuShareTimeline"
])

或

.api("onMenuShareAppMessage,onMenuShareTimeline")

addApi()

追加一个 API。

.addApi("chooseImage")

分享配置

title()

分享标题。

.title("Gentbo")

desc()

分享描述。

.desc("Gentbo JavaScript Library")

link()

分享链接。

.link("https://www.gentbo.com")

image()

分享图片。

必须为公网可访问地址。

.image("https://www.gentbo.com/logo.png")

success()

分享成功回调。

.success(()=>{
    console.log("分享成功");
})

cancel()

取消分享回调。

.cancel(()=>{
    console.log("取消分享");
})

run()

初始化微信 SDK 并注册分享。

.run()

完整示例

GB.Wxshare()
    .debug(false)

    .appid("wx123456789")

    .timestamp(1722040000)

    .nonce("abcdef")

    .sign("xxxxxxxxxxxxxxxx")

    .title("Gentbo")

    .desc("高性能 JavaScript 工具库")

    .link(location.href)

    .image("https://www.gentbo.com/logo.png")

    .success(()=>{
        console.log("分享成功");
    })

    .cancel(()=>{
        console.log("取消分享");
    })

    .run();

默认启用接口

工具默认启用以下微信分享接口:

onMenuShareAppMessage
onMenuShareTimeline

如果需要其它接口,可使用:

.api([
    "chooseImage",
    "previewImage",
    "scanQRCode"
])

或

.addApi("chooseImage")
.addApi("scanQRCode")

注意事项

  • 使用前必须先加载微信官方 jweixin SDK。
  • appId、timestamp、nonceStr、signature 必须由服务器生成。
  • 分享图片必须使用公网 HTTPS 地址。
  • 分享链接必须与 JS-SDK 签名使用的页面 URL 保持一致。
  • 必须在微信内置浏览器中使用。
  • 如果 wx 未加载,工具不会执行初始化。

浏览器支持

|浏览器|支持| |-------|------| |微信 Android|✔| |微信 iOS|✔|


Gentbo Custom License

Copyright (c) 2016-Present Zhou Bo
Website: https://developer.gentbo.com

Permission is granted to use this software for personal, educational, and commercial projects without modification.

You may not:

  1. Modify this software.
  2. Reverse engineer, decompile, or create derivative works based on this software.
  3. Redistribute, resell, sublicense, or publish this software or modified versions.
  4. Remove or alter copyright notices.

This software is provided "as is", without warranty of any kind. For commercial redistribution, OEM licensing, or special authorization:

Email: [email protected] QQ: 18486685 QQGroup: 431849998