route.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use think\facade\Route;
  3. Route::miss(function () {
  4. $appRequest = request()->pathinfo();
  5. if ($appRequest === null) {
  6. $appName = '';
  7. } else {
  8. $appRequest = str_replace('//', '/', $appRequest);
  9. $appName = explode('/', $appRequest)[0] ?? '';
  10. }
  11. switch (strtolower($appName)) {
  12. case config('app.admin_prefix', 'admin'):
  13. case 'kefu':
  14. case 'app':
  15. return view(app()->getRootPath() . 'public' . DS . config('app.admin_prefix', 'admin') . DS . 'index.html');
  16. case 'home':
  17. if (request()->isMobile()) {
  18. return redirect(app()->route->buildUrl('/'));
  19. } else {
  20. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  21. }
  22. case 'pages':
  23. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  24. default:
  25. if (!request()->isMobile()) {
  26. if (is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('mdType')) {
  27. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  28. } else {
  29. if (request()->get('type')) {
  30. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  31. } else {
  32. return view(app()->getRootPath() . 'public' . DS . 'mobile.html', ['siteName' => sys_config('site_name'), 'siteUrl' => sys_config('site_url') . '/pages/index/index']);
  33. }
  34. }
  35. } else {
  36. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  37. }
  38. }
  39. });