M4: 插件框架(钩子系统/ZIP安装/市场客户端)+ blog-seo 插件(JSON-LD/OG/llms.txt/Markdown导出)+ 后台插件/主题管理页

This commit is contained in:
ak
2026-08-11 18:15:56 +08:00
parent dee0208f1d
commit f77c96d3aa
18 changed files with 994 additions and 10 deletions
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Filament\Pages;
use App\Blog\Services\PackageInstaller;
use App\Blog\Support\ThemeManager;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Livewire\WithFileUploads;
class Themes extends Page
{
use WithFileUploads;
protected static \UnitEnum|string|null $navigationGroup = '管理';
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-swatch';
protected static ?string $navigationLabel = '主题管理';
protected string $view = 'filament.pages.themes';
public $zip;
public function getThemesProperty(): array
{
return app(ThemeManager::class)->all();
}
public function activateTheme(string $name): void
{
try {
app(ThemeManager::class)->activate($name);
Notification::make()->title('已激活主题:'.$name)->success()->send();
} catch (\Throwable $e) {
Notification::make()->title('激活失败')->body($e->getMessage())->danger()->send();
}
}
public function uploadThemeZip(): void
{
$this->validate([
'zip' => ['required', 'file', 'mimes:zip'],
]);
try {
$result = app(PackageInstaller::class)->installZip($this->zip->getRealPath());
Notification::make()->title('主题安装成功:'.$result['key'])->success()->send();
} catch (\Throwable $e) {
Notification::make()->title('安装失败')->body($e->getMessage())->danger()->send();
}
$this->zip = null;
}
public function uninstallTheme(string $name): void
{
try {
app(PackageInstaller::class)->uninstallTheme($name);
Notification::make()->title('已删除主题:'.$name)->success()->send();
} catch (\Throwable $e) {
Notification::make()->title('删除失败')->body($e->getMessage())->danger()->send();
}
}
}