You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

1 year ago
1 year ago
1 year ago
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\middleware;
  4. use think\facade\Db;
  5. use think\facade\Config;
  6. use think\facade\View;
  7. class LoadConfig
  8. {
  9. /**
  10. * 处理请求
  11. *
  12. * @param \think\Request $request
  13. * @param \Closure $next
  14. * @return Response
  15. */
  16. public function handle($request, \Closure $next)
  17. {
  18. if (!file_exists(app()->getRootPath().'.env')){
  19. if(strpos(request()->url(),'/installapp')===false){
  20. return redirect((string)url('/installapp'))->header([
  21. 'Cache-Control' => 'no-store, no-cache, must-revalidate',
  22. 'Pragma' => 'no-cache',
  23. ]);
  24. }else{
  25. return $next($request);
  26. }
  27. }
  28. $res = Db::name('config')->cache('configs',0)->column('value','key');
  29. Config::set($res, 'sys');
  30. View::assign('cdnpublic', '//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/');
  31. return $next($request)->header([
  32. 'Cache-Control' => 'no-store, no-cache, must-revalidate',
  33. 'Pragma' => 'no-cache',
  34. ]);
  35. }
  36. }