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

equity-core

v1.0.9

Published

和多惠APP H5基础组件

Readme

equity-core

equity-core基于Vue2,封装了和多惠H5基础能力,具体包括:和客户端通信能力、懒加载、登录、登出、数据请求、加载进度条等功能。

使用方式

1、引入库

npm install equity-core --save 或者
yarn add equity-core

2、初始化

在入口文件(即:main.js)中,

import Vue from "vue";
import EquityCore from "equity-core";

Vue.use(EquityCore, {router});

能力介绍

1、客户端能力

代码示例:

this.ability.login(); //调用客户端能力进行登录    

Props

| 属性名 | 说明 | 类型 | 默认值 | |-------|---------------|-----|-----| |isH5|是否使用浏览器浏览|Boolean|false| |isAPP|是否嵌套客户端|Boolean|false| |isAndroid|是否嵌套安卓客户端|Boolean|false| |isIOS|是否嵌套iOS客户端|Boolean|false|

Methods

| 方法名 | 说明 | 请求参数 | 返回值 | |-------|---------------|-----|-----| |getMobile|获取用户手机号码|-|Promise| |navigation|导航|name: 地方名称longitude: 纬度latitude: 手机号码|-| |login|登录|-|-| |getToken|获取大网令牌,用于第三方单点登录|-|Promise| |logout|登出|-|-| |getLocation|获取经纬度|-|Promise| |openMcsCloud|打开我的云盘|-|Promise| |openMiguRead|打开咪咕阅读|-|Promise| |openMiguGame|打开咪咕云游戏|-|Promise| |openMiguMusic|打开我的彩铃|-|Promise| |startGameQos|开启游戏加速|-|Promise| |startLiveQos|开启直播加速|-|Promise| |startVipQos|开启上网加速|-|Promise| |openPage|打开页面|url: 链接地址title?:标题ssologin?:是否需要单点|-| |getDistance|获取当前位置与某经纬度的距离|location: 经纬度|Promise| |setItem|存储数据|key:数据keyvalue:数据值type:存储方式,包括local(使用localStorage存储)、native(使用客户端存储)|-| |getItem|获取已存储的数据|key:数据keytype:存储方式,包括local(使用localStorage存储)、native(使用客户端存储)|Promise| |removeItem|删除已存储的数据|key:数据keytype:存储方式,包括local(使用localStorage存储)、native(使用客户端存储)|-| |checkVersion|检查版本是否有更新|-|-| |getVersion|获取当前客户端版本号|-|Promise| |getCacheSize|获取客户端缓存大小|-|Promise| |clearCache|清除缓存|-|-| |emit|发布全局事件|event: 事件名称params: 参数|-|

2、懒加载

代码示例:

import { lazyLoad } from "equity-core";

//1、代码加载
const load = lazyLoad(`views/test.vue`);
load(cmp=> {}, errMsg=>{alert(errMsg);});

//2、路由加载
const router = new VueRouter({
    routes: [{
        path: 'xxx',
        name: 'xxx',
        component: lazyLoad('xxx)
    }]
})

3、登录

代码示例:

import { login } from "equity-core";

login().then(user=> {
    console.log('当前用户:', user);
});

4、登出

代码示例:

import { logout } from "equity-core";

logout();

5、数据请求

数据请求,封装了axios库。

代码示例:

this.api.request({
    url: 'xxx',
    method: 'get',
    params: {}
}).then(res=> {
    console.log('请求返回内容:', res);
});

6、加载进度条

代码示例:

//显示进度条
this.$showLoading();

//隐藏进度条
this.$hideLoading();

7、路由加强

对 vue-router组件进行了加强,包括是否显示页面加载进度条、是否需要进行登录,如果需要登录,会检查用户是否已经登录,如果没有登录,跳转至登录界面进行登录对;如果已经登录,当前vue实例赋值user对象。

代码示例

const router = new VueRouter({
    routes: [{
        path: 'xxx',
        name: 'xxx',
        meta: {
            title: '标题',
            permission: 'auth', //认证,包含auth(强制登录)、some(如果登录进入用户模式,如果没登录进入游客模块)、none(不需要登录)
            showLoading: true //是否显示页面加载进度条
        }
        component: lazyLoad('xxx)
    }]
})

8、vue加强

  • 守卫加强

vue增加pageResume守卫,页面从隐藏状态进入到激活状态时,触发该守卫。

代码示例:

export default {
    name: 'Test',
    pageResume() {
        this.loadData();
    },
    methods: {
        loadData() {
            console.log('加载数据');
        }
    }
}
  • 实例加强

vue实例增加如下属性和方法。

Props

| 属性名 | 说明 | 类型 | 默认值 | |-------|---------------|-----|-----| |user|当前登录用户|Object|-| |api|数据请求对象|Object|-| |ability|客户端能力|Object|-|

Methods

| 方法名 | 说明 | 请求参数 | 返回值 | |-------|---------------|-----|-----| |$showLoading|显示加载进度条|-|-| |$hideLoading|隐藏进度条|-|-| |bindEvent|监听全局事件|event: 事件名称callback: 回调方法scope?: 作用域,实例销毁时会自动注销事件|-|