@msbfe/login-js
v1.0.9
Published
```javascript // src/plugins/login.client.js import Vue from 'vue' import LoginPlugin from '@msbfe/login-js' import '@msbfe/login-js/dist/style.css'
Downloads
6
Readme
@msb/login-js
nuxt2接入示例
// src/plugins/login.client.js
import Vue from 'vue'
import LoginPlugin from '@msbfe/login-js'
import '@msbfe/login-js/dist/style.css'
export default () => {
Vue.prototype.$login = function(callback) {
if (!localStorage.getItem("token")) {
const loginInstance = LoginPlugin.getInstance({
env: process.env.EXEC_ENV,
success: (data) => {
// 登录后统一处理方法(储存token,获取用户信息等)
// ....
loginInstance.close()
if (typeof callback === 'function') {
callback(data)
}
},
})
loginInstance.open()
} else if (typeof callback === 'function') {
callback()
}
}
}
// nuxt.config.js
plugins: [{ src: "~/plugins/login.client", ssr: false }]
// src/pages/xxx.vue
function onClick = () => {
this.$login({
// 登录鉴权后执行某些操作
// ....
})
}