Skip to content

Commit

Permalink
更新:帖子页布局优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Feb 10, 2023
1 parent 4d3a5dd commit 6676927
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 80 deletions.
6 changes: 3 additions & 3 deletions app/Languages/zh_CN/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
'hot' => '热门',
'best' => '最赞',
'reply' => '回复',
'Published on' => '发表于',
'Updated on' => '更新于',
'Published on' => '发表',
'Updated on' => '更新',
'Error using short tags' => '短代码使用出错',
'login' => '登陆',
'register' => '注册',
Expand All @@ -36,7 +36,7 @@
'notice' => '通知',
'no description' => '暂无描述',
'description' => '描述',
'IP attribution' => 'IP归属地: :province',
'IP attribution' => ':province',
'comment' => '评论',
'set to essence' => '设为精华',
'set to top' => '设为置顶',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if($comment_count)
@if($comment->total())
@if(get_options("comment_topic_show_type","default")==="default")
@php $caina = false; @endphp
@if($data->user_id == auth()->id() && Authority()->check("comment_caina")) @php $caina = true;@endphp @endif
Expand Down Expand Up @@ -65,11 +65,9 @@
<h3 class="card-title">全部评论</h3>
<div class="card-actions">
@if($comment_sort=="desc")
<a href="?{{ core_http_build_query(request()->all(),['comment_sort' => 'asc']) }}">倒序显示↓</a>

<a href="?{{ core_http_build_query(request()->all(),['comment_sort' => 'asc']) }}">正序显示↑</a>
@else
<a href="?{{ core_http_build_query(request()->all(),['comment_sort' => 'desc']) }}">正序显示↑</a>

<a href="?{{ core_http_build_query(request()->all(),['comment_sort' => 'desc']) }}">倒序显示↓</a>
@endif
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/Plugins/Comment/resources/views/Widget/topic.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="col-md-12">
<div class="col-md-12" id="comment">
<div class="border-0 card">
<div class="card-header">
<div class="card-title">评论</div>
Expand Down
4 changes: 1 addition & 3 deletions app/Plugins/Topic/src/Handler/Topic/ShowTopic.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public function handle($id, $comment_page)

// 缓存
$data = Topic::query()->with('tag', 'user', 'topic_updated', 'likes', 'post', 'post.options', 'comments.user', 'comments.post')->find($id);
// 创建数据
$comment_count = TopicComment::query()->where(['status' => 'publish', 'topic_id' => $id])->exists();
// 评论分页数据
if (get_options('comment_show_desc', 'off') === 'true') {
$CommentOrderBy = 'desc';
Expand All @@ -54,6 +52,6 @@ public function handle($id, $comment_page)
$parseData = [
'topic' => $data,
];
return view('App::topic.show.show', ['data' => $data, 'comment_count' => $comment_count, 'comment_sort' => $comment_sort, 'comment' => $comment, 'comment_page' => $comment_page, 'parseData' => $parseData]);
return view('App::topic.show.show', ['data' => $data, 'comment_sort' => $comment_sort, 'comment' => $comment, 'comment_page' => $comment_page, 'parseData' => $parseData]);
}
}
108 changes: 108 additions & 0 deletions app/Themes/CodeFec/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,111 @@
}),
'view' => 'App::topic.show.include.lfpage',
]);

// 新增帖子操作按钮 - 修改
Itf()->add('ui-topic-show-dropdown', 1, [
'enable' => (function ($data) {
if (Authority()->check('admin_topic_edit') && curd()->GetUserClass(auth()->data()->class_id)['permission-value'] > curd()->GetUserClass($data->user->class_id)['permission-value']) {
return true;
}
if (Authority()->check('topic_edit') && auth()->id() === $data->user->id) {
return true;
}
return false;
}),
'view' => (function ($data) {
$__app_revise = __('app.revise');
return <<<HTML
<a class="dropdown-item" href="/topic/{$data->id}/edit"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>{$__app_revise}</a>
HTML;
}),
]);

// 新增帖子操作按钮 - 精华 和置顶
Itf()->add('ui-topic-show-dropdown', 3, [
'enable' => (function ($data) {
if (auth()->check() && Authority()->check("topic_options")) {
return true;
}
return false;
}),
'view' => (function ($data) {
$__app_top = __('app.top');
$__app_essence = __('app.essence');
return <<<HTML
<a class="dropdown-item" core-click="topic-topping" topic-id="{$data->id}" >
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-up-circle" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path>
<path d="M12 8l-4 4"></path>
<path d="M12 8l0 8"></path>
<path d="M16 12l-4 -4"></path>
</svg>
{$__app_top}
</a>
<a class="dropdown-item" core-click="topic-essence" topic-id="{$data->id}" >
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-infinity" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M9.828 9.172a4 4 0 1 0 0 5.656a10 10 0 0 0 2.172 -2.828a10 10 0 0 1 2.172 -2.828a4 4 0 1 1 0 5.656a10 10 0 0 1 -2.172 -2.828a10 10 0 0 0 -2.172 -2.828"></path>
</svg>
{$__app_essence}
</a>
HTML;
}),
]);


// 新增帖子操作按钮 - 删除
Itf()->add('ui-topic-show-dropdown', 100, [
'enable' => (function ($data) {
if (Authority()->check('admin_topic_delete') && curd()->GetUserClass(auth()->data()->class_id)['permission-value'] > curd()->GetUserClass($data->user->class_id)['permission-value']) {
return true;
}
if (Authority()->check('topic_delete') && auth()->id() === $data->user->id) {
return true;
}
return false;
}),
'view' => (function ($data) {
$__app_delete = __('app.delete');
return <<<HTML
<a class="dropdown-item text-danger" core-click="topic-delete" topic-id="{$data->id}" >
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-trash" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<line x1="4" y1="7" x2="20" y2="7"></line>
<line x1="10" y1="11" x2="10" y2="17"></line>
<line x1="14" y1="11" x2="14" y2="17"></line>
<path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12"></path>
<path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>
</svg>
{$__app_delete}</a>
HTML;
}),
]);


// 新增帖子操作按钮 - 举报
Itf()->add('ui-topic-show-dropdown', 99, [
'enable' => (function ($data) {
return true;
}),
'view' => (function ($data) {
$__app_delete = __('app.delete');
return <<<HTML
<a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#modal-report" core-click="report-topic" topic-id="$data->id" >
<svg xmlns="http://www.w3.org/2000/svg" class="hvr-icon icon icon-tabler icon-tabler-flag-3"
width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M5 14h14l-4.5 -4.5l4.5 -4.5h-14v16"></path>
</svg>
举报
</a>
HTML;
}),
]);
103 changes: 54 additions & 49 deletions app/Themes/CodeFec/resources/views/topic/show/content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,57 @@
<div class="col-md-12" id="topic">
<div class="card">
<div class="card-header">
<ol class="breadcrumb breadcrumb-arrows" aria-label="breadcrumbs">
<li class="breadcrumb-item"><a href="/">首页</a></li>
<li class="breadcrumb-item"><a href="/tags/{{$data->tag->id}}.html">
{!! $data->tag->icon !!}
{{$data->tag->name}}
</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="">{{\Hyperf\Utils\Str::limit($data->title,20)}}</a></li>
</ol>
</div>
<div class="card-body topic">
@if ($data->essence > 0)
<div class="ribbon bg-green text-h3">
{{__('app.essence')}}
</div>
@endif
<div class="row" style="margin-top: -10px">
{{-- 标题--}}
<div class="col-md-12" id="title">
<h1 data-bs-toggle="tooltip" data-bs-placement="left" title="{{__('topic.title')}}">
@if ($data->topping > 0)
<span class="text-red">
{{__('app.top')}}
</span>
@endif
{{ $data->title }}
</h1>
</div>

{{-- 面包屑--}}
<div class="col-md-12">
@include('App::topic.show.ol')
</div>
<hr class="hr-text" style="margin-top: 5px;margin-bottom: 5px">

{{-- 作者信息--}}
@include('App::topic.show.include.author')

{{--文章信息--}}
<article class="col-md-12 article markdown" id="topic-content">
{!! ContentParse()->parse($data->post->content,$parseData) !!}
</article>
@if($data->user->Options->qianming!=='no bio')
<div class="hr-text hr-text-left mb-3">signature</div>
<span class="text-muted mb-0">
{{$data->user->Options->qianming}}
<h2 class="card-title text-reset" style="font-size: 1.5rem;" data-bs-toggle="tooltip"
data-bs-placement="top" title="{{__('topic.title')}}">
{{ $data->title }}
@if ($data->essence > 0)
<span class="text-green">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-diamond" style="--tblr-icon-size:1.8rem" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M6 5h12l3 5l-8.5 9.5a.7 .7 0 0 1 -1 0l-8.5 -9.5l3 -5"></path>
<path d="M10 12l-2 -2.2l.6 -1"></path>
</svg>
</span>
@endif

</h2>
<div class="card-actions">
@if(auth()->check())
<div class="dropdown">
<a href="#" class="btn-action dropdown-toggle" data-bs-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<!-- Download SVG icon from http://tabler-icons.io/i/dots-vertical -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/>
<path d="M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/>
<path d="M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/>
</svg>
</a>
<div class="dropdown-menu dropdown-menu-end text-muted">
@foreach(Itf()->get('ui-topic-show-dropdown') as $k=>$v)
@if(call_user_func($v['enable'],$data)===true && $v['view'] instanceof \Closure)
{!! call_user_func($v['view'],$data) !!}
@endif
@endforeach
</div>
</div>
@endif
</div>
</div>
@include('App::topic.show.include.author')
<article class="card-body topic article markdown text-reset">
{!! ContentParse()->parse($data->post->content,$parseData) !!}
</article>
<div class="px-3 py-3">
@if($data->user->Options->qianming!=='no bio')
<div class="hr-text hr-text-left mt-0 mb-3">signature</div>
<span class="text-muted">
{{$data->user->Options->qianming}}
</span>
@endif
</div>

{{-- 页脚--}}
@include('App::topic.show.include.footer')
Expand All @@ -66,7 +67,7 @@
</div>

{{-- 上下页--}}
{{-- @include('App::topic.show.include.lfpage')--}}
{{-- @include('App::topic.show.include.lfpage')--}}
@foreach(Itf()->get('ui-topic-comment-before-hook') as $k=>$v)
@if(call_user_func($v['enable'])===true)
@include($v['view'])
Expand All @@ -77,7 +78,9 @@
<div class="border-0 card">
<div class="empty">
<div class="empty-icon"><!-- Download SVG icon from http://tabler-icons.io/i/mood-sad -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-ban" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-ban" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="12" cy="12" r="9"></circle>
<line x1="5.7" y1="5.7" x2="18.3" y2="18.3"></line>
Expand All @@ -91,7 +94,9 @@
<div class="empty-action">
<a href="/login" class="btn btn-primary">
<!-- Download SVG icon from http://tabler-icons.io/i/search -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-login" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-login"
width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"></path>
<path d="M20 12h-13l3 -3m0 6l-3 -3"></path>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<div class="col-md-12" id="author">
<div class="mx-3 my-3 mb-0" id="author">
<div class="row">
<div class="col">
<div class="row">
<div class="col-auto">
<a class="avatar" href="/users/{{ $data->user->id }}.html"
<a class="avatar avatar-rounded" href="/users/{{ $data->user->id }}.html"
style="background-image: url({{ super_avatar($data->user) }})"></a>
</div>
<div class="col" style="margin-left: -10px">
<div class="topic-author-name">
{!! u_username($data->user,['topic' => true,'extends' => true,'class' => ['text-reset']]) !!}
<a data-bs-toggle="tooltip" data-bs-placement="right" title="{{$data->user->class->name}}" href="/users/group/{{$data->user->class->id}}.html" style="color:{{$data->user->class->color}}">
<span>{!! $data->user->class->icon !!}</span>
</a>
</div>
<div>{{__("app.Published on")}}:{{ format_date($data->created_at) }}
<div>
<span class="cursor-pointer" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{$data->created_at}}">
{{__("app.Published on")}}:{{ format_date($data->created_at) }}
</span>
<span class="cursor-pointer" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{$data->updated_at}}">{{__("app.Updated on")}}:{{ format_date($data->created_at) }}</span>
<span v-if="user.city">
|
<span class="text-red">
Expand All @@ -22,10 +23,36 @@
</span>
</div>
</div>
<div class="col-auto">

</div>
</div>
</div>
<div class="col-auto">

</div>
</div>
</div>
<div class="mt-0 mb-0">
<div class="hr-text hr-text-right mt-3 mb-0">
<div class="text-muted">
{{-- 浏览量--}}
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-eye" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path>
<path d="M22 12c-2.667 4.667 -6 7 -10 7s-7.333 -2.333 -10 -7c2.667 -4.667 6 -7 10 -7s7.333 2.333 10 7"></path>
</svg>
{{$data->view}}
</div>
<span class="mx-1">|</span>
<a class="text-muted" href="#comment"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-message-circle" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M3 20l1.3 -3.9a9 8 0 1 1 3.4 2.9l-4.7 1"></path>
<path d="M12 12l0 .01"></path>
<path d="M8 12l0 .01"></path>
<path d="M16 12l0 .01"></path>
</svg>
{{$comment->total()}}
</a>
</div>
</div>

0 comments on commit 6676927

Please sign in to comment.