web.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. 'version' => config('app.version'),
  24. 'description' => config('v2board.app_description', 'V2Board is best'),
  25. 'logo' => config('v2board.logo')
  26. ];
  27. if (!config("theme.{$renderParams['theme']}")) {
  28. $themeService = new ThemeService($renderParams['theme']);
  29. $themeService->init();
  30. }
  31. $renderParams['theme_config'] = config('theme.' . config('v2board.frontend_theme', 'v2board'));
  32. return view('theme::' . config('v2board.frontend_theme', 'v2board') . '.dashboard', $renderParams);
  33. });
  34. //TODO:: 兼容
  35. Route::get('/' . config('v2board.secure_path', config('v2board.frontend_admin_path', hash('crc32b', config('app.key')))), 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. 'secure_path' => config('v2board.secure_path', config('v2board.frontend_admin_path', hash('crc32b', config('app.key'))))
  45. ]);
  46. });