fix: 修复上下文
This commit is contained in:
parent
d679d70023
commit
ac4df58eec
|
@ -1,3 +0,0 @@
|
||||||
genshin
|
|
||||||
system-plugin
|
|
||||||
miao-plugin
|
|
|
@ -340,27 +340,34 @@ class PluginsLoader {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
for (const plugin of priority) {
|
for (const plugin of priority) {
|
||||||
/**
|
if (!plugin?.getContext) continue
|
||||||
* 上下文hook
|
|
||||||
*/
|
|
||||||
if (!plugin.getContext) continue
|
|
||||||
const context = {
|
const context = {
|
||||||
...plugin.getContext(),
|
...plugin.getContext(),
|
||||||
...plugin.getContext(false, true)
|
...plugin.getContext(false, true)
|
||||||
}
|
}
|
||||||
if (!lodash.isEmpty(context)) {
|
|
||||||
let ret
|
if (lodash.isEmpty(context)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不为空的时候
|
||||||
|
let ret = false
|
||||||
|
|
||||||
|
// 从方法里执行
|
||||||
for (const fnc in context) {
|
for (const fnc in context) {
|
||||||
// 不是函数,错误插件错误写法
|
// 不是函数,错误插件错误写法
|
||||||
if (typeof plugin[fnc] !== 'function') {
|
if (typeof plugin[fnc] !== 'function') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ret ||= await plugin[fnc](context[fnc])
|
ret = await plugin[fnc](context[fnc])
|
||||||
}
|
}
|
||||||
// 返回continue时,继续响应后续插件
|
|
||||||
if (ret === 'continue') continue
|
// 不是约定的直接
|
||||||
return
|
if (typeof ret != 'boolean' && ret !== true) {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -210,7 +210,7 @@ export class Plugin {
|
||||||
* @param isGroup
|
* @param isGroup
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getContext(type: string, isGroup?: boolean) {
|
getContext(type?: string, isGroup?: boolean) {
|
||||||
if (type) return State[this.conKey(isGroup)]?.[type]
|
if (type) return State[this.conKey(isGroup)]?.[type]
|
||||||
return State[this.conKey(isGroup)]
|
return State[this.conKey(isGroup)]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue