重新初始化

This commit is contained in:
2020-02-17 20:47:06 +08:00
parent 5c320206fb
commit 58d999ed73
4016 changed files with 1271 additions and 302396 deletions

View File

@@ -9,73 +9,22 @@
namespace app\http\middleware;
use think\facade\Session;
use think\facade\View;
/**
* @title 后台中间件
*/
class Admin {
protected $data = [];
protected $outAuth = ['admin/index/login', 'admin/index/logout', 'admin/index/verify'];
public function handle($request, \Closure $next) {
$user = Session::get('user');
$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),
'page' => $request->param('page', 1),
);
$response = $next($request);
if (is_array($response->getData())) {
$this->data = array_merge($this->data, $response->getData());
} else {
$this->data = $response->getData();
}
if ($request->isAjax()) {
if (isset($this->data['config'])) {
unset($this->data['config']);
}
return json($this->data);
} else {
if (\is_string($this->data) && $this->data != '') {
return $response;
} else {
return $response->data($this->fetch());
}
}
}
/**
* @title 显示类
*/
protected function fetch($template = '') {
// 使用内置PHP模板引擎渲染模板输出
$config = array(
'tpl_replace_string' => array(
'__static__' => '/static',
'__img__' => '/static/admin/images',
'__css__' => '/static/admin/css',
'__js__' => '/static/admin/js',
'__public__' => '/static/admin',
),
);
$template = (isset($this->data['template']) && $this->data['template']) ? $this->data['template'] : $template;
View::config($config);
View::assign('sent_version', sent_version);
View::assign('config', (isset($this->data['config']) ? $this->data['config'] : []));
View::assign((isset($this->data['data']) ? $this->data['data'] : []));
return View::fetch($template);
return $response;
}
}

View File

@@ -1,36 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\middleware;
use think\facade\Session;
use think\facade\View;
/**
* @title 后台中间件
*/
class AdminAuth {
public function handle($request, \Closure $next) {
$user = Session::get('user');
if (Session::has('user') && $user['uid']) {
$request->user = $user;
if ($user['uid'] == 1) {
$request->isAdmin = true;
}
$current_url = '/' . str_replace('.', '/', strtolower($request->controller())) . '/' . strtolower($request->action());
$meta_title = $current_url;
View::assign('meta_title', $meta_title);
return $next($request);
} else {
return redirect(url('admin.index/login'))->remember();
}
}
}

View File

@@ -1,52 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\middleware;
use think\facade\View;
/**
* @title 后台中间件
*/
class Front {
protected $data = [];
public function handle($request, \Closure $next) {
$response = $next($request);
$this->data = $response->getData();
if ($request->isAjax()) {
return json($this->data);
}else{
return $response->data($this->fetch());
}
}
/**
* @title 显示类
*/
protected function fetch($template = ''){
// 使用内置PHP模板引擎渲染模板输出
$config = array(
'tpl_replace_string' => array(
'__static__' => '/static',
'__img__' => '/static/front/images',
'__css__' => '/static/front/css',
'__js__' => '/static/front/js',
'__public__' => '/static/front',
)
);
if (is_string($this->data)) {
$this->data = array('data' => $this->data);
}
View::config($config);
View::assign($this->data);
return View::engine('Think')->fetch($template);
}
}

View File

@@ -1,32 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\validate\admin;
use think\Validate;
class Client extends Validate {
protected $rule = [
'title' => 'require|unique:client',
'appid' => 'require|unique:client',
'appsecret' => 'require',
];
protected $message = [
'title.require' => '客户端标题不能为空!',
'appid.require' => 'APPID不能为空',
'appsecret.require' => '秘钥不能为空!',
];
protected $scene = [
'add' => ['title', 'appid', 'appsecret'],
'edit' => ['title', 'appid', 'appsecret'],
];
}

View File

@@ -1,29 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\validate\admin;
use think\Validate;
class Index extends Validate {
protected $rule = [
'username' => 'require',
'password' => 'require',
];
protected $message = [];
/**
* @title 登录验证
*/
public function sceneLogin() {
return $this->only(['username','password']);
}
}