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:
@@ -8,7 +8,6 @@ use App\Blog\Support\ThemeInjector;
|
||||
use App\Blog\Support\ThemeManager;
|
||||
use App\Models\Setting;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -38,9 +37,15 @@ class ThemeInject extends Page
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$vars = app(ThemeManager::class)->variables();
|
||||
$varRows = [];
|
||||
foreach ($vars as $key => $value) {
|
||||
$varRows[] = ['key' => (string) $key, 'value' => (string) $value];
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'inject' => $this->normalizeBlocks(Setting::get('inject.blocks', [])),
|
||||
'theme_vars' => app(ThemeManager::class)->variables(),
|
||||
'theme_vars' => $varRows,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -80,11 +85,23 @@ class ThemeInject extends Page
|
||||
|
||||
$tabs[] = Tab::make('主题变量(stylevar)')
|
||||
->schema([
|
||||
KeyValue::make('theme_vars')
|
||||
Repeater::make('theme_vars')
|
||||
->label('当前主题变量:视图用 {{ theme(\'var\', \'key\') }} 引用')
|
||||
->keyLabel('变量名')
|
||||
->valueLabel('内容(HTML)')
|
||||
->schema([
|
||||
TextInput::make('key')
|
||||
->label('变量名')
|
||||
->required(),
|
||||
Textarea::make('value')
|
||||
->label('内容(HTML)')
|
||||
->rows(4),
|
||||
])
|
||||
->columns(1)
|
||||
->defaultItems(0)
|
||||
->collapsible()
|
||||
->itemLabel(fn (array $state): ?string => $state['key'] ?? null)
|
||||
->reorderable()
|
||||
->reorderableWithButtons()
|
||||
->addActionLabel('添加变量')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -118,7 +135,16 @@ class ThemeInject extends Page
|
||||
}
|
||||
|
||||
Setting::set('inject.blocks', $blocks);
|
||||
Setting::set('theme_vars_'.app(ThemeManager::class)->active(), $data['theme_vars'] ?? []);
|
||||
|
||||
$vars = [];
|
||||
foreach ($data['theme_vars'] ?? [] as $row) {
|
||||
$key = trim((string) ($row['key'] ?? ''));
|
||||
if ($key === '') {
|
||||
continue;
|
||||
}
|
||||
$vars[$key] = (string) ($row['value'] ?? '');
|
||||
}
|
||||
Setting::set('theme_vars_'.app(ThemeManager::class)->active(), $vars);
|
||||
\App\Blog\Support\PageCacheMiddleware::flush();
|
||||
|
||||
Notification::make()->title('注入内容已保存')->success()->send();
|
||||
|
||||
Reference in New Issue
Block a user