12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { getScriptOptions } from '@/utils/common'
- const scriptOptions = getScriptOptions()
- class pluginLoginAuth {
- name: string
- options: any
- hooks: Record<string, Function>
- constructor(options = {}) {
- this.name = 'login'
- this.hooks = {}
- this.options = Object.assign(
- {
- auto: false,
- type: 'login-code'
- },
- scriptOptions,
- options
- )
- if (this.options.auto) {
- this.init()
- }
- }
- init() {
- // console.log('init', getScriptOptions())
- }
- use(context) {
- context.$emit('register-plugin-login-auth', this, {
- replay: true
- })
- }
- getInstance() {
- const hooks = this.hooks
- return hooks
- }
- register(hook, fn) {
- if (!this.hooks[hook]) {
- this.hooks[hook] = fn
- } else {
- console.warn('not register hook:', hook)
- }
- }
- }
- const LoginAuth = new pluginLoginAuth()
- export default LoginAuth
|