gengx
This commit is contained in:
@@ -6,6 +6,20 @@ use app\model\SystemSetting;
|
||||
|
||||
class SettingsService
|
||||
{
|
||||
private const DEFAULT_FEATURES = [
|
||||
'markdown' => true,
|
||||
'image' => true,
|
||||
'video' => true,
|
||||
'voice' => true,
|
||||
'document' => true,
|
||||
'emoji' => true,
|
||||
'upload_image' => true,
|
||||
'upload_video' => true,
|
||||
'upload_file' => true,
|
||||
'paste_image' => true,
|
||||
'short_drama' => true,
|
||||
];
|
||||
|
||||
public static function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
$row = SystemSetting::where('setting_key', $key)->find();
|
||||
@@ -36,18 +50,8 @@ class SettingsService
|
||||
|
||||
public static function getFeatures(): array
|
||||
{
|
||||
return self::get('features', [
|
||||
'markdown' => true,
|
||||
'image' => true,
|
||||
'video' => true,
|
||||
'voice' => true,
|
||||
'document' => true,
|
||||
'emoji' => true,
|
||||
'upload_image' => true,
|
||||
'upload_video' => true,
|
||||
'upload_file' => true,
|
||||
'paste_image' => true,
|
||||
]);
|
||||
$stored = self::get('features', []);
|
||||
return array_replace(self::DEFAULT_FEATURES, is_array($stored) ? $stored : []);
|
||||
}
|
||||
|
||||
public static function isFeatureEnabled(string $feature): bool
|
||||
|
||||
Reference in New Issue
Block a user