使用形参解构以减少继承类非必要传参
Signed-off-by: 柠檬冲水 <10424920+ningmengchongshui@user.noreply.gitee.com>
This commit is contained in:
parent
972ddfc492
commit
73531b39b3
|
@ -17,27 +17,26 @@ export default class plugin {
|
||||||
* @param task.fnc 定时任务方法名
|
* @param task.fnc 定时任务方法名
|
||||||
* @param task.log false时不显示执行日志
|
* @param task.log false时不显示执行日志
|
||||||
*/
|
*/
|
||||||
constructor (data) {
|
constructor({ name = 'your-plugin', dsc = '无', event = 'message', priority = 5000, task = { fnc: '', cron: '' }, rule = [] }) {
|
||||||
/** 插件名称 */
|
/** 插件名称 */
|
||||||
this.name = data.name
|
this.name = name
|
||||||
/** 插件描述 */
|
/** 插件描述 */
|
||||||
this.dsc = data.dsc
|
this.dsc = dsc
|
||||||
/** 监听事件,默认message https://oicqjs.github.io/oicq/#events */
|
/** 监听事件,默认message https://oicqjs.github.io/oicq/#events */
|
||||||
this.event = data.event || 'message'
|
this.event = event
|
||||||
/** 优先级 */
|
/** 优先级 */
|
||||||
this.priority = data.priority || 5000
|
this.priority = priority
|
||||||
/** 定时任务,可以是数组 */
|
/** 定时任务,可以是数组 */
|
||||||
this.task = {
|
this.task = {
|
||||||
/** 任务名 */
|
/** 任务名 */
|
||||||
name: '',
|
name: '',
|
||||||
/** 任务方法名 */
|
/** 任务方法名 */
|
||||||
fnc: data.task?.fnc || '',
|
fnc: task.fnc || '',
|
||||||
/** 任务cron表达式 */
|
/** 任务cron表达式 */
|
||||||
cron: data.task?.cron || ''
|
cron: task.cron || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 命令规则 */
|
/** 命令规则 */
|
||||||
this.rule = data.rule || []
|
this.rule = rule
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue