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

vue-wonders-sso-util

v1.1.7

Published

wonders-sso vue工具

Downloads

3

Readme

使用方式

安装

NPM

npm install [email protected] --save

YARN

yarn add [email protected]

使用

全局注册 main.js中

import SSOGuard from 'vue-wonders-sso-util'
// 参数1:vue路由 VueRouter 
// 参数2:axios对象  
// 参数3:axios 的baseURL (①baseURL可以是指向应用后端的,后端需要对应的拦截,详见springboot后端内容 ②baseURL可以是请求单点中心的baseURL,但是work时候需要自己定义回调)
const ssoGuard = new SSOGuard(router,axios,process.env.VUE_APP_API_ROOT)
//注册到vue实例中
Vue.prototype.$SSOGuard = ssoGuard;
//开启单点拦截
ssoGuard.work();
//开启单点网络拦截
ssoGuard.axiosWork();

//这样就完成单点拦截,
// 获取用户信息在需要的地方调用this.$SSOGuard.getSSOUser()即可
// 注销方式在需要的地方调用this.$SSOGuard.logout()即可
/**
 * axios的完整拦截,需要自己在axios配置添加拦截器。
 * 如以下示例代码,当未授权时候,跳转到单点登录页面
 */
axios.defaults.validateStatus = function(status) {
    return status >= 200 && status <= 500 // 默认的
}
axios.interceptors.response.use(res => {
    if (res.status===401){
        let obj = res.data.result;
        let projectUrl = window.location.href
        window.location.href = `${obj.ssoUrl}?service=${obj.proUrl ? obj.proUrl : projectUrl}`;
        return ;
    }
    return res
}, error => {
    return Promise.reject(error)
})

一些方法

work
开启vue路由拦截
work方法有3个入参 errorBack, successBack, unauthorizedBack
errorBack:异常回调函数
successBack:成功(通过单点校验)回调函数,默认是直接next()
unauthorizedBack:401回调函数,默认是跳转到单点登录页面
logout
this.$SSOGuard.logout()
用于注销,注意此方法只会清除单点用到的缓存,cookie等。业务项目的请在调用此方法前自行清除
getSSOUser
this.$SSOGuard.getSSOUser()
获取单点用户
返回值例子
{
	"expireFreshTime": 1674029403195,
	"expireMinute": 30,
	"loginname": "srm_admin",//登录名
	"userid": "402819b96e1e334b016e8cf7e57c00a7",
	"username": "市人民医院管理员",//用户名
	"version": "ac64301d8e8f4f0ca50c4aa570e82bc1"
}
validate
校验是否登录
返回值为promise

springboot后端

使用此单点工具,后端需要对应的单点拦截。需要配置后端对应jar包 版本>=1.1.7

<dependency>
    <groupId>com.wonders</groupId>
    <artifactId>wonders-sso-backstage</artifactId>
    <version>1.1.7</version>
</dependency>