fix: feat: add theme public files initialization check
Some checks are pending
Docker Build and Publish / build (push) Waiting to run

This commit is contained in:
xboard 2025-01-11 02:23:13 +08:00
parent 5de466fc3e
commit 635943e742
2 changed files with 12 additions and 1 deletions

View File

@ -271,7 +271,7 @@ class ThemeService
/**
* 获取主题路径
*/
private function getThemePath(string $theme): ?string
public function getThemePath(string $theme): ?string
{
$systemPath = base_path(self::SYSTEM_THEME_DIR . $theme);
if (File::exists($systemPath)) {

View File

@ -3,6 +3,7 @@
use App\Services\ThemeService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\File;
/*
|--------------------------------------------------------------------------
@ -42,6 +43,16 @@ Route::get('/', function (Request $request) {
throw new Exception('主题视图文件不存在');
}
// 检查主题是否已复制到public目录
$publicThemePath = public_path('theme/' . $theme);
if (!File::exists($publicThemePath)) {
$themePath = $themeService->getThemePath($theme);
if (!$themePath || !File::copyDirectory($themePath, $publicThemePath)) {
throw new Exception('主题初始化失败');
}
Log::info('Theme initialized in public directory', ['theme' => $theme]);
}
$renderParams = [
'title' => admin_setting('app_name', 'Xboard'),
'theme' => $theme,