帖子附件下载及显示
This commit is contained in:
parent
18df4bda7e
commit
7666402809
@ -90,7 +90,7 @@ class Article extends Model
|
|||||||
{
|
{
|
||||||
$artTop = Cache::get('arttop');
|
$artTop = Cache::get('arttop');
|
||||||
if (!$artTop) {
|
if (!$artTop) {
|
||||||
$artTop = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,jie,pv')->where(['is_top' => 1, 'status' => 1, 'delete_time' => 0])->with([
|
$artTop = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,pv,jie,upzip')->where(['is_top' => 1, 'status' => 1, 'delete_time' => 0])->with([
|
||||||
'cate' => function ($query) {
|
'cate' => function ($query) {
|
||||||
$query->where('delete_time', 0)->field('id,catename,ename');
|
$query->where('delete_time', 0)->field('id,catename,ename');
|
||||||
},
|
},
|
||||||
@ -115,7 +115,7 @@ class Article extends Model
|
|||||||
{
|
{
|
||||||
$artList = Cache::get('artlist');
|
$artList = Cache::get('artlist');
|
||||||
if(!$artList){
|
if(!$artList){
|
||||||
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_hot,jie,pv')
|
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_hot,pv,jie,upzip')
|
||||||
->with([
|
->with([
|
||||||
'cate' => function($query){
|
'cate' => function($query){
|
||||||
$query->where('delete_time',0)->field('id,catename,ename');
|
$query->where('delete_time',0)->field('id,catename,ename');
|
||||||
@ -162,7 +162,7 @@ class Article extends Model
|
|||||||
$article = Cache::get('article_'.$id);
|
$article = Cache::get('article_'.$id);
|
||||||
if(!$article){
|
if(!$article){
|
||||||
//查询文章
|
//查询文章
|
||||||
$article = $this::field('id,title,content,status,cate_id,user_id,is_top,is_hot,is_reply,pv,jie,upzip,tags,title_color,create_time')->where('status',1)->with([
|
$article = $this::field('id,title,content,status,cate_id,user_id,is_top,is_hot,is_reply,pv,jie,upzip,downloads,tags,title_color,create_time')->where('status',1)->with([
|
||||||
'cate' => function($query){
|
'cate' => function($query){
|
||||||
$query->where('delete_time',0)->field('id,catename,ename');
|
$query->where('delete_time',0)->field('id,catename,ename');
|
||||||
},
|
},
|
||||||
@ -203,7 +203,7 @@ class Article extends Model
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
//查询文章,15个分1页
|
//查询文章,15个分1页
|
||||||
case 'jie':
|
case 'jie':
|
||||||
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,jie,pv')->with([
|
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,pv,jie,upzip')->with([
|
||||||
'cate' => function($query){
|
'cate' => function($query){
|
||||||
$query->where('delete_time',0)->field('id,catename,ename');
|
$query->where('delete_time',0)->field('id,catename,ename');
|
||||||
},
|
},
|
||||||
@ -219,7 +219,7 @@ class Article extends Model
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'hot':
|
case 'hot':
|
||||||
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,jie,pv')->with([
|
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,pv,jie,upzip')->with([
|
||||||
'cate' => function($query){
|
'cate' => function($query){
|
||||||
$query->where('delete_time',0)->field('id,catename,ename');
|
$query->where('delete_time',0)->field('id,catename,ename');
|
||||||
},
|
},
|
||||||
@ -235,7 +235,7 @@ class Article extends Model
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'top':
|
case 'top':
|
||||||
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,jie,pv')->with([
|
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,pv,jie,upzip')->with([
|
||||||
'cate' => function($query){
|
'cate' => function($query){
|
||||||
$query->where('delete_time',0)->field('id,catename,ename');
|
$query->where('delete_time',0)->field('id,catename,ename');
|
||||||
},
|
},
|
||||||
@ -251,7 +251,7 @@ class Article extends Model
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,jie,pv')->with([
|
$artList = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,is_hot,pv,jie,upzip')->with([
|
||||||
'cate' => function($query){
|
'cate' => function($query){
|
||||||
$query->where('delete_time',0)->field('id,catename,ename');
|
$query->where('delete_time',0)->field('id,catename,ename');
|
||||||
},
|
},
|
||||||
|
@ -288,6 +288,9 @@ class Article extends BaseController
|
|||||||
{
|
{
|
||||||
$zipdir = Db::name('article')->where('id',$id)->value('upzip');
|
$zipdir = Db::name('article')->where('id',$id)->value('upzip');
|
||||||
$zip = substr($zipdir,1);
|
$zip = substr($zipdir,1);
|
||||||
|
Db::name('article')->cache(true)->where('id',$id)->inc('downloads')->update();
|
||||||
|
//删除缓存显示下载后数据
|
||||||
|
Cache::delete('article_'.$id);
|
||||||
return download($zip,'my');
|
return download($zip,'my');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ CREATE TABLE `tao_article` (
|
|||||||
`pv` int(11) NOT NULL DEFAULT '0' COMMENT '浏览量',
|
`pv` int(11) NOT NULL DEFAULT '0' COMMENT '浏览量',
|
||||||
`jie` enum('1','0') NOT NULL DEFAULT '0' COMMENT '0未结1已结',
|
`jie` enum('1','0') NOT NULL DEFAULT '0' COMMENT '0未结1已结',
|
||||||
`upzip` varchar(70) DEFAULT NULL COMMENT '文章附件',
|
`upzip` varchar(70) DEFAULT NULL COMMENT '文章附件',
|
||||||
|
`downloads` int(5) NOT NULL DEFAULT '0' COMMENT '下载量',
|
||||||
`tags` varchar(255) DEFAULT NULL COMMENT 'tag',
|
`tags` varchar(255) DEFAULT NULL COMMENT 'tag',
|
||||||
`read_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '阅读权限0开放1回复可读2密码可读3私密',
|
`read_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '阅读权限0开放1回复可读2密码可读3私密',
|
||||||
`art_pass` varchar(6) DEFAULT NULL COMMENT '文章加密密码',
|
`art_pass` varchar(6) DEFAULT NULL COMMENT '文章加密密码',
|
||||||
@ -77,7 +78,7 @@ CREATE TABLE `tao_article` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of tao_article
|
-- Records of tao_article
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `tao_article` VALUES ('1', 'Fly Template 社区模版', '[quote]\r\n 你们认为layui官方Fly Template 社区模版怎么样?\r\n[/quote]\r\n你喜欢吗?\r\n很多人都说比较喜欢,我个人认为不错的,这个板子非常喜欢,我看到有一些人做了开发,可惜的是都没有很好的维护,有的漏洞比较多,不完善,很美好的一个板子,但没有长久 的更新,非常的可惜。\r\n如果用别人的不好用,那我就做一个出来吧。喜欢的人多关注,适当时候放出来大家一起用。\r\n关于详情页的内容解析\r\n该模板自带一个特定语法的编辑器,当你把内容存储到数据库后,在页面读取后浏览,会发现诸如“表情、代码、图片”等无法解析,这是因为需要对该内容进行一次转义,通常来说这是在服务端完成的,但鉴于简单化,你还可以直接在前端去解析,在模板的detail.html中,我们已经把相关的代码写好了,你只需打开注释即可(在代码的最下面)。当然,如果觉得编辑器无法满足你的需求,你也可以把该编辑器换成别的HTML编辑器或MarkDown编辑器。', '1', '1', '1', '0', '0', '1', '12', '0', null, null, '0', null, null, null, '1546698225', '1577772362', '0');
|
INSERT INTO `tao_article` VALUES ('1', 'Fly Template 社区模版', '[quote]\r\n 你们认为layui官方Fly Template 社区模版怎么样?\r\n[/quote]\r\n你喜欢吗?\r\n很多人都说比较喜欢,我个人认为不错的,这个板子非常喜欢,我看到有一些人做了开发,可惜的是都没有很好的维护,有的漏洞比较多,不完善,很美好的一个板子,但没有长久 的更新,非常的可惜。\r\n如果用别人的不好用,那我就做一个出来吧。喜欢的人多关注,适当时候放出来大家一起用。\r\n关于详情页的内容解析\r\n该模板自带一个特定语法的编辑器,当你把内容存储到数据库后,在页面读取后浏览,会发现诸如“表情、代码、图片”等无法解析,这是因为需要对该内容进行一次转义,通常来说这是在服务端完成的,但鉴于简单化,你还可以直接在前端去解析,在模板的detail.html中,我们已经把相关的代码写好了,你只需打开注释即可(在代码的最下面)。当然,如果觉得编辑器无法满足你的需求,你也可以把该编辑器换成别的HTML编辑器或MarkDown编辑器。', '1', '1', '1', '0', '0', '1', '12', '0', null, '0', null, '0', null, null, null, '1546698225', '1577772362', '0');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for tao_auth_group
|
-- Table structure for tao_auth_group
|
||||||
|
@ -29,14 +29,15 @@
|
|||||||
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
||||||
-->
|
-->
|
||||||
{if($art.user.vip > 0)}
|
{if($art.user.vip > 0)}
|
||||||
<i class="layui-badge fly-badge-vip">VIP{$art.user.vip}</i>
|
<i class="layui-badge fly-badge-vip">vip{$art.user.vip}</i>
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
<span>{$art.create_time|date='Y-m-d'}</span>
|
<span>{$art.create_time|date='Y-m-d'}</span>
|
||||||
|
|
||||||
<span class="layui-hide-xs" title="人气"><i class="iconfont" title="人气"></i> {$art.pv}</span>
|
<span class="layui-hide-xs" title="浏览"><i class="iconfont" title="浏览"></i> {$art.pv}</span>
|
||||||
{if ($art.jie == 1)}<span class="layui-badge fly-badge-accept layui-hide-xs">{:lang('end')}</span>{/if}
|
{if ($art.jie == 1)}<span class="layui-badge fly-badge-accept layui-hide-xs">{:lang('end')}</span>{/if}
|
||||||
<span class="fly-list-nums">
|
<span class="fly-list-nums">
|
||||||
|
{notempty name="$art.upzip"}<i class="layui-icon layui-icon-file" style="font-size: 15px; color: #393D49;" title="附件"></i>{/notempty}
|
||||||
<i class="iconfont icon-pinglun1" title="回答"></i> {$art.comments_count}
|
<i class="iconfont icon-pinglun1" title="回答"></i> {$art.comments_count}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
<span class="fly-list-nums">
|
<span class="fly-list-nums">
|
||||||
<a href="#comment"><i class="iconfont" title="{:lang('reply')}"></i> {$comments->count()} </a>
|
<a href="#comment"><i class="iconfont" title="{:lang('reply')}"></i> {$comments->count()} </a>
|
||||||
<i class="iconfont" title="人气"></i> {$pv}
|
<i class="iconfont" title="浏览"></i> {$pv}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-about">
|
<div class="detail-about">
|
||||||
@ -58,7 +58,7 @@
|
|||||||
<cite>{$article.user.nickname ?: $article.user.name}</cite>
|
<cite>{$article.user.nickname ?: $article.user.name}</cite>
|
||||||
<i class="iconfont icon-renzheng" title="认证信息:{{ rows.user.approve }}"></i>
|
<i class="iconfont icon-renzheng" title="认证信息:{{ rows.user.approve }}"></i>
|
||||||
{if($article.user.vip > 0)}
|
{if($article.user.vip > 0)}
|
||||||
<i class="layui-badge fly-badge-vip">VIP{$article.user.vip}</i>
|
<i class="layui-badge fly-badge-vip">vip{$article.user.vip}</i>
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
<span>{$article.create_time|date='Y-m-d H:d'}</span>
|
<span>{$article.create_time|date='Y-m-d H:d'}</span>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
{notempty name="$article.upzip"}
|
{notempty name="$article.upzip"}
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label ">{:lang('enclosure')}:</label>
|
<label ">{:lang('enclosure')}:</label>
|
||||||
<button type="button" class="layui-btn" id="zip-download"><i class="layui-icon layui-icon-download-circle"></i>{:lang('download files')}</button>
|
<button type="button" class="layui-btn" id="zip-download"><i class="layui-icon layui-icon-download-circle"></i>{:lang('download files')}: {$article.downloads}次</button>
|
||||||
</div>
|
</div>
|
||||||
{/notempty}
|
{/notempty}
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,15 +14,15 @@
|
|||||||
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
||||||
-->
|
-->
|
||||||
{if($art.user.vip > 0)}
|
{if($art.user.vip > 0)}
|
||||||
<i class="layui-badge fly-badge-vip">VIP{$art.user.vip}</i>
|
<i class="layui-badge fly-badge-vip">vip{$art.user.vip}</i>
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
<span>{$art.create_time|date='Y-m-d'}</span>
|
<span>{$art.create_time|date='Y-m-d'}</span>
|
||||||
|
<span class="layui-hide-xs" title="浏览"><i class="iconfont" title="浏览"></i> {$art.pv}</span>
|
||||||
<span class="layui-hide-xs" title="人气"><i class="iconfont" title="人气"></i> {$art.pv}</span>
|
|
||||||
{if ($art.jie == 1)}<span class="layui-badge fly-badge-accept layui-hide-xs">{:lang('end')}</span>{/if}
|
{if ($art.jie == 1)}<span class="layui-badge fly-badge-accept layui-hide-xs">{:lang('end')}</span>{/if}
|
||||||
|
|
||||||
<span class="fly-list-nums">
|
<span class="fly-list-nums">
|
||||||
|
{notempty name="$art.upzip"}<i class="layui-icon layui-icon-file" style="font-size: 15px; color: #393D49;" title="附件"></i>{/notempty}
|
||||||
<i class="iconfont icon-pinglun1" title="回答"></i>{$art.comments_count}
|
<i class="iconfont icon-pinglun1" title="回答"></i>{$art.comments_count}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
<cite>{$top.user.nickname ?: $top.user.name}</cite>
|
<cite>{$top.user.nickname ?: $top.user.name}</cite>
|
||||||
<!--i class="iconfont icon-renzheng" title="认证信息:XXX"></i-->
|
<!--i class="iconfont icon-renzheng" title="认证信息:XXX"></i-->
|
||||||
{if($top.user.vip > 0)}
|
{if($top.user.vip > 0)}
|
||||||
<i class="layui-badge fly-badge-vip">VIP{$top.user.vip}</i>
|
<i class="layui-badge fly-badge-vip">vip{$top.user.vip}</i>
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
<span>{$top.create_time|date='Y-m-d'}</span>
|
<span>{$top.create_time|date='Y-m-d'}</span>
|
||||||
|
<span class=" layui-hide-xs" title="浏览"> <i class="iconfont" title="浏览"></i> {$top.pv} </span>
|
||||||
<span class=" layui-hide-xs" title="人气"><i class="iconfont" title="人气"></i> {$top.pv}</span>
|
|
||||||
{if ($top.jie == 1)}<span class="layui-badge fly-badge-accept layui-hide-xs">{:lang('end')}</span>{/if}
|
{if ($top.jie == 1)}<span class="layui-badge fly-badge-accept layui-hide-xs">{:lang('end')}</span>{/if}
|
||||||
<span class="fly-list-nums">
|
<span class="fly-list-nums">
|
||||||
|
{notempty name="$top.upzip"}<i class="layui-icon layui-icon-file" style="font-size: 15px; color: #393D49;" title="附件"></i>{/notempty}
|
||||||
<i class="iconfont icon-pinglun1" title="回答"></i> {$top.comments_count}
|
<i class="iconfont icon-pinglun1" title="回答"></i> {$top.comments_count}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user