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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sd-account

v6.3.5

Published

水滴登录模块

Downloads

72

Readme

sd-account

INSTALL

$ yarn add sd-account

USEAGE

import account from 'sd-account' 

// appid(项目appid)
// userThirdScope(授权方式base 或者 user_info)
// thirdType(1,hz;3,sdc;7,sdb)
// codeExtend; 一个对象,用来扩展错误码拦截
Vue.use(account, {
  appid: 'wx536456456fsfsd',
  userThirdScope: 'base',
  thirdType: 1,
  codeExtend: {
    23230: () => {
      // action
    },
    20021: () => {
      // action
    }
  }
})

this.$sdAccount.login().then(() => {
  console.log('登录成功')
})

// 或者重置参数:
this.$sdAccount.login({
  url: `https://www.shuidix.com`,
  userThirdScope: `base` || `user_info`
})

API

//登录
// setting:可选,会重写Vue.use时传入的参数
// 允许重置两个参数: url, userThirdScope
login(setting)

//拦截错误码
interceptHttpCode(code)

//发送验证码, phone 是手机号, done是成功回调, fail是失败回调
sendVerifyCode({
 'mobile': mobile
}).then()

//config 包含{mobile: config.phone, verifyCode:config.verifyCode}. done, fail同上
loginWithMobile(config, done, fail)

// 是否登录
isLogin()

// 使用手机号+code登录
loginWithLongCode({
  code: '',
  mobile: '',
  thirdType: ''
}).then().catch()
...
更多接口在index.js查看

TIPS

// 方法需替换原来interceptHttpCode, 在'api/utils/index.js'
Vue.sdAccount.interceptHttpCode(code)

// 该字段在每次执微信行授权行为时都会刷新,用于标识当次授权行为是静默授权还是显式授权
// value值为user_info 或者 base
storage.get('tokenType')

// 推荐写法(in App.vue)
this.$router.afterEach((to, from) => {
  const needLogin = to.meta.login
  const plat = platform()

  if (needLogin) {
    if (plat === 1) {
      this.$sdAccount.login().then(() => {
        this.renderView = true
      }).catch(e => {
        console.log(e)
      })
    } else {
      if (!this.$sdAccount.isLogin()) {
        this.$showLogin(() => {
          this.renderView = true
        })
      } else {
        this.renderView = true
      }
    }
  } else {
    this.renderView = true
  }
})