web.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use Illuminate\Http\Request;
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Web Routes
  6. |--------------------------------------------------------------------------
  7. |
  8. | Here is where you can register web routes for your application. These
  9. | routes are loaded by the RouteServiceProvider within a group which
  10. | contains the "web" middleware group. Now create something great!
  11. |
  12. */
  13. Route::get('/', function (Request $request) {
  14. try {
  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. ];
  27. $renderParams['theme_config'] = config('theme.' . config('v2board.frontend_theme', 'v2board'));
  28. return view('theme::' . config('v2board.frontend_theme', 'v2board') . '.dashboard', $renderParams);
  29. } catch (\Illuminate\Foundation\Bootstrap\HandleExceptions $e) {
  30. abort(500, '主题初始化发生错误,请在后台对主题检查或配置后重试。');
  31. }
  32. });
  33. Route::get('/' . config('v2board.frontend_admin_path', 'admin'), function () {
  34. return view('admin', [
  35. 'title' => config('v2board.app_name', 'V2Board'),
  36. 'theme_sidebar' => config('v2board.frontend_theme_sidebar', 'light'),
  37. 'theme_header' => config('v2board.frontend_theme_header', 'dark'),
  38. 'theme_color' => config('v2board.frontend_theme_color', 'default'),
  39. 'backgroun_url' => config('v2board.frontend_background_url'),
  40. 'verison' => config('app.version')
  41. ]);
  42. });