app.php 1.4 KB

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