app.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. if (\app\model\CardModel::cardStatus($pluginsDirName)) {
  23. include_once $router;
  24. }
  25. break;
  26. }
  27. }
  28. }
  29. }
  30. Route::miss(function () {
  31. return view(app_path() . "view/cardNotFound.html")->code(200);
  32. });
  33. });
  34. Route::options("[:s]", function () {
  35. return response('', 200);
  36. });