app.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use think\facade\Route;
  3. Route::any('/manager', 'index/index');
  4. Route::any('/noteApp', "index/index");
  5. Route::any("/", 'index/index');
  6. Route::any("/favicon", "index/favicon");
  7. Route::get("/plugins/:dir/static/[:file]", "\PluginStaticSystem@index")->pattern(['dir' => '\w+', 'file' => '[\w||\s\-].*']);//插件静态资源路由文件
  8. Route::group("/plugins", function () {
  9. $pluginsDir = root_path() . "plugins/";
  10. if (is_dir($pluginsDir)) {
  11. $url = request()->baseUrl();
  12. $urlArr = explode('/', $url);
  13. $pluginsDirName = '';
  14. if (isset($urlArr[2])) {
  15. $pluginsDirName = $urlArr[2];
  16. }
  17. foreach (scandir($pluginsDir) as $item) {
  18. if (mb_strtolower($item) == mb_strtolower($pluginsDirName)) {
  19. $router = $pluginsDir . $item . '/route.php';
  20. if (file_exists($router)) {
  21. $_ENV['plugins_dir_name'] = $pluginsDir . $item;
  22. include_once $router;
  23. break;
  24. }
  25. }
  26. }
  27. }
  28. Route::miss(function () {
  29. return view(app_path() . "view/cardNotFound.html")->code(200);
  30. });
  31. });
  32. Route::options("[:s]", function () {
  33. return response('', 200);
  34. });