route.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. use think\facade\Route;
  12. use think\facade\Config;
  13. use think\Response;
  14. use app\http\middleware\AllowOriginMiddleware;
  15. /**
  16. * 无需授权的接口
  17. */
  18. Route::group(function () {
  19. //用户名密码登录
  20. Route::post('login', 'Login/login')->name('AdminLogin')->option(['real_name' => '下载表备份记录']);
  21. //后台登录页面数据
  22. Route::get('login/info', 'Login/info')->option(['real_name' => '登录信息']);
  23. //下载文件
  24. Route::get('download', 'PublicController/download')->option(['real_name' => '下载文件']);
  25. //验证码
  26. Route::get('captcha_pro', 'Login/captcha')->name('')->option(['real_name' => '获取验证码']);
  27. Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
  28. })->middleware(AllowOriginMiddleware::class);
  29. /**
  30. * miss 路由
  31. */
  32. Route::miss(function () {
  33. if (app()->request->isOptions()) {
  34. $header = Config::get('cookie.header');
  35. $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
  36. return Response::create('ok')->code(200)->header($header);
  37. } else
  38. return Response::create()->code(404);
  39. });