route.php 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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 . 'system.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() && is_dir(app()->getRootPath() . 'public' . DS . 'home') && !request()->get('type')) {
  25. return view(app()->getRootPath() . 'public' . DS . 'home' . DS . 'index.html');
  26. } else {
  27. return view(app()->getRootPath() . 'public' . DS . 'index.html');
  28. }
  29. }
  30. });