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

capacitor-plugin-awake-wxmini

v0.0.5

Published

App awake wx mini program.

Readme

capacitor-plugin-awake-wxmini

capacitor-plugin-awake-wxmini可以让用户在App中唤起微信小程序,并在操作完成后返回到App中的一个插件。

支持平台

  • Android

使用方法

npm install capacitor-plugin-awake-wxmini --save

/* 在android的MainActivity.java中添加插件 */

// 引入插件
import com.brainy.awakewxmini.AwakeWxMiniPlugin;
// 添加插件
add(AwakeWxMiniPlugin.class);

API

awake

awake(options:AwakeOptions):void

App中调用改方法唤起微信小程序。

options:AwakeOptions

return:void

Interface Used

AwakeOptions


interface AwakeOptions {
    appId: string;
    // 应用id,微信开放平台申请的
    miniId:string;
    // 微信小程序原始Id,gh_开头
    path:string;
    // 小程序打开路径,不填则为小程序默认打开路径,可通过路径传参。如:"/path?a=1&b=2"
    type:number;
    // 小程序打开类型,0:正式版,1:开发版,2:体验版
}

Example

    import { Plugins } from '@capacitor/core';

    Plugins.AwakeWxMiniPlugin.awake({
        appId: "",
        miniId: "",
        path: "",
        type: 0
    })

Tips:

如果需要实现小程序执行完成回到app中,需要做以下操作:

1.在项目的MainActivity同级目录中新建文件夹wxapi,并在wxapi中新建WXEntryActivity类,并填入以下内容

package com.brainy.manager.wxapi;//注意更改为自己的包名路径

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.brainy.awakewxmini.AwakeWxMiniPlugin;
import com.getcapacitor.JSObject;
import com.getcapacitor.PluginCall;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;


public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        IWXAPI api = AwakeWxMiniPlugin.getWxApi(this);

        if (api == null) {
            startMainActivity();
        } else {
            api.handleIntent(getIntent(), this);
        }
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);

        setIntent(intent);

        IWXAPI api = AwakeWxMiniPlugin.getWxApi(this);
        if (api == null) {
            startMainActivity();
        } else {
            api.handleIntent(intent, this);
        }

    }

    @Override
    public void onResp(BaseResp resp) {
        Log.d("WX", resp.toString());

        PluginCall call = AwakeWxMiniPlugin.getCall();

        if (call == null) {
            startMainActivity();
            return ;
        }

        switch (resp.errCode) {
            case BaseResp.ErrCode.ERR_OK:
                switch (resp.getType()) {
                    case ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM:
                        Log.d("WX", "miniprogram back;");
                        WXLaunchMiniProgram.Resp miniProResp = (WXLaunchMiniProgram.Resp) resp;
                        launchMiniProResp(miniProResp);
                        break;
                    default:
                        call.success();
                        break;
                }
                break;
            case BaseResp.ErrCode.ERR_USER_CANCEL:
                call.error("用户取消");
                break;
            case BaseResp.ErrCode.ERR_AUTH_DENIED:
                call.error("授权失败");
                break;
            case BaseResp.ErrCode.ERR_SENT_FAILED:
                call.error("发送请求失败");
                break;
            case BaseResp.ErrCode.ERR_UNSUPPORT:
                call.error("微信不支持");
                break;
            case BaseResp.ErrCode.ERR_COMM:
                call.error("普通错误");
                break;
            default:
                call.error("未知错误");
                break;
        }

        finish();
    }

    @Override
    public void onReq(BaseReq req) {
        finish();
    }

    protected void startMainActivity() {
        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setPackage(getApplicationContext().getPackageName());
        getApplicationContext().startActivity(intent);
    }

    protected void launchMiniProResp(WXLaunchMiniProgram.Resp launchMiniProResp){
        PluginCall call = AwakeWxMiniPlugin.getCall();
        String extraData =launchMiniProResp.extMsg; //对应小程序组件 <button open-type="launchApp"> 中的 app-parameter 属性
        JSObject response = new JSObject();
        try {
            response.put("extMsg", extraData);
        }catch (Exception e){
            Log.e("WX", e.getMessage());
        }
        call.success(response);
    }
}

2.在AndroidManifest.xml中加入新建的activity

        <activity android:name=".wxapi.WXEntryActivity" android:label="@string/app_name" android:exported="true" android:taskAffinity="com.brainy.manager" android:launchMode="singleTask">
        </activity>

3.实现小程序回到app的回调

    Plugins.AwakeWxMiniPlugin.awake({
        appId: "",
        miniId: "",
        path: "",
        type: 0
    }).then(res=>{
        
    })