feat: new xboard

This commit is contained in:
xboard
2025-01-21 14:57:54 +08:00
parent de18cfe596
commit 0f43fff242
373 changed files with 17923 additions and 20264 deletions
+52 -13
View File
@@ -2,6 +2,9 @@
use App\Services\ThemeService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\File;
/*
|--------------------------------------------------------------------------
@@ -14,27 +17,59 @@ use Illuminate\Http\Request;
|
*/
Route::get('/', function (Request $request) {
if (admin_setting('app_url') && admin_setting('safe_mode_enable', 0)) {
if ($request->server('HTTP_HOST') !== parse_url(admin_setting('app_url'))['host']) {
abort(403);
}
}
$renderParams = [
'title' => admin_setting('app_name', 'Xboard'),
'theme' => admin_setting('frontend_theme', 'Xboard'),
'version' => config('app.version'),
'description' => admin_setting('app_description', 'Xboard is best'),
'logo' => admin_setting('logo')
];
if (!admin_setting("theme_{$renderParams['theme']}")) {
$themeService = new ThemeService($renderParams['theme']);
$themeService->init();
$theme = admin_setting('frontend_theme', 'Xboard');
$themeService = new ThemeService();
try {
// 检查主题是否存在,不存在则尝试切换到默认主题
if (!$themeService->exists($theme)) {
if ($theme !== 'Xboard') {
Log::warning('Theme not found, switching to default theme', ['theme' => $theme]);
$theme = 'Xboard';
admin_setting(['frontend_theme' => $theme]);
}
$themeService->switch($theme);
}
// 检查主题视图文件是否存在
if (!$themeService->getThemeViewPath($theme)) {
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,
'version' => config('app.version'),
'description' => admin_setting('app_description', 'Xboard is best'),
'logo' => admin_setting('logo'),
'theme_config' => $themeService->getConfig($theme)
];
return view('theme::' . $theme . '.dashboard', $renderParams);
} catch (Exception $e) {
Log::error('Theme rendering failed', [
'theme' => $theme,
'error' => $e->getMessage()
]);
abort(500, '主题加载失败');
}
$renderParams['theme_config'] = admin_setting("theme_". admin_setting('frontend_theme', 'Xboard')) ?? config('theme.' . admin_setting('frontend_theme', 'Xboard'));
return view('theme::' . admin_setting('frontend_theme', 'Xboard') . '.dashboard', $renderParams);
});
//TODO:: 兼容
@@ -50,3 +85,7 @@ Route::get('/' . admin_setting('secure_path', admin_setting('frontend_admin_path
'secure_path' => admin_setting('secure_path', admin_setting('frontend_admin_path', hash('crc32b', config('app.key'))))
]);
});
Route::get('/' . (admin_setting('subscribe_path', 's')) . '/{token}', [\App\Http\Controllers\V1\Client\ClientController::class, 'subscribe'])
->middleware('client')
->name('client.subscribe');