mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 11:20:53 +08:00
fix: read plugin enabled from DB for consistency
This commit is contained in:
@@ -17,6 +17,11 @@ trait HasPluginConfig
|
||||
*/
|
||||
protected ?string $pluginCode = null;
|
||||
|
||||
/**
|
||||
* 插件启用状态(仅当前对象生命周期内缓存)
|
||||
*/
|
||||
protected ?bool $pluginEnabled = null;
|
||||
|
||||
/**
|
||||
* 获取插件配置
|
||||
*/
|
||||
@@ -82,6 +87,7 @@ trait HasPluginConfig
|
||||
{
|
||||
$this->pluginCode = $pluginCode;
|
||||
$this->pluginConfig = null; // 重置配置缓存
|
||||
$this->pluginEnabled = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +120,15 @@ trait HasPluginConfig
|
||||
*/
|
||||
public function isPluginEnabled(): bool
|
||||
{
|
||||
return (bool) $this->getConfig('enable', false);
|
||||
if ($this->pluginEnabled !== null) {
|
||||
return $this->pluginEnabled;
|
||||
}
|
||||
|
||||
$pluginCode = $this->getPluginCode();
|
||||
$isEnabled = Plugin::where('code', $pluginCode)->value('is_enabled');
|
||||
$this->pluginEnabled = (bool) $isEnabled;
|
||||
|
||||
return $this->pluginEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,5 +139,6 @@ trait HasPluginConfig
|
||||
$pluginCode = $this->getPluginCode();
|
||||
Cache::forget("plugin_config_{$pluginCode}");
|
||||
$this->pluginConfig = null;
|
||||
$this->pluginEnabled = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user