admin app bind
This commit is contained in:
parent
5873cebcfd
commit
d126d0fc38
@ -198,9 +198,13 @@ class Admin extends AdminController
|
||||
|
||||
//清除缓存Cache
|
||||
public function clearCache(){
|
||||
$atemp = app()->getRootPath().'runtime/admin/temp/';
|
||||
$itemp = app()->getRootPath().'runtime/index/temp/';
|
||||
$cache = app()->getRootPath().'runtime/cache/';
|
||||
//$atemp = app()->getRootPath().'runtime/admin/temp/';
|
||||
//$itemp = app()->getRootPath().'runtime/index/temp/';
|
||||
//$cache = app()->getRootPath().'runtime/cache/';
|
||||
|
||||
$atemp = str_replace('\\',"/",app()->getRootPath().'runtime/admin/temp/');
|
||||
$itemp = str_replace('\\',"/",app()->getRootPath().'runtime/index/temp/');
|
||||
$cache = str_replace('\\',"/",app()->getRootPath().'runtime/cache/');
|
||||
Files::delDirAndFile($atemp);
|
||||
Files::delDirAndFile($itemp);
|
||||
if(is_dir($cache) && Files::delDirAndFile($cache)){
|
||||
@ -209,4 +213,13 @@ class Admin extends AdminController
|
||||
return json(['code'=>-1,'msg'=>'清除缓存失败']);
|
||||
}
|
||||
}
|
||||
|
||||
//退出登陆
|
||||
public function logout()
|
||||
{
|
||||
Session::clear();
|
||||
$res = ['code'=>0,'msg'=>'退出成功' ];
|
||||
|
||||
return json($res);
|
||||
}
|
||||
}
|
@ -157,16 +157,6 @@ class User extends AdminController
|
||||
return json($res);
|
||||
}
|
||||
|
||||
|
||||
//退出登陆
|
||||
public function logout()
|
||||
{
|
||||
Session::clear();
|
||||
$res = ['code'=>0,'msg'=>'退出成功' ];
|
||||
|
||||
return json($res);
|
||||
}
|
||||
|
||||
//过滤数组中为空和null的值
|
||||
public function filtrArr($arr)
|
||||
{
|
||||
|
@ -17,36 +17,34 @@ class Auth
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
//halt($request->pathinfo());
|
||||
$response = $next($request);
|
||||
//后置中间件获取应用控制器方法
|
||||
$app = app('http')->getName();
|
||||
$controller = $request->controller();
|
||||
$action = $request->action();
|
||||
|
||||
if($request->controller() !== 'Login' && $request->action() !=='logout')
|
||||
{
|
||||
//登陆检验
|
||||
if (!Session::has('admin_id')) {
|
||||
return redirect((string) url('admin/login/index'));
|
||||
}
|
||||
$app = app('http')->getName();
|
||||
$controller = $request->controller();
|
||||
$action = $request->action();
|
||||
|
||||
//登陆后检验权限
|
||||
if (Session::has('admin_id')) {
|
||||
// 排除权限
|
||||
$not_check = ['admin/Index/index','admin/Index/home','admin/Set/info','admin/Set/password','admin/User/logout'];
|
||||
|
||||
if (!in_array($app . '/' . $controller . '/' . $action, $not_check)) {
|
||||
$auth = new UserAuth();
|
||||
$admin_id = Session::get('admin_id');
|
||||
$admin_id = Session::get('admin_id'); //登录用户的id
|
||||
|
||||
if (!$auth->check($app . '/' . $controller . '/' . $action, $admin_id) && $admin_id != 1) {
|
||||
//return response('<script>alert("没有权限");location.back()</script>');
|
||||
//return response('没有权限');
|
||||
return json(['code'=>-1,'msg'=>'没有权限!']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
//排除登录页和验证码被重定向
|
||||
if($controller !== 'Login' && !stristr($request->pathinfo(),"captcha.html") && $action !== 'logout')
|
||||
{
|
||||
//非登录重定向
|
||||
return redirect((string) url('admin/login/index'));
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ layui.define('view', function(exports){
|
||||
});
|
||||
admin.req({
|
||||
type: "post"
|
||||
,url: '/admin/Admin/clearCache'
|
||||
,url: adminClearCache
|
||||
,success: function(data){
|
||||
if (data.code == 0) {
|
||||
layer.close(loading);
|
||||
|
@ -24,7 +24,7 @@ layui.define(function(exports){
|
||||
admin.events.logout = function(){
|
||||
//执行退出接口
|
||||
admin.req({
|
||||
url: '/admin/user/logout'
|
||||
url: AdminLogout
|
||||
,type: 'get'
|
||||
,data: {}
|
||||
,done: function(res){ //这里要说明一下:done 是只有 response 的 code 正常才会执行。而 succese 则是只要 http 为 200 就会执行
|
||||
@ -36,10 +36,8 @@ layui.define(function(exports){
|
||||
icon:1,
|
||||
time:2000
|
||||
}, function(){
|
||||
location.href = '/admin/login/index';
|
||||
location.href = AdminLogin;
|
||||
});
|
||||
|
||||
//location.href = '/admin/login/index';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -191,7 +191,7 @@ layui.define(function(exports){
|
||||
//本周发贴
|
||||
table.render({
|
||||
elem: '#LAY-index-topSearch'
|
||||
,url: '/admin/index/forums' //模拟接口
|
||||
,url: indexForums //发贴接口
|
||||
,page: true
|
||||
,cellMinWidth: 120
|
||||
,cols: [[
|
||||
@ -207,7 +207,7 @@ layui.define(function(exports){
|
||||
//本周评论
|
||||
table.render({
|
||||
elem: '#LAY-index-topCard'
|
||||
,url: '/admin/index/replys' //模拟接口
|
||||
,url: indexReplys //评论接口
|
||||
,page: true
|
||||
,cellMinWidth: 120
|
||||
,cols: [[
|
||||
|
@ -79,7 +79,7 @@ layui.define(['table', 'form'], function(exports){
|
||||
//分类管理
|
||||
table.render({
|
||||
elem: '#LAY-app-content-tags'
|
||||
,url: '/admin/Forum/tags' //模拟接口
|
||||
,url: '/Forum/tags' //模拟接口
|
||||
,cols: [[
|
||||
{type: 'numbers', fixed: 'left'}
|
||||
,{field: 'sort', title: '排序', width: 80, sort: true}
|
||||
|
@ -57,7 +57,7 @@ layui.define('form', function(exports){
|
||||
//更换图形验证码
|
||||
$body.on('click', '#LAY-user-get-vercode', function(){
|
||||
var othis = $(this);
|
||||
this.src = '/captcha?t='+ new Date().getTime()
|
||||
this.src = '/captcha.html?t='+ new Date().getTime()
|
||||
});
|
||||
|
||||
//对外暴露的接口
|
||||
|
@ -95,6 +95,9 @@
|
||||
|
||||
{block name="js"}
|
||||
<script>
|
||||
var forumList = "{:url('Forum/list')}",
|
||||
forumListdel = "{:url('Forum/listdel')}",
|
||||
forumListform = "{:url('Forum/listform')}";
|
||||
layui.config({
|
||||
base: '/static/admin/' //静态资源所在路径
|
||||
}).extend({
|
||||
@ -103,7 +106,7 @@
|
||||
var $ = layui.$
|
||||
,form = layui.form
|
||||
,table = layui.table;
|
||||
|
||||
|
||||
//监听搜索
|
||||
form.on('submit(LAY-app-forumlist-search)', function(data){
|
||||
var field = data.field;
|
||||
|
@ -14,49 +14,49 @@
|
||||
<div carousel-item>
|
||||
<ul class="layui-row layui-col-space10">
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/forum/list')}">
|
||||
<a lay-href="{:url('Forum/list')}">
|
||||
<i class="layui-icon layui-icon-list"></i>
|
||||
<cite>帖子</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/forum/replys')}">
|
||||
<a lay-href="{:url('Forum/replys')}">
|
||||
<i class="layui-icon layui-icon-survey"></i>
|
||||
<cite>评论</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/forum/tags')}">
|
||||
<a lay-href="{:url('Forum/tags')}">
|
||||
<i class="layui-icon layui-icon-template-1"></i>
|
||||
<cite>分类</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/Admin/repass')}">
|
||||
<a lay-href="{:url('Admin/repass')}">
|
||||
<i class="layui-icon layui-icon-password"></i>
|
||||
<cite>密码</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/slider/index')}">
|
||||
<a lay-href="{:url('Slider/index')}">
|
||||
<i class="layui-icon layui-icon-dollar"></i>
|
||||
<cite>广告</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/Admin/info')}">
|
||||
<a lay-href="{:url('Admin/info')}">
|
||||
<i class="layui-icon layui-icon-form"></i>
|
||||
<cite>资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/User/list')}">
|
||||
<a lay-href="{:url('User/list')}">
|
||||
<i class="layui-icon layui-icon-user"></i>
|
||||
<cite>用户</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/set/website')}">
|
||||
<a lay-href="{:url('Set/website')}">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>设置</cite>
|
||||
</a>
|
||||
@ -287,5 +287,7 @@
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'console']);
|
||||
var indexForums = "{:url('Index/forums')}",
|
||||
indexReplys = "{:url('Index/replys')}";
|
||||
</script>
|
||||
{/block}
|
@ -14,6 +14,13 @@
|
||||
{block name="body"}内容{/block}
|
||||
<script src="/static/layui/jquery.min.js" charset="utf-8"></script>
|
||||
<script src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var AdminLogin = "{:url('Login/index')}",
|
||||
AdminLogout = "{:url('Admin/logout')}",
|
||||
adminClearCache = "{:url('Admin/clearCache')}";
|
||||
//var c = "{:config('app.domain_bind.www')}";
|
||||
//console.log(c);
|
||||
</script>
|
||||
{block name="js"}js文件{/block}
|
||||
</body>
|
||||
</html>
|
@ -55,8 +55,8 @@
|
||||
<cite>{:session('admin_name')}</cite>
|
||||
</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a lay-href="{:url('admin/admin/info')}">基本资料</a></dd>
|
||||
<dd><a lay-href="{:url('admin/admin/repass')}">修改密码</a></dd>
|
||||
<dd><a lay-href="{:url('Admin/info')}">基本资料</a></dd>
|
||||
<dd><a lay-href="{:url('Admin/repass')}">修改密码</a></dd>
|
||||
<hr>
|
||||
<dd layadmin-event="logout" style="text-align: center;"><a>退出</a></dd>
|
||||
</dl>
|
||||
|
@ -25,7 +25,7 @@
|
||||
</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd>
|
||||
<a lay-href="{:url('admin/user/list')}">网站用户</a>
|
||||
<a lay-href="{:url('User/list')}">网站用户1</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a lay-href="{:url('admin/admin/adminList')}">后台管理员</a>
|
||||
|
Loading…
Reference in New Issue
Block a user