Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@xtc/common-login

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xtc/common-login

公共登录js

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
15
150%
Maintainers
2
Weekly downloads
 
Created
Source

使用说明

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()
        */
        
    }
    

FAQs

Package last updated on 01 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts