route.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. //获取客服数据
  28. Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
  29. Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
  30. })->middleware(AllowOriginMiddleware::class);
  31. /**
  32. * miss 路由
  33. */
  34. Route::miss(function () {
  35. if (app()->request->isOptions()) {
  36. $header = Config::get('cookie.header');
  37. $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
  38. return Response::create('ok')->code(200)->header($header);
  39. } else
  40. return Response::create()->code(404);
  41. });