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

@shencom/utils-userinfo

v0.3.3

Published

用户统一管理工具包

Downloads

221

Readme

@shencom/utils-userinfo

用户统一管理工具包

Install

pnpm add @shencom/utils

# or

pnpm add @shencom/utils-userinfo

Basic Usage

const userinfo = new BaseUserInfo(Option);

Options

interface Options {
  /** 存储方法 */
  Storage: ScStorageBase;
}

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ------- | -------- | ------------- | ------ | ------ | | Storage | 存储方法 | ScStorageBase | - | 必填 |

Example

import { ScUserInfoBase } from '@shencom/utils';
// import { ScUserInfoBase } from '@shencom/utils-userinfo';
import { ScStorage } from './storage'; // 初始化过的

const UserInfo = new ScUserInfoBase({
  Storage: ScStorage,
});

export default UserInfo;

Attrs

sex

  • 说明: 性别
  • 类型:
    enum Sex {
      '未知' = 0,
      '男',
      '女',
      '保密',
    }
  • 示例:
    userinfo.sex[1];
    userinfo.sex[2];

Methods

setUserInfo

  • 说明: 存储用户信息
  • 类型: (data: SC.User.Info): void
  • 参数:
    • data: 用户信息
  • 示例:
    setUserInfo(data);

setRefreshToken

  • 说明: 设置存储 RefreshToken 有效时间减去 1 天
  • 类型: (refreshToken: SC.User.RefreshToken): void
  • 参数:
    • refreshToken: 过期时间和 token
  • 示例:
    setRefreshToken(data);

setRootToken

  • 说明:
    • 设置 tokenrefreshTokenwxToken
    • openid 存在,uid 不存在的时候,存储的 tokenwxToken
    • 否则存储的为 tokenrefreshToken
  • 类型: (data: SC.User.RootInfo): void
  • 参数:
    • data: 登录接口返回的数据
  • 示例:
    setRootToken(data);

setRootInfo

  • 说明: 设置 tokenrefreshTokenuserInfo
    • setRootTokensetUserInfo的集合;
  • 类型: (data: SC.User.RootInfo): void
  • 参数:
    • data: 登录接口返回的数据
  • 示例:
    setRootInfo(data);

| 方法名 | 说明 | 参数 | 返回值 | | -------------------- | ------------------------------ | ------ | ------------ | | getUserInfo | 获取用户信息 | - | SC.User.Info | | removeUserInfo | 移除用户信息 | - | - | | getPhone | 获取手机号 | - | String | | isPhone | 手机号是否存在 | - | Boolean | | getUid | 获取用户 id | - | String | | isUid | 用户 id 是否存在 | - | Boolean | | getOpenId | 获取 openid | - | String | | isOpenId | 用户 openid 是否存在 | - | Boolean | | getAvatar | 获取头像 | - | String | | isAvatar | 头像是否存在 | - | Boolean | | getNickname | 获取昵称 | - | String | | isNickname | 昵称是否存在 | - | Boolean | | getRealname | 获取真实姓名 | - | String | | isRealname | 真实姓名是否存在 | - | Boolean | | getToken | 获取 tokne | - | String | | setToken | 设置 tokne | String | - | | removeToken | 移除 tokne | - | - | | getWxToken | 获取微信 tokne | - | String | | setWxToken | 设置微信 tokne | String | - | | removeWxToken | 移除微信 tokne | - | - | | getRefreshToken | 获取 RefreshToken | - | String | | removeRefreshToken | 移除 RefreshToken | - | - | | hasAvatarAndName | 是否存在头像和昵称或者真实姓名 | - | - | | isWxUser | 是否是微信用户 | - | Boolean | | isSysUser | 是否是系统用户 | - | Boolean | | isLogin | 是否登录 | - | Boolean | | clearAllUser | 清除全部用户的信息 | - | - |