Skip to content

Commit

Permalink
版本更新到1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tingyuu committed Jan 4, 2018
1 parent cfa1165 commit af0ae27
Show file tree
Hide file tree
Showing 60 changed files with 880 additions and 2,781 deletions.
30 changes: 30 additions & 0 deletions README.md
@@ -1,3 +1,32 @@
Tplay 1.1
===============

更新说明:

1.新增部分索引

2.新增便签功能

3.新增置顶和审核文章的功能

4.优化部分按钮和表格的表现

5.调整部分页面的打开方式为iframe弹窗

6.重做了新增和修改管理员角色时分配权限的页面部分

7.部分表单页面增加了相应的注释

8.layui版本提升到2.2.5

下次更新:

1.增加第三方登录

2.增加支付

3.增加微信公众号管理

Tplay 1.0
===============

Expand Down Expand Up @@ -33,6 +62,7 @@ www WEB部署目录(或者子目录)
│ ├─static css、js等资源目录
│ │ ├─admin Tplay后台css、js文件
│ │ ├─public 公共css、js文件
│ ├─uploads 图片等资源文件
│ ├─index.php 入口文件
│ ├─router.php 快速测试文件
│ └─.htaccess 用于apache的重写
Expand Down
56 changes: 52 additions & 4 deletions app/admin/controller/Admin.php
Expand Up @@ -283,8 +283,8 @@ public function adminCatePublish()
//将菜单id字符串拆分成数组
$info['cate']['permissions'] = explode(',',$info['cate']['permissions']);
}
$menus = $menuModel->select();
$info['menu'] = $menuModel->menulist($menus);
$menus = Db::name('admin_menu')->select();
$info['menu'] = $this->menulist($menus);
$this->assign('info',$info);
return $this->fetch();
}
Expand Down Expand Up @@ -318,14 +318,62 @@ public function adminCatePublish()
}
} else {
//非提交操作
$info['menu'] = $menuModel->select();
$info['menu'] = $menuModel->menulist($info['menu']);
$menus = Db::name('admin_menu')->select();
$info['menu'] = $this->menulist($menus);
//$info['menu'] = $this->menulist($info['menu']);
$this->assign('info',$info);
return $this->fetch();
}
}
}


public function preview()
{
$id = $this->request->has('id') ? $this->request->param('id', 0, 'intval') : 0;
$model = new \app\admin\model\AdminCate();
$info['cate'] = $model->where('id',$id)->find();
if(!empty($info['cate']['permissions'])) {
//将菜单id字符串拆分成数组
$info['cate']['permissions'] = explode(',',$info['cate']['permissions']);
}
$menus = Db::name('admin_menu')->select();
$info['menu'] = $this->menulist($menus);
$this->assign('info',$info);
return $this->fetch();
}


protected function menulist($menu,$id=0,$level=0){

static $menus = array();
$size = count($menus)-1;
foreach ($menu as $value) {
if ($value['pid']==$id) {
$value['level'] = $level+1;
if($level == 0)
{
$value['str'] = str_repeat('',$value['level']);
$menus[] = $value;
}
elseif($level == 2)
{
$value['str'] = '    '.'└ ';
$menus[$size]['list'][] = $value;
}
else
{
$value['str'] = '  '.'└ ';
$menus[$size]['list'][] = $value;
}

$this->menulist($menu,$value['id'],$value['level']);
}
}
return $menus;
}


/**
* 管理员角色删除
* @return [type] [description]
Expand Down
28 changes: 28 additions & 0 deletions app/admin/controller/Article.php
Expand Up @@ -134,4 +134,32 @@ public function delete()
}
}
}


public function is_top()
{
if($this->request->isPost()){
$post = $this->request->post();
if(false == Db::name('article')->where('id',$post['id'])->update(['is_top'=>$post['is_top']])) {
return $this->error('设置失败');
} else {
addlog($post['id']);//写入日志
return $this->success('设置成功','admin/article/index');
}
}
}


public function status()
{
if($this->request->isPost()){
$post = $this->request->post();
if(false == Db::name('article')->where('id',$post['id'])->update(['status'=>$post['status']])) {
return $this->error('设置失败');
} else {
addlog($post['id']);//写入日志
return $this->success('设置成功','admin/article/index');
}
}
}
}
17 changes: 17 additions & 0 deletions app/admin/controller/Common.php
Expand Up @@ -108,6 +108,20 @@ public function login()
if($name['password'] != $post['password']) {
return $this->error('密码错误');
} else {
//是否记住账号
if(!empty($post['remember']) and $post['remember'] == 1) {
//检查当前有没有记住的账号
if(Cookie::has('usermember')) {
Cookie::delete('usermember');
}
//保存新的
Cookie::forever('usermember',$post['name']);
} else {
//未选择记住账号,或属于取消操作
if(Cookie::has('usermember')) {
Cookie::delete('usermember');
}
}
Cookie::set("admin",$name['id'],7200); //保存新的,最长为2小时
//记录登录时间和ip
Db::name('admin')->where('id',$name['id'])->update(['login_ip' => $this->request->ip(),'login_time' => time()]);
Expand All @@ -119,6 +133,9 @@ public function login()
}
}
} else {
if(Cookie::has('usermember')) {
$this->assign('usermember',Cookie::get('usermember'));
}
return $this->fetch();
}
} else {
Expand Down
39 changes: 39 additions & 0 deletions app/admin/controller/Main.php
Expand Up @@ -13,6 +13,7 @@
namespace app\admin\controller;

use \think\Db;
use \think\Cookie;
class Main extends \think\Controller
{
public function index()
Expand Down Expand Up @@ -46,15 +47,53 @@ public function index()
*/
$web['user_num'] = Db::name('admin')->count();
$web['admin_cate'] = Db::name('admin_cate')->count();
$ip_ban = Db::name('webconfig')->value('black_ip');
$web['ip_ban'] = empty($ip_ban) ? 0 : count(explode(',',$ip_ban));

$web['article_num'] = Db::name('article')->count();
$web['status_article'] = Db::name('article')->where('status',0)->count();
$web['top_article'] = Db::name('article')->where('is_top',1)->count();
$web['file_num'] = Db::name('attachment')->count();
$web['status_file'] = Db::name('attachment')->where('status',0)->count();
$web['ref_file'] = Db::name('attachment')->where('status',-1)->count();
$web['message_num'] = Db::name('messages')->count();
$web['look_message'] = Db::name('messages')->where('is_look',0)->count();

if(Cookie::has('remember')) {
$web['remember'] = Cookie::get('remember');
//return $web['remember'];
} else {
$web['remember'] = '';
}

$this->assign('web',$web);

return $this->fetch();
}


public function remember()
{
if($this->request->isPost()) {
$post = $this->request->post();
if(Cookie::has('remember')) {
Cookie::delete('remember');
}
Cookie::forever('remember',$post['message']);
return $this->success('一经记,不轻忘...');
}
}


public function delremember()
{
if($this->request->isPost()) {
if(Cookie::has('remember')) {
Cookie::delete('remember');
} else {
return $this->error('不曾记,何以忘...');
}
return $this->success('一经忘,不再想...');
}
}
}
3 changes: 2 additions & 1 deletion app/admin/model/AdminMenu.php
Expand Up @@ -16,13 +16,14 @@
class AdminMenu extends Model
{
public function menulist($menu,$id=0,$level=0){

static $menus = array();
foreach ($menu as $value) {
if ($value['pid']==$id) {
$value['level'] = $level+1;
if($level == 0)
{
$value['str'] = str_repeat('<i class="fa fa-angle-double-right"></i> ',$value['level']);
$value['str'] = str_repeat('',$value['level']);
}
elseif($level == 2)
{
Expand Down
2 changes: 1 addition & 1 deletion app/admin/model/ArticleCate.php
Expand Up @@ -22,7 +22,7 @@ public function catelist($cate,$id=0,$level=0){
$value['level'] = $level+1;
if($level == 0)
{
$value['str'] = str_repeat('<i class="fa fa-angle-double-right"></i> ',$value['level']);
$value['str'] = str_repeat('',$value['level']);
}
elseif($level == 2)
{
Expand Down
72 changes: 47 additions & 25 deletions app/admin/view/admin/adminCate.html
Expand Up @@ -14,19 +14,29 @@
<body>
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
<div class="layui-btn-group demoTable">
<a href="{:url('admin/admin/adminCatePublish')}" class="a_menu">
<button class="layui-btn layui-btn-sm"><i class="fa fa-edit"> </i>添加新角色</button>
<a href="{:url('admin/admin/adminCatePublish')}" class="layui-btn layui-btn-sm a_menu">
<i class="fa fa-edit"> </i>添加新角色
</a>
</div>
</fieldset>
<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
<colgroup>
<col width="50">
<col width="100">
<col width="150">
<col width="150">
<col width="150">
<col width="300">
<col width="60">
</colgroup>
<thead>
<tr>
<th>编号</th>
<th>角色名称</th>
<th>权限预览</th>
<th>创建时间</th>
<th>修改时间</th>
<th>最后修改时间</th>
<th>备注</th>
<th>操作</th>
</tr>
</thead>
Expand All @@ -35,12 +45,13 @@
<tr>
<td>{$vo.id}</td>
<td>{$vo.name}</td>
<td><a href="javascript:;">点击查看</a></td>
<td><a href="{:url('admin/admin/preview',['id'=>$vo.id])}" class="layui-btn layui-btn-xs preview" style="margin-right: 0;font-size:12px;">点击查看</a></td>
<td>{$vo.create_time}</td>
<td>{$vo.update_time}</td>
<td>{$vo.desc}</td>
<td class="operation-menu">
<a href="{:url('admin/admin/adminCatePublish',['id'=>$vo.id])}" class="a_menu"><button class="layui-btn layui-btn-xs" ><i class="layui-icon"></i></button></a>
<button class="layui-btn layui-btn-xs delete" id="{$vo.id}"><i class="layui-icon"></i></button>
<a href="{:url('admin/admin/adminCatePublish',['id'=>$vo.id])}" class="layui-btn layui-btn-xs a_menu" style="margin-right: 0;font-size:12px;">修改</a>
<a class="layui-btn layui-btn-xs layui-btn-danger delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;">删除</a>
</td>
</tr>
{/volist}
Expand Down Expand Up @@ -88,36 +99,47 @@
})
</script>
<script type="text/javascript">
$('.a_menu').click(function(){
var url = $(this).attr('href');
var id = $(this).attr('id');
var a = true;
if(id) {
layui.use('layer', function(){
var layer = layui.layer;
$('.a_menu').click(function(){
var url = $(this).attr('href');
var a = 0;
$.ajax({
url:url
,async:false
,data:{id:id}
,success:function(res){
if(res.code == 0) {
layer.msg(res.msg);
a = false;
a = 1;
}
}
})
} else {
$.ajax({
url:url
,async:false
,success:function(res){
if(res.code == 0) {
layer.msg(res.msg);
a = false;
if(a === 0) {
layer.open({
type:2,
content:url,
area: ['700px', '600px'],
end:function(){
location.reload();
}
});
}
return false;
})

$('.preview').click(function(){
var url = $(this).attr('href');
layer.open({
type:2,
content:url,
area: ['550px', '400px'],
end:function(){
location.reload();
}
})
}
return a;
})
});
return false;
})
});
</script>
</body>
</html>

0 comments on commit af0ae27

Please sign in to comment.