Skip to content

Commit

Permalink
更新:优化Tags页面
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Dec 14, 2022
1 parent 5952526 commit 00b8df3
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 91 deletions.
154 changes: 68 additions & 86 deletions app/Plugins/Topic/resources/views/Tags/data/index.blade.php
@@ -1,94 +1,76 @@
<div class="row row-cards justify-content-center">
@if($page->count())
@foreach($page as $data)
<article class="col-md-12">
<div class="border-0 card card-body">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-auto">
<a href="/users/{{$data->user->username}}.html" class="avatar"
style="background-image: url({{super_avatar($data->user)}})">
<div class="card">

</a>
</div>
<div class="col">
<a href="/users/{{$data->user->username}}.html"
style="margin-bottom:0;text-decoration:none;"
class="card-title text-reset">{{$data->user->username}}</a>
<div style="margin-top:1px">{{__("app.Published on")}}:{{$data->created_at}}</div>
</div>
<div class="col-auto">
@if($data->essence>0)
<div class="ribbon bg-green text-h3">
{{__("app.essence")}}
</div>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="row">
<div class="col-md-12 markdown home-article">
<a href="/{{$data->id}}.html" class="text-reset">
<h2>
@if($data->topping>0)
<span class="text-red">
{{__('app.top')}}
</span>
@endif
{{$data->title}}</h2>
</a>
<span class="home-summary">{!! content_brief($data->post->content,get_options("topic_brief_len",250)) !!}</span>
</div>
</div>
</div>
<div class="col-md-12" style="margin-top: 5px">
<div class="d-flex align-items-center">
<div class="col-auto bottomLine">
<a href="/tags/{{$data->tag->id}}.html" style="text-decoration:none">
<div class="card-circle">
<img src="{{$data->tag->icon}}" alt="">
<span>{{$data->tag->name}}</span>
</div>
</a>
</div>
<div class="ms-auto">
<span class="text-muted" data-bs-toggle="tooltip" data-bs-placement="bottom"
title="{{__("app.pageviews")}}">
<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"/><circle
cx="12" cy="12" r="2"/><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"/></svg>
{{$data->view}}
</span>
<a style="text-decoration:none;" core-click="like-topic" topic-id="{{$data->id}}"
class="ms-3 text-muted cursor-pointer" data-bs-toggle="tooltip"
data-bs-placement="bottom" title="{{__("topic.likes")}}">
<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="M19.5 13.572l-7.5 7.428l-7.5 -7.428m0 0a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572"/>
</svg>
<span core-show="topic-likes">{{$data->like}}</span>
</a>
</div>
</div>
<div class="card-header">
<ul class="nav nav-pills card-header-pills">
@if(!count(request()->all()))
<li class="nav-item">
<a class="nav-link active fw-bold" href="/tags/{{$data->id}}.html">
<svg xmlns="http://www.w3.org/2000/svg" class="icon me-1 d-none d-sm-block" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path d="M0 0h24v24H0z" stroke="none"/>
<circle cx="12" cy="12" r="9"/>
<path d="M12 7v5l3 3"/>
</svg>
{{__('app.latest')}}</a>
</li>
@else
<li class="nav-item">
<a class="nav-link" href="/tags/{{$data->id}}.html">
<svg xmlns="http://www.w3.org/2000/svg" class="icon me-1 d-none d-sm-block" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
stroke-linecap="round" stroke-linejoin="round">
<path d="M0 0h24v24H0z" stroke="none"/>
<circle cx="12" cy="12" r="9"/>
<path d="M12 7v5l3 3"/>
</svg>
{{__('app.latest')}}</a>
</li>
@endif
@foreach($topic_menu as $data)
@if(\Hyperf\Utils\Str::contains(core_http_url(),$data['parameter']))
<li class="nav-item">
<a class="nav-link active fw-bold" href="{{$data['url']}}">
{!!$data['icon']!!}{{$data['name']}}</a>
</li>
@else
<li class="nav-item">
<a class="nav-link" href="{{$data['url']}}">
{!!$data['icon']!!}{{$data['name']}}</a>
</li>
@endif
@endforeach
<li class="nav-item ms-auto">
<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"/><circle cx="12" cy="12" r="1" /><circle cx="12" cy="19" r="1" /><circle cx="12" cy="5" r="1" /></svg>
</a>
<div class="dropdown-menu dropdown-menu-end">
@foreach(Itf()->get('ui-home-tabs-dropdown') as $k=>$v)
@if(call_user_func($v['enable'])===true)
@include($v['view'])
@endif
@endforeach
</div>
</div>
</li>
</ul>
</div>

@if($page->count())
@foreach($page as $data)
@include('App::index.style2')
@endforeach
@else
<div class="col-md-12">
<div class="border-0 card card-body">
<div class="text-center card-title">{{__("app.No more results")}}</div>
</div>
</article>
@endforeach
@else
<div class="col-md-12">
<div class="border-0 card card-body">
<div class="text-center card-title">{{__("app.No more results")}}</div>
</div>
@endif
<div class="mt-2">
{!! make_page($page) !!}
</div>
@endif
{!! make_page($page) !!}
</div>
</div>
67 changes: 64 additions & 3 deletions app/Plugins/Topic/src/Controllers/TagsController.php
Expand Up @@ -36,13 +36,74 @@ public function data($id)
if (! TopicTag::query()->where('status', '=', null)->where('id', $id)->exists()) {
return admin_abort('页面不存在', 404);
}
$page = Topic::query()
$page = Topic::query(true)
->where('tag_id', $id)
->where('status', 'publish')
->with('tag', 'user')
->orderBy('id', 'desc')
->orderBy('topping', 'desc')
->orderBy('updated_at', 'desc')
->paginate(get_options('topic_home_num', 15));
if (request()->input('query') === 'hot') {
$page = Topic::query()
->where('tag_id', $id)
->where('status', 'publish')
->with('tag', 'user')
->orderBy('view', 'desc')
->orderBy('id', 'desc')
->paginate(get_options('topic_home_num', 15));
}
if (request()->input('query') === 'publish') {
$page = Topic::query()
->where('tag_id', $id)
->where('status', 'publish')
->with('tag', 'user')
->orderBy('id', 'desc')
->paginate(get_options('topic_home_num', 15));
}
if (request()->input('query') === 'essence') {
$page = Topic::query()
->where('tag_id', $id)
->where([['essence', '>', 0], ['status', 'publish']])
->with('tag', 'user')
->orderBy('updated_at', 'desc')
->paginate(get_options('topic_home_num', 15));
}
if (request()->input('query') === 'topping') {
$page = Topic::query()
->where('tag_id', $id)
->where([['topping', '>', 0], ['status', 'publish']])
->with('tag', 'user')
->orderBy('updated_at', 'desc')
->paginate((int) get_options('topic_home_num', 15));
}
$data = TopicTag::query()->where('id', $id)->first();
return view('Topic::Tags.data', ['data' => $data, 'page' => $page]);
$topic_menu = [
[
'name' => '最新发布',
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-news" 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="M16 6h3a1 1 0 0 1 1 1v11a2 2 0 0 1 -4 0v-13a1 1 0 0 0 -1 -1h-10a1 1 0 0 0 -1 1v12a3 3 0 0 0 3 3h11"></path>
<line x1="8" y1="8" x2="12" y2="8"></line>
<line x1="8" y1="12" x2="12" y2="12"></line>
<line x1="8" y1="16" x2="12" y2="16"></line>
</svg>',
'url' => '/tags/' . $data->id . '.html?' . core_http_build_query(['query' => 'publish'], ['page' => request()->input('page', 1)]),
'parameter' => 'query=publish',
],
[
'name' => __('app.essence'),
'icon' => '<svg width="24" height="24" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" class="icon w-3 h-3 me-1 d-none d-md-block"><g stroke-width="3" fill-rule="evenodd"><path fill="#fff" fill-opacity=".01" d="M0 0h48v48H0z"/><g stroke="currentColor" fill="none"><path d="M10.636 5h26.728L45 18.3 24 43 3 18.3z"/><path d="M10.636 5L24 43 37.364 5M3 18.3h42"/><path d="M15.41 18.3L24 5l8.59 13.3"/></g></g></svg>',
'url' => '/tags/' . $data->id . '.html?' . core_http_build_query(['query' => 'essence'], ['page' => request()->input('page', 1)]),
'parameter' => 'query=essence',
],
[
'name' => __('app.hot'),
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" class="icon me-1 d-none d-md-block" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M0 0h24v24H0z" stroke="none"/><path d="M12 12c2-2.96 0-7-1-8 0 3.038-1.773 4.741-3 6-1.226 1.26-2 3.24-2 5a6 6 0 1 0 12 0c0-1.532-1.056-3.94-2-5-1.786 3-2.791 3-4 2z"/></svg>',
'url' => '/tags/' . $data->id . '.html?' . core_http_build_query(['query' => 'hot'], ['page' => request()->input('page', 1)]),
'parameter' => 'query=hot',
],
];
return view('Topic::Tags.data', ['data' => $data, 'page' => $page, 'topic_menu' => $topic_menu]);
}

#[GetMapping(path: '/tags/create')]
Expand Down
2 changes: 1 addition & 1 deletion app/Plugins/User/resources/views/home/comment.blade.php
@@ -1,7 +1,7 @@
<link rel="stylesheet" href="{{ mix('plugins/Topic/css/app.css') }}">
<div class="row row-cards">

@php($topics = \App\Plugins\Comment\src\Model\TopicComment::query()->where(['user_id' => $user->id,'status' => 'publish'])->paginate(15))
@php($topics = \App\Plugins\Comment\src\Model\TopicComment::query()->where(['user_id' => $user->id,'status' => 'publish'])->orderByDesc('id')->paginate(15))
<div class="col-md-12">
<div class="border-0 card card-body">
<h3 class="card-title">{{$user->username}} 发布的评论</h3>
Expand Down
2 changes: 1 addition & 1 deletion app/Plugins/User/resources/views/home/topic.blade.php
@@ -1,7 +1,7 @@
<link rel="stylesheet" href="{{ mix('plugins/Topic/css/app.css') }}">
<div class="row row-cards">

@php($topics = \App\Plugins\Topic\src\Models\Topic::query()->where(['user_id' => $user->id,'status' => 'publish'])->paginate(15))
@php($topics = \App\Plugins\Topic\src\Models\Topic::query()->where(['user_id' => $user->id,'status' => 'publish'])->orderByDesc('id')->paginate(15))
<div class="col-md-12">
<div class="border-0 card card-body">
<h3 class="card-title">{{$user->username}} 发布的主题</h3>
Expand Down

0 comments on commit 00b8df3

Please sign in to comment.