web.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use App\Services\ThemeService;
  3. use Illuminate\Http\Request;
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Web Routes
  7. |--------------------------------------------------------------------------
  8. |
  9. | Here is where you can register web routes for your application. These
  10. | routes are loaded by the RouteServiceProvider within a group which
  11. | contains the "web" middleware group. Now create something great!
  12. |
  13. */
  14. Route::get('/', function (Request $request) {
  15. if (config('v2board.app_url') && config('v2board.safe_mode_enable', 0)) {
  16. if ($request->server('HTTP_HOST') !== parse_url(config('v2board.app_url'))['host']) {
  17. abort(403);
  18. }
  19. }
  20. $renderParams = [
  21. 'title' => config('v2board.app_name', 'V2Board'),
  22. 'theme' => config('v2board.frontend_theme', 'v2board'),
  23. 'theme_path' => '/theme/' . config('v2board.frontend_theme', 'v2board') . '/assets/',
  24. 'version' => config('app.version'),
  25. 'description' => config('v2board.app_description', 'V2Board is best'),
  26. 'logo' => config('v2board.logo')
  27. ];
  28. if (!config("theme.{$renderParams['theme']}")) {
  29. $themeService = new ThemeService($renderParams['theme']);
  30. $themeService->init();
  31. }
  32. $renderParams['theme_config'] = config('theme.' . config('v2board.frontend_theme', 'v2board'));
  33. return view('theme::' . config('v2board.frontend_theme', 'v2board') . '.dashboard', $renderParams);
  34. });
  35. Route::get('/' . config('v2board.frontend_admin_path', 'admin'), function () {
  36. return view('admin', [
  37. 'title' => config('v2board.app_name', 'V2Board'),
  38. 'theme_sidebar' => config('v2board.frontend_theme_sidebar', 'light'),
  39. 'theme_header' => config('v2board.frontend_theme_header', 'dark'),
  40. 'theme_color' => config('v2board.frontend_theme_color', 'default'),
  41. 'background_url' => config('v2board.frontend_background_url'),
  42. 'version' => config('app.version'),
  43. 'logo' => config('v2board.logo')
  44. ]);
  45. });