Skip to content

Commit

Permalink
改进
Browse files Browse the repository at this point in the history
1、修改菜单错误
2、增加站点版权信息配置
3、完善锁屏
  • Loading branch information
yuan-dian committed Sep 9, 2018
1 parent e153995 commit bd394a1
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 65 deletions.
22 changes: 22 additions & 0 deletions application/admin/controller/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,26 @@ public function editPassword()
return $this->fetch();
}
}

/**
* 解锁
*/
public function unlock()
{
$this->request->isPost();
if(!$this->request->isPost()){
$this->error('非法请求');
}
$uid=get_user_id();
if(!$uid){
$this->error('登录信息过期',url('/admin/login'));
}
$password=input('password','','trim');
$psd=model('user')->where('uid','=',get_user_id())->value('password');
if(password_verify($password,$psd)){
$this->success('解锁成功');
}else{
$this->error('密码错误');
}
}
}
4 changes: 3 additions & 1 deletion application/admin/controller/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,13 @@ public function siteConfig()
}else{
$title=input('title','tpswoole','trim');
$name=input('name','tpswoole','trim');
$copyright=input('copyright','copyright @2018 原点','trim');
if(!$title || !$name)$this->error('参数错误');
$save=[
'value'=>[
'title'=>$title,
'name'=>$name
'name'=>$name,
'copyright'=>$copyright
],
'update_time'=>time()
];
Expand Down
64 changes: 63 additions & 1 deletion application/admin/view/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</div>
<!-- 底部 -->
<div class="layui-footer footer">
<p><span>copyright @2018</span></p>
<p><span>{$site_config.value.copyright}</span></p>
</div>
</div>

Expand All @@ -109,6 +109,68 @@
$(window).resize(function(){
$(".navBar").height($(window).height()-210);
})
//锁屏
function lockPage(){
layer.open({
title : false,
type : 1,
content : '<div class="admin-header-lock" id="lock-box">'+
'<div class="admin-header-lock-img"><img src="/images/face.jpg" class="userAvatar"/></div>'+
'<div class="admin-header-lock-name" id="lockUserName">{$Think.session.user_auth.name}</div>'+
'<div class="input_btn">'+
'<input type="password" class="admin-header-lock-input layui-input" autocomplete="off" placeholder="请输入密码解锁.." name="lockPwd" id="lockPwd" />'+
'<button class="layui-btn" id="unlock">解锁</button>'+
'</div>'+
'</div>',
closeBtn : 0,
shade : 0.9,
success : function(){
//判断是否设置过头像,如果设置过则修改顶部、左侧和个人资料中的头像,否则使用默认头像
if(window.sessionStorage.getItem('userFace') && $(".userAvatar").length > 0){
$(".userAvatar").attr("src",$(".userAvatar").attr("src").split("images/")[0] + "images/" + window.sessionStorage.getItem('userFace').split("images/")[1]);
}
}
})
$(".admin-header-lock-input").focus();
}
$(".lockcms").on("click",function(){
window.sessionStorage.setItem("lockcms",true);
lockPage();
})
// 判断是否显示锁屏
if(window.sessionStorage.getItem("lockcms") == "true"){
lockPage();
}
// 解锁
$("body").on("click","#unlock",function(){
var password=$(this).siblings(".admin-header-lock-input").val();
if(password == ''){
layer.msg("请输入解锁密码!");
$(this).siblings(".admin-header-lock-input").focus();
}else{
$.post("{:url('/admin/unlock')}",{password:password},function (data) {
if(data.code){
window.sessionStorage.setItem("lockcms",false);
$(this).siblings(".admin-header-lock-input").val('');
layer.closeAll("page");
}else{
$(this).siblings(".admin-header-lock-input").val('').focus();
layer.msg(data.msg, {time: 1500}, function () {
if(data.url){
window.sessionStorage.setItem("lockcms",false);
location.href=data.url;
}
});
}
});
}
});
$(document).on('keydown', function(event) {
var event = event || window.event;
if(event.keyCode == 13) {
$("#unlock").click();
}
});
})
function loginout(){
$.post("{:url('/admin/logout')}",'',function (data) {
Expand Down
6 changes: 6 additions & 0 deletions application/admin/view/system/site_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<input type="text" class="layui-input" name="name" value="{$data.value.name}">
</td>
</tr>
<tr>
<td>版权信息</td>
<td>
<input type="text" class="layui-input" name="copyright" value="{$data.value.copyright}">
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding-right: 15%">
<a class="layui-btn" lay-submit lay-filter="save">立即提交</a>
Expand Down
4 changes: 2 additions & 2 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
'auth_group_access' => 'auth_group_access', // 用户-用户组关系表
'auth_rule' => 'auth_rule', // 权限规则表
'auth_user' => 'uese', // 用户信息表
'not_auth_tip' => '无权限操作!', //无权限的提示信息
'not_auth_tip' => '无权限操作!', //无权限的提示信息
'is_cache' => true, //是否将规则缓存
'expire' => 3600, //缓存时间
'prefix' => 'user_auth_', //缓存前缀
'cache_tag' => 'auth', //缓存key
'exclude_rule' => [ //不验证权限的url
'admin/index', //首页
'admin/home' //系统信息
'admin/home', //系统信息
]
];
55 changes: 0 additions & 55 deletions public/js/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,61 +58,6 @@ layui.use(['form','jquery',"layer"],function() {
showNotice();
})

//锁屏
function lockPage(){
layer.open({
title : false,
type : 1,
content : '<div class="admin-header-lock" id="lock-box">'+
'<div class="admin-header-lock-img"><img src="images/face.jpg" class="userAvatar"/></div>'+
'<div class="admin-header-lock-name" id="lockUserName">驊驊龔頾</div>'+
'<div class="input_btn">'+
'<input type="password" class="admin-header-lock-input layui-input" autocomplete="off" placeholder="请输入密码解锁.." name="lockPwd" id="lockPwd" />'+
'<button class="layui-btn" id="unlock">解锁</button>'+
'</div>'+
'<p>请输入“123456”,否则不会解锁成功哦!!!</p>'+
'</div>',
closeBtn : 0,
shade : 0.9,
success : function(){
//判断是否设置过头像,如果设置过则修改顶部、左侧和个人资料中的头像,否则使用默认头像
if(window.sessionStorage.getItem('userFace') && $(".userAvatar").length > 0){
$(".userAvatar").attr("src",$(".userAvatar").attr("src").split("images/")[0] + "images/" + window.sessionStorage.getItem('userFace').split("images/")[1]);
}
}
})
$(".admin-header-lock-input").focus();
}
$(".lockcms").on("click",function(){
window.sessionStorage.setItem("lockcms",true);
lockPage();
})
// 判断是否显示锁屏
if(window.sessionStorage.getItem("lockcms") == "true"){
lockPage();
}
// 解锁
$("body").on("click","#unlock",function(){
if($(this).siblings(".admin-header-lock-input").val() == ''){
layer.msg("请输入解锁密码!");
$(this).siblings(".admin-header-lock-input").focus();
}else{
if($(this).siblings(".admin-header-lock-input").val() == "123456"){
window.sessionStorage.setItem("lockcms",false);
$(this).siblings(".admin-header-lock-input").val('');
layer.closeAll("page");
}else{
layer.msg("密码错误,请重新输入!");
$(this).siblings(".admin-header-lock-input").val('').focus();
}
}
});
$(document).on('keydown', function(event) {
var event = event || window.event;
if(event.keyCode == 13) {
$("#unlock").click();
}
});

//退出
$(".signOut").click(function(){
Expand Down
4 changes: 2 additions & 2 deletions route/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
'editPassword'=>'admin/Login/editPassword', //重置密码
'logout$'=>'admin/Login/logout', //退出
'check$'=>'admin/User/check', //验证用户是否存在
'test$'=>'admin/Login/test', //验证用户是否存在
'getMenu'=>'admin/index/getMenu', //验证用户是否存在
'unlock'=>'admin/Login/unlock', //验证用户是否存在
])->ext('html');
/**
* 需要权限验证路由
*/
Route::group('admin', [

//首页
'index$'=>'admin/Index/index', //首页
'home'=>'admin/Index/home', //系统信息
Expand Down
8 changes: 4 additions & 4 deletions sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MySQL Backup
Source Server Version: 5.7.14
Source Database: tp5.1
Date: 2018/9/9 10:57:03
Date: 2018/9/9 16:19:13
*/

SET FOREIGN_KEY_CHECKS=0;
Expand Down Expand Up @@ -107,6 +107,6 @@ CREATE TABLE `think_user` (
-- ----------------------------
INSERT INTO `think_auth_group` VALUES ('1','管理员组','1','1,2,3,4,5,6,8,9,10','0','1494407780'), ('2','普通用户组','1','1,2,3,4,10,13,14,18,19','0','1494308736');
INSERT INTO `think_auth_group_access` VALUES ('1','1'), ('2','2');
INSERT INTO `think_auth_rule` VALUES ('1','#','首页','0','1','1','','1','fa fa-home','1'), ('2','#','用户管理','0','1','1','','1','fa fa-user','1'), ('3','admin/userList','用户列表','2','1','1','','1',NULL,'1'), ('4','admin/groupList','用户组列表','2','1','1','','1',NULL,'1'), ('5','admin/edit','添加用户','2','1','1','','0','','1'), ('6','#','系统管理','0','1','1','','1','fa fa-cog','1'), ('7','admin/cleanCache','清除缓存','13','1','1','','1','','1'), ('8','admin/menu','菜单管理','13','1','1','','1','','1'), ('9','admin/home','系统信息','1','1','1','','1','','1'), ('10','admin/log','日志管理','13','1','1','','1','','1'), ('11','admin/editMenu','编辑菜单','13','1','1','','0','','1'), ('12','admin/deleteMenu','删除菜单','13','1','1','','0','','1'), ('13','admin/config','系统配置','13','1','1','','1','','1'), ('14','admin/siteConfig','站点配置','13','1','1','','1','','1');
INSERT INTO `think_config` VALUES ('1','system_config','系统配置','{\"debug\": \"0\", \"trace\": \"0\", \"trace_type\": \"0\"}','0','1523414007','1531729547'), ('2','site_config','站点配置','{\"name\": \"tpswoole\", \"title\": \"tpswoole\"}','1','1523414007','1536461414');
INSERT INTO `think_user` VALUES ('1','admin','admin',NULL,'$2y$10$HLh4UHoluqLvwsNN6vQxz.tuKMA5xYp6rH2vOpA.74sxiQbjwm2My','82','127.0.0.1','1536458451','1','1','0','1536458451'), ('2','admin1','admin1',NULL,'$2y$10$HLh4UHoluqLvwsNN6vQxz.tuKMA5xYp6rH2vOpA.74sxiQbjwm2My','13','127.0.0.1','1535891091','1','1','0','1535891091');
INSERT INTO `think_auth_rule` VALUES ('1','#','首页','0','1','1','','1','fa fa-home','1'), ('2','#','用户管理','0','1','1','','1','fa fa-user','1'), ('3','admin/userList','用户列表','2','1','1','','1',NULL,'1'), ('4','admin/groupList','用户组列表','2','1','1','','1',NULL,'1'), ('5','admin/edit','添加用户','2','1','1','','0','','1'), ('6','#','系统管理','0','1','1','','1','fa fa-cog','1'), ('7','admin/cleanCache','清除缓存','6','1','1','','1','','1'), ('8','admin/menu','菜单管理','6','1','1','','1','','1'), ('9','admin/home','系统信息','1','1','1','','1','','1'), ('10','admin/log','日志管理','6','1','1','','1','','1'), ('11','admin/editMenu','编辑菜单','6','1','1','','0','','1'), ('12','admin/deleteMenu','删除菜单','6','1','1','','0','','1'), ('13','admin/config','系统配置','6','1','1','','1','','1'), ('14','admin/siteConfig','站点配置','6','1','1','','1','','1');
INSERT INTO `think_config` VALUES ('1','system_config','系统配置','{\"debug\": \"0\", \"trace\": \"0\", \"trace_type\": \"0\"}','0','1523414007','1531729547'), ('2','site_config','站点配置','{\"name\": \"tpswoole\", \"title\": \"tpswoole\", \"copyright\": \"copyright @2018 原点\"}','1','1523414007','1536478335');
INSERT INTO `think_user` VALUES ('1','admin','admin',NULL,'$2y$10$HLh4UHoluqLvwsNN6vQxz.tuKMA5xYp6rH2vOpA.74sxiQbjwm2My','87','127.0.0.1','1536480810','1','1','0','1536480810'), ('2','admin1','admin1',NULL,'$2y$10$HLh4UHoluqLvwsNN6vQxz.tuKMA5xYp6rH2vOpA.74sxiQbjwm2My','13','127.0.0.1','1535891091','1','1','0','1535891091');

0 comments on commit bd394a1

Please sign in to comment.