feat: topbar legacy-sync button, card view mode with cover fallback, year/month/day archives, richer page cache admin, stylevar repeater editor
- topbar: Livewire LegacySyncButton next to 写文章 (moved from user menu) - view modes: add 图文(card) grid with cover fallback chain (cover → attachment → first content image → placeholder); list mode now title-only compact - archives: year/month/day index grid - page cache admin: size + expiry columns, total size, cache policy note - theme inject: stylevars switch from KeyValue to Repeater with multi-line HTML editing - import: html_entity_decode for category/post-title/link/keywords/comment author
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Blog\Support\PageCacheMiddleware;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* 顶栏「同步旧站」按钮:点击后对 sablog 老库做增量导入(幂等,不产生重复)。
|
||||
*/
|
||||
class LegacySyncButton extends Component
|
||||
{
|
||||
public bool $running = false;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$this->running = true;
|
||||
|
||||
$src = config('blog.sablog_source');
|
||||
|
||||
try {
|
||||
Artisan::call('sablog:import', [
|
||||
'--host' => $src['host'],
|
||||
'--port' => $src['port'],
|
||||
'--database' => $src['database'],
|
||||
'--username' => $src['username'],
|
||||
'--password' => $src['password'],
|
||||
'--prefix' => $src['prefix'],
|
||||
]);
|
||||
$output = trim(Artisan::output());
|
||||
|
||||
PageCacheMiddleware::flush();
|
||||
|
||||
Notification::make()
|
||||
->title('旧站数据同步完成')
|
||||
->body(Str::afterLast($output, '报告:') ?: $output)
|
||||
->success()
|
||||
->persistent()
|
||||
->send();
|
||||
} catch (\Throwable $e) {
|
||||
Notification::make()
|
||||
->title('同步失败')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
|
||||
$this->running = false;
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('livewire.legacy-sync-button');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user