Skip to content

Commit 00b8df3

Browse files
committedDec 14, 2022
更新:优化Tags页面
·
v2.7.7v2.1.7
1 parent 5952526 commit 00b8df3

File tree

4 files changed

+134
-91
lines changed

4 files changed

+134
-91
lines changed
 
Lines changed: 68 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,76 @@
11
<div class="row row-cards justify-content-center">
2-
@if($page->count())
3-
@foreach($page as $data)
4-
<article class="col-md-12">
5-
<div class="border-0 card card-body">
6-
<div class="row">
7-
<div class="col-md-12">
8-
<div class="row">
9-
<div class="col-auto">
10-
<a href="/users/{{$data->user->username}}.html" class="avatar"
11-
style="background-image: url({{super_avatar($data->user)}})">
2+
<div class="card">
123

13-
</a>
14-
</div>
15-
<div class="col">
16-
<a href="/users/{{$data->user->username}}.html"
17-
style="margin-bottom:0;text-decoration:none;"
18-
class="card-title text-reset">{{$data->user->username}}</a>
19-
<div style="margin-top:1px">{{__("app.Published on")}}:{{$data->created_at}}</div>
20-
</div>
21-
<div class="col-auto">
22-
@if($data->essence>0)
23-
<div class="ribbon bg-green text-h3">
24-
{{__("app.essence")}}
25-
</div>
26-
@endif
27-
</div>
28-
</div>
29-
</div>
30-
<div class="col-md-12">
31-
<div class="row">
32-
<div class="col-md-12 markdown home-article">
33-
<a href="/{{$data->id}}.html" class="text-reset">
34-
<h2>
35-
@if($data->topping>0)
36-
<span class="text-red">
37-
{{__('app.top')}}
38-
</span>
39-
@endif
40-
{{$data->title}}</h2>
41-
</a>
42-
<span class="home-summary">{!! content_brief($data->post->content,get_options("topic_brief_len",250)) !!}</span>
43-
</div>
44-
</div>
45-
</div>
46-
<div class="col-md-12" style="margin-top: 5px">
47-
<div class="d-flex align-items-center">
48-
<div class="col-auto bottomLine">
49-
<a href="/tags/{{$data->tag->id}}.html" style="text-decoration:none">
50-
<div class="card-circle">
51-
<img src="{{$data->tag->icon}}" alt="">
52-
<span>{{$data->tag->name}}</span>
53-
</div>
54-
</a>
55-
</div>
56-
<div class="ms-auto">
57-
<span class="text-muted" data-bs-toggle="tooltip" data-bs-placement="bottom"
58-
title="{{__("app.pageviews")}}">
59-
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
60-
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
61-
stroke-linecap="round" stroke-linejoin="round"><path stroke="none"
62-
d="M0 0h24v24H0z"
63-
fill="none"/><circle
64-
cx="12" cy="12" r="2"/><path
65-
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>
66-
{{$data->view}}
67-
</span>
68-
<a style="text-decoration:none;" core-click="like-topic" topic-id="{{$data->id}}"
69-
class="ms-3 text-muted cursor-pointer" data-bs-toggle="tooltip"
70-
data-bs-placement="bottom" title="{{__("topic.likes")}}">
71-
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
72-
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
73-
stroke-linecap="round" stroke-linejoin="round">
74-
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
75-
<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"/>
76-
</svg>
77-
<span core-show="topic-likes">{{$data->like}}</span>
78-
</a>
79-
</div>
80-
</div>
4+
<div class="card-header">
5+
<ul class="nav nav-pills card-header-pills">
6+
@if(!count(request()->all()))
7+
<li class="nav-item">
8+
<a class="nav-link active fw-bold" href="/tags/{{$data->id}}.html">
9+
<svg xmlns="http://www.w3.org/2000/svg" class="icon me-1 d-none d-sm-block" width="24"
10+
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
11+
stroke-linecap="round" stroke-linejoin="round">
12+
<path d="M0 0h24v24H0z" stroke="none"/>
13+
<circle cx="12" cy="12" r="9"/>
14+
<path d="M12 7v5l3 3"/>
15+
</svg>
16+
{{__('app.latest')}}</a>
17+
</li>
18+
@else
19+
<li class="nav-item">
20+
<a class="nav-link" href="/tags/{{$data->id}}.html">
21+
<svg xmlns="http://www.w3.org/2000/svg" class="icon me-1 d-none d-sm-block" width="24"
22+
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
23+
stroke-linecap="round" stroke-linejoin="round">
24+
<path d="M0 0h24v24H0z" stroke="none"/>
25+
<circle cx="12" cy="12" r="9"/>
26+
<path d="M12 7v5l3 3"/>
27+
</svg>
28+
{{__('app.latest')}}</a>
29+
</li>
30+
@endif
31+
@foreach($topic_menu as $data)
32+
@if(\Hyperf\Utils\Str::contains(core_http_url(),$data['parameter']))
33+
<li class="nav-item">
34+
<a class="nav-link active fw-bold" href="{{$data['url']}}">
35+
{!!$data['icon']!!}{{$data['name']}}</a>
36+
</li>
37+
@else
38+
<li class="nav-item">
39+
<a class="nav-link" href="{{$data['url']}}">
40+
{!!$data['icon']!!}{{$data['name']}}</a>
41+
</li>
42+
@endif
43+
@endforeach
44+
<li class="nav-item ms-auto">
45+
<div class="dropdown">
46+
<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 -->
47+
<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>
48+
</a>
49+
<div class="dropdown-menu dropdown-menu-end">
50+
@foreach(Itf()->get('ui-home-tabs-dropdown') as $k=>$v)
51+
@if(call_user_func($v['enable'])===true)
52+
@include($v['view'])
53+
@endif
54+
@endforeach
8155
</div>
8256
</div>
57+
</li>
58+
</ul>
59+
</div>
60+
61+
@if($page->count())
62+
@foreach($page as $data)
63+
@include('App::index.style2')
64+
@endforeach
65+
@else
66+
<div class="col-md-12">
67+
<div class="border-0 card card-body">
68+
<div class="text-center card-title">{{__("app.No more results")}}</div>
8369
</div>
84-
</article>
85-
@endforeach
86-
@else
87-
<div class="col-md-12">
88-
<div class="border-0 card card-body">
89-
<div class="text-center card-title">{{__("app.No more results")}}</div>
9070
</div>
71+
@endif
72+
<div class="mt-2">
73+
{!! make_page($page) !!}
9174
</div>
92-
@endif
93-
{!! make_page($page) !!}
75+
</div>
9476
</div>

‎app/Plugins/Topic/src/Controllers/TagsController.php

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,74 @@ public function data($id)
3636
if (! TopicTag::query()->where('status', '=', null)->where('id', $id)->exists()) {
3737
return admin_abort('页面不存在', 404);
3838
}
39-
$page = Topic::query()
39+
$page = Topic::query(true)
4040
->where('tag_id', $id)
41+
->where('status', 'publish')
4142
->with('tag', 'user')
42-
->orderBy('id', 'desc')
43+
->orderBy('topping', 'desc')
44+
->orderBy('updated_at', 'desc')
4345
->paginate(get_options('topic_home_num', 15));
46+
if (request()->input('query') === 'hot') {
47+
$page = Topic::query()
48+
->where('tag_id', $id)
49+
->where('status', 'publish')
50+
->with('tag', 'user')
51+
->orderBy('view', 'desc')
52+
->orderBy('id', 'desc')
53+
->paginate(get_options('topic_home_num', 15));
54+
}
55+
if (request()->input('query') === 'publish') {
56+
$page = Topic::query()
57+
->where('tag_id', $id)
58+
->where('status', 'publish')
59+
->with('tag', 'user')
60+
->orderBy('id', 'desc')
61+
->paginate(get_options('topic_home_num', 15));
62+
}
63+
if (request()->input('query') === 'essence') {
64+
$page = Topic::query()
65+
->where('tag_id', $id)
66+
->where([['essence', '>', 0], ['status', 'publish']])
67+
->with('tag', 'user')
68+
->orderBy('updated_at', 'desc')
69+
->paginate(get_options('topic_home_num', 15));
70+
}
71+
if (request()->input('query') === 'topping') {
72+
$page = Topic::query()
73+
->where('tag_id', $id)
74+
->where([['topping', '>', 0], ['status', 'publish']])
75+
->with('tag', 'user')
76+
->orderBy('updated_at', 'desc')
77+
->paginate((int) get_options('topic_home_num', 15));
78+
}
4479
$data = TopicTag::query()->where('id', $id)->first();
45-
return view('Topic::Tags.data', ['data' => $data, 'page' => $page]);
80+
$topic_menu = [
81+
[
82+
'name' => '最新发布',
83+
'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">
84+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
85+
<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>
86+
<line x1="8" y1="8" x2="12" y2="8"></line>
87+
<line x1="8" y1="12" x2="12" y2="12"></line>
88+
<line x1="8" y1="16" x2="12" y2="16"></line>
89+
</svg>',
90+
'url' => '/tags/' . $data->id . '.html?' . core_http_build_query(['query' => 'publish'], ['page' => request()->input('page', 1)]),
91+
'parameter' => 'query=publish',
92+
],
93+
[
94+
'name' => __('app.essence'),
95+
'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>',
96+
'url' => '/tags/' . $data->id . '.html?' . core_http_build_query(['query' => 'essence'], ['page' => request()->input('page', 1)]),
97+
'parameter' => 'query=essence',
98+
],
99+
[
100+
'name' => __('app.hot'),
101+
'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>',
102+
'url' => '/tags/' . $data->id . '.html?' . core_http_build_query(['query' => 'hot'], ['page' => request()->input('page', 1)]),
103+
'parameter' => 'query=hot',
104+
],
105+
];
106+
return view('Topic::Tags.data', ['data' => $data, 'page' => $page, 'topic_menu' => $topic_menu]);
46107
}
47108

48109
#[GetMapping(path: '/tags/create')]

‎app/Plugins/User/resources/views/home/comment.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<link rel="stylesheet" href="{{ mix('plugins/Topic/css/app.css') }}">
22
<div class="row row-cards">
33

4-
@php($topics = \App\Plugins\Comment\src\Model\TopicComment::query()->where(['user_id' => $user->id,'status' => 'publish'])->paginate(15))
4+
@php($topics = \App\Plugins\Comment\src\Model\TopicComment::query()->where(['user_id' => $user->id,'status' => 'publish'])->orderByDesc('id')->paginate(15))
55
<div class="col-md-12">
66
<div class="border-0 card card-body">
77
<h3 class="card-title">{{$user->username}} 发布的评论</h3>

‎app/Plugins/User/resources/views/home/topic.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<link rel="stylesheet" href="{{ mix('plugins/Topic/css/app.css') }}">
22
<div class="row row-cards">
33

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

0 commit comments

Comments
 (0)
Please sign in to comment.