M7: 全量测试(25 用例)+ README + 部署文档(nginx/systemd/cron)+ theme:publish 命令
This commit is contained in:
@@ -69,6 +69,30 @@ class ThemeManager
|
||||
}
|
||||
|
||||
Setting::set('active_theme', $theme);
|
||||
$this->prependViews();
|
||||
}
|
||||
|
||||
/**
|
||||
* 把激活主题的 views 目录前置到全局视图路径。
|
||||
* 在 Provider boot 与运行时切换主题时调用。
|
||||
*/
|
||||
public function prependViews(): void
|
||||
{
|
||||
// 迁移尚未执行(migrate:fresh 首轮)时跳过 DB 查询,使用默认主题
|
||||
$active = \Illuminate\Support\Facades\Schema::hasTable('settings')
|
||||
? $this->active()
|
||||
: config('themes.default');
|
||||
|
||||
$views = $this->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