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
@@ -0,0 +1,66 @@
<x-filament-panels::page>
<x-filament::section heading="插件列表">
<div class="space-y-4">
@forelse($this->plugins as $plugin)
<div class="flex items-center justify-between gap-4 rounded-xl border border-gray-200 p-4 dark:border-white/10">
<div>
<div class="flex items-center gap-2">
<span class="font-semibold">{{ $plugin['title'] }}</span>
<span class="text-xs text-gray-500">{{ $plugin['version'] }}</span>
@if($plugin['enabled'])
<x-filament::badge color="success">已启用</x-filament::badge>
@else
<x-filament::badge color="gray">已停用</x-filament::badge>
@endif
</div>
<p class="mt-1 text-sm text-gray-500">{{ $plugin['description'] }}</p>
<p class="mt-0.5 text-xs text-gray-400">{{ $plugin['vendor'] }}.{{ $plugin['name'] }}</p>
</div>
<div class="flex shrink-0 gap-2">
@if($plugin['enabled'])
<x-filament::button size="sm" color="gray" wire:click="disablePlugin('{{ $plugin['key'] }}')">停用</x-filament::button>
@else
<x-filament::button size="sm" color="success" wire:click="enablePlugin('{{ $plugin['key'] }}')">启用</x-filament::button>
@endif
@if(! in_array($plugin['key'], config('plugins.enabled', []), true))
<x-filament::button size="sm" color="danger" wire:click="uninstallPlugin('{{ $plugin['key'] }}')" wire:confirm="确定卸载该插件?">卸载</x-filament::button>
@endif
</div>
</div>
@empty
<p class="text-sm text-gray-500">暂无插件</p>
@endforelse
</div>
</x-filament::section>
<x-filament::section heading="安装插件(ZIP">
<form wire:submit="uploadZip" class="flex items-end gap-3">
<div class="flex-1">
<x-filament::input.wrapper>
<x-filament::input type="file" wire:model="zip" accept=".zip" />
</x-filament::input.wrapper>
@error('zip') <p class="mt-1 text-sm text-danger-600">{{ $message }}</p> @enderror
</div>
<x-filament::button type="submit" color="primary">安装</x-filament::button>
</form>
</x-filament::section>
<x-filament::section heading="插件市场" :description="config('market.url') ?: '未配置远程市场(config/market.php 的 MARKET_URL),仅支持本地 ZIP 安装'">
<div class="space-y-3">
<x-filament::button color="gray" wire:click="loadMarket">刷新市场</x-filament::button>
@forelse($marketItems as $index => $item)
<div class="flex items-center justify-between gap-4 rounded-xl border border-gray-200 p-4 dark:border-white/10">
<div>
<div class="font-semibold">{{ $item['title'] ?? $item['name'] }}</div>
<p class="text-sm text-gray-500">{{ $item['description'] ?? '' }}</p>
<p class="text-xs text-gray-400">{{ $item['version'] ?? '' }} · {{ $item['author'] ?? '' }}</p>
</div>
<x-filament::button size="sm" color="primary" wire:click="installFromMarket({{ $index }})">安装</x-filament::button>
</div>
@empty
<p class="text-sm text-gray-500">点击「刷新市场」拉取可用插件/主题</p>
@endforelse
</div>
</x-filament::section>
</x-filament-panels::page>
@@ -0,0 +1,38 @@
<x-filament-panels::page>
<x-filament::section heading="主题列表">
<div class="grid gap-4 sm:grid-cols-2">
@forelse($this->themes as $theme)
<div class="rounded-xl border border-gray-200 p-5 dark:border-white/10">
<div class="flex items-center justify-between">
<span class="font-semibold text-lg">{{ $theme['title'] }}</span>
<span class="text-xs text-gray-500">v{{ $theme['version'] }}</span>
</div>
<p class="mt-1 text-sm text-gray-500">{{ $theme['description'] }}</p>
<p class="mt-0.5 text-xs text-gray-400">{{ $theme['author'] }}</p>
<div class="mt-3 flex gap-2">
@if($theme['active'])
<x-filament::badge color="success">当前使用</x-filament::badge>
@else
<x-filament::button size="sm" color="primary" wire:click="activateTheme('{{ $theme['name'] }}')">启用</x-filament::button>
<x-filament::button size="sm" color="danger" wire:click="uninstallTheme('{{ $theme['name'] }}')" wire:confirm="确定删除该主题?">删除</x-filament::button>
@endif
</div>
</div>
@empty
<p class="text-sm text-gray-500">暂无主题</p>
@endforelse
</div>
</x-filament::section>
<x-filament::section heading="安装主题(ZIP">
<form wire:submit="uploadThemeZip" class="flex items-end gap-3">
<div class="flex-1">
<x-filament::input.wrapper>
<x-filament::input type="file" wire:model="zip" accept=".zip" />
</x-filament::input.wrapper>
@error('zip') <p class="mt-1 text-sm text-danger-600">{{ $message }}</p> @enderror
</div>
<x-filament::button type="submit" color="primary">安装</x-filament::button>
</form>
</x-filament::section>
</x-filament-panels::page>