mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
refactor: 重构
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
export * from './dns-provider'
|
||||
export * from './plugin'
|
||||
export * from './access-provider'
|
||||
export * from './dns-provider/index.js'
|
||||
export * from './plugin/index.js'
|
||||
export * from './access-provider/index.js'
|
||||
export { Store } from './store/store.js'
|
||||
export { util } from './utils'
|
||||
export { util } from './utils/index.js'
|
||||
// module.createRequireFromPath()
|
||||
|
||||
@@ -4,7 +4,11 @@ import dayjs from 'dayjs'
|
||||
import Sleep from '../utils/util.sleep.js'
|
||||
|
||||
export class AbstractPlugin {
|
||||
constructor ({ accessProviders }) {
|
||||
constructor (options) {
|
||||
if (options == null) {
|
||||
throw new Error('插件安装失败:参数不允许为空')
|
||||
}
|
||||
const { accessProviders } = options
|
||||
this.logger = logger
|
||||
this.accessProviders = accessProviders
|
||||
}
|
||||
|
||||
@@ -26,11 +26,18 @@ export class Registry {
|
||||
}
|
||||
|
||||
get (name) {
|
||||
if (name) {
|
||||
return this.collection[name]
|
||||
if (!name) {
|
||||
throw new Error('插件名称不能为空')
|
||||
}
|
||||
|
||||
throw new Error(`${name} cant blank`)
|
||||
if (!this.collection) {
|
||||
this.collection = {}
|
||||
}
|
||||
const plugin = this.collection[name]
|
||||
if (!plugin) {
|
||||
throw new Error(`插件${name}还未注册`)
|
||||
}
|
||||
return plugin
|
||||
}
|
||||
|
||||
getCollection () {
|
||||
|
||||
Reference in New Issue
Block a user