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.

39 lines
1023 B

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. class LoadConfig
  7. {
  8. /**
  9. * 处理请求
  10. *
  11. * @param \think\Request $request
  12. * @param \Closure $next
  13. * @return Response
  14. */
  15. public function handle($request, \Closure $next)
  16. {
  17. if (!file_exists(app()->getRootPath().'.env')){
  18. if(strpos(request()->url(),'/installapp')===false){
  19. return redirect((string)url('/installapp'))->header([
  20. 'Cache-Control' => 'no-store, no-cache, must-revalidate',
  21. 'Pragma' => 'no-cache',
  22. ]);
  23. }else{
  24. return $next($request);
  25. }
  26. }
  27. $res = Db::name('config')->cache('configs',0)->column('value','key');
  28. Config::set($res, 'sys');
  29. return $next($request)->header([
  30. 'Cache-Control' => 'no-store, no-cache, must-revalidate',
  31. 'Pragma' => 'no-cache',
  32. ]);
  33. }
  34. }