M7: 全量测试(25 用例)+ README + 部署文档(nginx/systemd/cron)+ theme:publish 命令
This commit is contained in:
@@ -18,7 +18,7 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
// 激活主题的 views 目录前置到全局视图路径,实现主题覆盖 + 默认兜底
|
||||
$this->prependActiveThemeViews();
|
||||
app(ThemeManager::class)->prependViews();
|
||||
|
||||
// 侧边栏数据共享:所有前台视图自动获得 $categories/$recentPosts/$hotTags/$links 等
|
||||
View::composer(
|
||||
@@ -26,25 +26,4 @@ class ThemeServiceProvider extends ServiceProvider
|
||||
SidebarComposer::class
|
||||
);
|
||||
}
|
||||
|
||||
private function prependActiveThemeViews(): void
|
||||
{
|
||||
$manager = app(ThemeManager::class);
|
||||
|
||||
// 迁移尚未执行(如 migrate:fresh 首轮)时跳过 DB 查询,使用默认主题
|
||||
$active = \Illuminate\Support\Facades\Schema::hasTable('settings')
|
||||
? $manager->active()
|
||||
: config('themes.default');
|
||||
|
||||
$views = $manager->path($active).'/views';
|
||||
|
||||
if (! is_dir($views)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$paths = config('view.paths');
|
||||
array_unshift($paths, $views);
|
||||
config(['view.paths' => $paths]);
|
||||
app('view')->getFinder()->setPaths($paths);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user