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.

public/asset/entry/dataFileManager.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/vendor/ueditor/ueditor.all.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.

vendor/modstart/modstart/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.

vendor/modstart/modstart/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.

vendor/modstart/modstart/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.

vendor/modstart/modstart/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.

vendor/modstart/modstart/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.

vendor/modstart/modstart/asset/entry/dataFileManager.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.

vendor/modstart/modstart/asset/vendor/ueditor/ueditor.all.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.

vendor/modstart/modstart/lang/zh/base.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,5 @@
232232
'Examples' => '例子',
233233
'Under Development' => '开发中',
234234
'Price' => '价格',
235+
'%s is default, please change it' => '%s 为默认值,请修改',
235236
];

vendor/modstart/modstart/resources/asset/src/common/admin.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
window._rootWindow = MS.util.getRootWindow();
12
window._pageTabManager = {
23
closeFromTab: function () {
34
if (window == parent.window) {
@@ -16,6 +17,25 @@ window._pageTabManager = {
1617
var tabPageId = window.frameElement.getAttribute("data-tab-page")
1718
window.parent._pageTabManager.updateTitle(tabPageId, title)
1819
},
20+
activeUrl: function (url) {
21+
var $menu = _rootWindow.$('.ub-panel-frame .left .menu');
22+
var normalUrl = _rootWindow._pageTabManager.normalTabUrl(url);
23+
$menu.find('a').each(function (i, o) {
24+
var url = $(o).attr('href');
25+
if (url === 'javascript:;') {
26+
return;
27+
}
28+
if (_rootWindow._pageTabManager.normalTabUrl(url) === normalUrl) {
29+
$(o).parents('.children').prev().addClass('open');
30+
$menu.find('.menu-item').removeClass('active');
31+
$(o).closest('.menu-item').addClass('active');
32+
try {
33+
o.scrollIntoView({block: 'center', behavior: 'smooth'});
34+
} catch (e) {
35+
}
36+
}
37+
});
38+
}
1939
};
2040

2141
$(window).on('load', function () {
@@ -52,6 +72,13 @@ $(window).on('load', function () {
5272
});
5373
}
5474

75+
// 后台Logo
76+
var $logo = $frame.find('.left .logo');
77+
$logo.on('click', function () {
78+
$($menu.find('a')[0]).click();
79+
return false;
80+
});
81+
5582
// 后台菜单搜索
5683
var $menu = $frame.find('.left .menu');
5784
var markText = function (str, indexs) {
@@ -291,6 +318,8 @@ $(window).on('load', function () {
291318
}
292319

293320
this.updateMainPage()
321+
322+
294323
},
295324
open: function (url, title, option) {
296325
option = Object.assign({
@@ -372,16 +401,15 @@ $(window).on('load', function () {
372401
if (!title) {
373402
title = $(this).text();
374403
}
375-
if (window.parent !== window) {
376-
window.parent._pageTabManager.open(url, title)
377-
} else {
378-
tabManager.open(url, title)
379-
}
404+
_rootWindow._pageTabManager.open(url, title, {
405+
focus: function () {
406+
tabManager.activeUrl(url);
407+
}
408+
});
380409
return false;
381410
});
382411
window._pageTabManager = tabManager
383412
} else {
384-
// console.log('page-tabs-disabled')
385413
$adminTabRefresh.remove();
386414
}
387415

vendor/modstart/modstart/resources/asset/src/svue/components/DataSelector.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@
6969
<div class="action">
7070
<a v-if="permission['Delete']"
7171
href="javascript:;" :title="L('Delete')"
72-
:class="{active:listChecked.length>0}"
72+
:class="{active:activeFileOperate}"
7373
@click="doFileDelete">
7474
<i class="iconfont icon-trash"></i>
7575
{{ L('Delete') }}
7676
</a>
7777
<a v-if="permission['Add/Edit']"
7878
href="javascript:;" :title="L('Edit')"
79-
:class="{active:listChecked.length>0}"
79+
:class="{active:activeFileOperate}"
8080
@click="doFileEdit">
8181
<i class="iconfont icon-sign"></i>
8282
{{ L('Edit') }}
@@ -284,20 +284,22 @@ export default {
284284
watch: {
285285
categoryFilter(val) {
286286
this.$refs.$categoryTreeAll.filter(val)
287-
}
287+
},
288288
},
289289
computed: {
290290
apiUrl() {
291291
return this.url + '/' + this.category
292292
},
293293
listChecked() {
294-
return this.records.filter(o => o.checked
295-
)
294+
return this.records.filter(o => o.checked)
296295
},
297296
listCheckedIds() {
298297
return this.listChecked.map(o => o.id
299298
)
300-
}
299+
},
300+
activeFileOperate() {
301+
return this.listChecked.length > 0 && this.listChecked.filter(f => f.id > 0).length === this.listChecked.length
302+
},
301303
},
302304
mounted() {
303305
if ('flat' === this.mode) {
@@ -340,6 +342,9 @@ export default {
340342
Dialog.tipError(this.L('Select %d item(s) at most', this.max))
341343
},
342344
doFileEdit() {
345+
if (!this.activeFileOperate) {
346+
return
347+
}
343348
this.fileEdit.categoryId = this.currentCategoryId
344349
this.fileVisible = true
345350
},
@@ -362,13 +367,12 @@ export default {
362367
})
363368
},
364369
doFileDelete() {
365-
const ids = this.listCheckedIds;
366-
if (ids.length === 0) {
370+
if (!this.activeFileOperate || !this.listCheckedIds.length) {
367371
return;
368372
}
369373
Dialog.confirm(this.L('Confirm Delete ?'), () => {
370374
Dialog.loadingOn()
371-
this.$api.post(this.apiUrl, JsonUtil.extend({id: ids.join(',')}, {action: 'fileDelete'}), res => {
375+
this.$api.post(this.apiUrl, JsonUtil.extend({id: this.listCheckedIds.join(',')}, {action: 'fileDelete'}), res => {
372376
Dialog.loadingOff()
373377
Dialog.tipSuccess(this.L('Delete Success'))
374378
this.doList(1)

0 commit comments

Comments
 (0)