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

@xtc/common-login

v1.0.3

Published

公共登录js

Readme

使用说明

npm install @xtc/common-login --save

导包
import LoginManager from '@xtc/common-login'
/**
 *  
*/
import {
    //获取用户信息
    getUserInfo,
    //退出登录
    logout,
    //切换代理
    switchAgent,
    //切换系统 
    switchSystem,
    //window.open方式打开统一菜单界面
    openAdminPage
    } from '@xtc/common-login'
初始化
onReady为login后回调
    const loginManager = new LoginManager({
        loginRequire: true,
        onReady: onReady
    });
    //lm === loginManager;router为路由对象
    function onReady(lm, router, errorInfo) {
        if(lm.state) {
            console.log("状态正常")
        } else {
            console.log("状态异常")
        }
        //获取用户ID
        lm.getUserId()
        //获取品牌
        lm.getBrand()
        //获取代理Id
        lm.getAgentId()
        //获取代理名称
        lm.getAgentName()
        //获取token
        lm.getToken()
        //获取全部参数
        lm.getParams()

        //获取菜单数组
        const menuList = router.getMenuList()
        //获取具有层级已排序的菜单列表
        const routeList = router.getRouteList()
        /*层级菜单结构
            routeList: [
                {
                    menuUrl: 菜单地址
                    name: 标题
                    expand: 扩展信息
                    children: 子级菜单数组
                }
            ]
        */

        //获取用户信息,用户角色信息
        const {userInfo, userRoleInfo} = getUserInfo()
        /*用户信息结构、用户角色结构
        userInfo: { object
            brand: 品牌
            mobile: 手机号
            remark: 备注
            userId: 用户Id,
            userName: 用户名
        }
        userRoleInfo: [ array
            {
                agentId: 代理Id,
                code: 角色代号,
                name: 角色别名,
                roleId: 角色Id,
                system: 所属系统
            }
        ]

        */
        /*
                如果你把lm挂到Vue的原型对象上,那么你可以在创建的Vue组件中以
            如下方式调用。
            Vue.prototype.$login = lm
            //若this指向vue实例

            //跳转到选择系统页 
            this.$login.switchSystem()
            //退出登录
            this.$login.logout()
            //跳转至登录权限管理
            this.$login.toAdmin()
            //跳转至选择代理页
            this.$login.switchAgent()
        */
        
    }