小更新
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\http\middleware;
|
||||
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
@@ -15,13 +16,23 @@ use think\facade\View;
|
||||
*/
|
||||
class Admin {
|
||||
|
||||
protected $data = [];
|
||||
protected $data = [];
|
||||
protected $outAuth = ['admin/index/login', 'admin/index/logout', 'admin/index/verify'];
|
||||
|
||||
public function handle($request, \Closure $next) {
|
||||
$user = Session::get('user');
|
||||
$request->url = str_replace(".", "/", strtolower($request->controller())) . '/' . $request->action();
|
||||
if (!Session::has('user') && !$user['uid'] && !in_array($request->url, $this->outAuth)) {
|
||||
return redirect('admin/index/login');
|
||||
}
|
||||
$request->isAdmin = 1;
|
||||
$request->user = $user;
|
||||
|
||||
$request->pageConfig = array(
|
||||
'list_rows' => $request->param('limit', 20),
|
||||
'page' => $request->param('page', 1)
|
||||
'list_rows' => $request->param('limit', 20),
|
||||
'page' => $request->param('page', 1),
|
||||
);
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
if (is_array($response->getData())) {
|
||||
@@ -36,9 +47,9 @@ class Admin {
|
||||
}
|
||||
return json($this->data);
|
||||
} else {
|
||||
if(\is_string($this->data) && $this->data != ''){
|
||||
if (\is_string($this->data) && $this->data != '') {
|
||||
return $response;
|
||||
}else{
|
||||
} else {
|
||||
return $response->data($this->fetch());
|
||||
}
|
||||
}
|
||||
@@ -51,11 +62,11 @@ class Admin {
|
||||
// 使用内置PHP模板引擎渲染模板输出
|
||||
$config = array(
|
||||
'tpl_replace_string' => array(
|
||||
'__static__' => '/static',
|
||||
'__img__' => '/static/admin/images',
|
||||
'__css__' => '/static/admin/css',
|
||||
'__js__' => '/static/admin/js',
|
||||
'__public__' => '/static/admin',
|
||||
'__static__' => '/static',
|
||||
'__img__' => '/static/admin/images',
|
||||
'__css__' => '/static/admin/css',
|
||||
'__js__' => '/static/admin/js',
|
||||
'__public__' => '/static/admin',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user