route.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. return view(app()->getRootPath() . 'public' . DS . config('app.admin_prefix', 'admin') . DS . 'index.html');
  15. case 'home':
  16. if (request()->isMobile()) {
  17. return redirect(app()->route->buildUrl('/'));
  18. } else {
  19. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  20. }
  21. case 'pages':
  22. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  23. default:
  24. if (!request()->isMobile()) {
  25. if (is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('type')) {
  26. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  27. } else {
  28. if (request()->get('type')) {
  29. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  30. } else {
  31. return view(app()->getRootPath() . 'public' . DS . 'mobile.html', ['siteName' => sys_config('site_name'), 'siteUrl' => sys_config('site_url') . '/pages/index/index']);
  32. }
  33. }
  34. } else {
  35. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  36. }
  37. }
  38. });