This commit is contained in:
Edward Yang 2022-06-30 18:39:17 +08:00
parent 394a74ee1b
commit 1ee55af5a0
3 changed files with 18 additions and 1 deletions

View File

@ -43,10 +43,11 @@ class Manager
foreach ($existed as $dirname => $package) {
$pluginPath = $this->getPluginsDir() . DIRECTORY_SEPARATOR . $dirname;
$plugin = new Plugin($pluginPath, $package);
$status = $plugin->getStatus();
$plugin->setDirname($dirname);
$plugin->setName(Arr::get($package, 'name'));
$plugin->setInstalled(true);
$plugin->setEnabled(false);
$plugin->setEnabled($status);
$plugin->setVersion(Arr::get($package, 'version'));
$plugin->setColumns();

View File

@ -101,6 +101,12 @@ class Plugin implements Arrayable, \ArrayAccess
return admin_route('plugins.edit', ['code' => $this->code]);
}
public function getStatus(): bool
{
return SettingRepo::getPluginStatus($this->code);
}
/**
* 获取插件对应的设置字段, 并获取已存储在DB的字段值
*

View File

@ -39,6 +39,16 @@ class SettingRepo
->keyBy('name');
}
public static function getPluginStatus($pluginCode): bool
{
$status = Setting::query()
->where('type', 'plugin')
->where('space', $pluginCode)
->where('name', 'status')
->value('value');
return (bool)$status;
}
public static function update($type, $code, $fields)
{
Setting::query()->where('type', $type)->where('space', $code)->delete();