Skip to content

Commit 4bc410e

Browse files
committed
feat: 博客标签数量侧边栏显示数量限制可设置
1 parent 6c82bab commit 4bc410e

File tree

31 files changed

+1706
-1558
lines changed

31 files changed

+1706
-1558
lines changed

env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
APP_ENV=beta
22
APP_DEBUG=true
3-
APP_KEY=4LmYVxyQ0twIjPtNguwEgxDN68oEhBYH
3+
APP_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
4+
ENCRYPT_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
45

56
DB_HOST=localhost
67
DB_PORT=3306

module/Blog/Admin/Controller/ConfigController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function index(AdminConfigBuilder $builder)
3737
})
3838
->defaultValue(BlogDarkModeType::AUTO);
3939
});
40+
$builder->number('Blog_PanelTagLimit', '侧边栏标签数量')->help('0为不限制')->defaultValue(0);
4041
$builder->formClass('wide');
4142
return $builder->perform();
4243
}

module/Blog/Core/MBlog.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,21 @@ public static function getCategory($categoryId)
563563

564564
/**
565565
* @Util 获取所有博客标签信息
566+
* @param $limit int 限制数量,0为不限制
566567
* @return array 数组,标签→数量映射
567568
* @returnExample
568569
* {
569570
* "标签1": 1,
570571
* "标签2": 2
571572
* }
572573
*/
573-
public static function tags()
574+
public static function tags($limit = 0)
574575
{
575-
return BlogTagUtil::all();
576+
$records = BlogTagUtil::all();
577+
if ($limit > 0) {
578+
$records = array_slice($records, 0, $limit);
579+
}
580+
return $records;
576581
}
577582

578583
/**

module/Blog/View/pc/blog/inc/tags.blade.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<div class="ub-content-box margin-bottom">
22
<div class="tw-p-3">
3-
<div class="tw-text-lg">
4-
<i class="iconfont icon-tag"></i>
5-
标签
3+
<div class="tw-flex">
4+
<div class="tw-text-lg tw-flex-grow">
5+
<i class="iconfont icon-tag"></i>
6+
标签
7+
</div>
8+
<div>
9+
<a href="{{modstart_web_url('blog/tags')}}" class="ub-text-muted">
10+
全部
11+
</a>
12+
</div>
613
</div>
714
<div class="tw-mt-4 tw-flex tw-flex-wrap">
8-
@foreach(MBlog::tags() as $t=>$c)
15+
@foreach(MBlog::tags(modstart_config('Blog_PanelTagLimit',0)) as $t=>$c)
916
<a href="{{modstart_web_url('blogs',['keywords'=>$t])}}"
1017
class="hover:tw-shadow ub-content-block tw-block tw-leading-5 tw-mb-2 tw-mr-2 tw-px-2 tw-py-1 tw-rounded-3xl @if(!empty($keywords)&&$keywords==$t) ub-bg-primary @endif">
1118
{{$t}}

module/Vendor/Web/Controller/InstallController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,15 @@ public function prepare()
110110
// 替换.env文件
111111
$envContent = file_get_contents(base_path('env.example'));
112112

113+
$envContent = preg_replace("/APP_DEBUG=(.*?)\\n/", "APP_DEBUG=false\n", $envContent);
113114
$envContent = preg_replace("/DB_HOST=(.*?)\\n/", "DB_HOST=" . $dbHost . "\n", $envContent);
114115
$envContent = preg_replace("/DB_PORT=(.*?)\\n/", "DB_PORT=" . $dbPort . "\n", $envContent);
115116
$envContent = preg_replace("/DB_DATABASE=(.*?)\\n/", "DB_DATABASE=" . $dbDatabase . "\n", $envContent);
116117
$envContent = preg_replace("/DB_USERNAME=(.*?)\\n/", "DB_USERNAME=" . $dbUsername . "\n", $envContent);
117118
$envContent = preg_replace("/DB_PASSWORD=(.*?)\\n/", "DB_PASSWORD=" . $dbPassword . "\n", $envContent);
118119
$envContent = preg_replace("/DB_PREFIX=(.*?)\\n/", "DB_PREFIX=" . $dbPrefix . "\n", $envContent);
119120
$envContent = preg_replace("/APP_KEY=(.*?)\\n/", "APP_KEY=" . RandomUtil::string(32) . "\n", $envContent);
121+
$envContent = preg_replace("/ENCRYPT_KEY=(.*?)\\n/", "ENCRYPT_KEY=" . RandomUtil::string(32) . "\n", $envContent);
120122
if (!empty($installConfig['envs'])) {
121123
foreach ($installConfig['envs'] as $envField) {
122124
$envContent = preg_replace(

public/asset/common/admin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/asset/common/editor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/asset/common/photoswipe.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/asset/common/share.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/asset/entry/basic.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)