Skip to content

Commit 7dd34d5

Browse files
committed
blog prev next url fixed
1 parent 3aaa700 commit 7dd34d5

File tree

12 files changed

+102
-7
lines changed

12 files changed

+102
-7
lines changed

module/Blog/Api/Controller/BlogController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public function get()
210210

211211

212212
$recordNext = Blog::published()
213+
->where('id', '>', $record['id'])
213214
->orderBy('id', 'desc')
214215
->limit(1)->first();
215216
if ($recordNext) {
@@ -218,14 +219,15 @@ public function get()
218219
}
219220

220221
$recordPrev = Blog::published()
222+
->where('id', '<', $record['id'])
221223
->orderBy('id', 'asc')
222224
->limit(1)->first();
223225
if ($recordPrev) {
224226
$recordPrev = ArrayUtil::keepKeys($recordPrev->toArray(), ['id', 'title']);
225227
$recordPrev['_url'] = UrlUtil::blog($recordPrev);
226228
}
227229

228-
ModelUtil::increase('blog', $record['id'], 'clickCount');
230+
ModelUtil::increase(Blog::class, $record['id'], 'clickCount');
229231

230232
return Response::generateSuccessData([
231233
'pageTitle' => $record['title'],

module/Blog/Docs/release.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.6.0
2+
3+
- 修复:博客上一篇下一篇链接错误问题
4+
5+
---
6+
17
## 3.5.0 博客公告,二级分类,定时发布
28

39
- 新增:系统公告模块适配,支持博客公告

module/Blog/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"博客"
1919
],
2020
"modstartVersion": ">=4.0.0",
21-
"version": "3.5.0",
21+
"version": "3.6.0",
2222
"author": "ModStart",
2323
"description": "提供一个基础的博客系统",
2424
"suggest": [

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.

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.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml, yaml}]
15+
indent_size = 4
16+
17+
[*.{less, css}]
18+
indent_size = 4
19+
20+
[docker-compose.yml]
21+
indent_size = 4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ window._pageTabManager = {
3737
}
3838
}
3939
});
40+
},
41+
blurUrl: function (url) {
42+
var $menu = _rootWindow.$('.ub-panel-frame .left .menu');
43+
var normalUrl = _rootWindow._pageTabManager.normalTabUrl(url);
44+
$menu.find('a').each(function (i, o) {
45+
var url = $(o).attr('href');
46+
if (url === 'javascript:;') {
47+
return;
48+
}
49+
if (_rootWindow._pageTabManager.normalTabUrl(url) === normalUrl) {
50+
$(o).parents('.menu-item').removeClass('active');
51+
}
52+
});
4053
}
4154
};
4255

@@ -478,6 +491,9 @@ $(window).on('load', function () {
478491
_rootWindow._pageTabManager.open(url, title, {
479492
focus: function () {
480493
tabManager.activeUrl(url);
494+
},
495+
blur: function () {
496+
tabManager.blurUrl(url);
481497
}
482498
});
483499
return false;

vendor/modstart/modstart/src/Core/Dao/ModelUtil.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,41 @@ public static function insertAllSafely($model, $records, $updateTimestamp = true
211211
}
212212
}
213213

214+
/**
215+
* 根据条件新增、更新或删除已有数据
216+
* @param $model string 数据表
217+
* @param $records array 多条数据数组
218+
* @param $where array 条件数组
219+
* @param $keyName string 主键名称,默认为id
220+
* @return array
221+
*/
222+
public static function insertOrUpdateOrDelete($model, $records, $where = [], $idName = 'id')
223+
{
224+
if (empty($records)) {
225+
return $records;
226+
}
227+
$existIds = self::values($model, $idName, $where);
228+
$newIds = array_filter(ArrayUtil::flatItemsByKey($records, $idName));
229+
list($_, $deleteIds) = ArrayUtil::diff($existIds, $newIds);
230+
if (!empty($deleteIds)) {
231+
self::model($model)->where($where)->whereIn($idName, $deleteIds)->delete();
232+
}
233+
foreach ($records as $i => $record) {
234+
foreach ($where as $k => $v) {
235+
$records[$i][$k] = $v;
236+
}
237+
}
238+
foreach ($records as $i => $record) {
239+
if (empty($record[$idName])) {
240+
unset($record[$idName]);
241+
$records[$i][$idName] = self::model($model)->insertGetId($record);
242+
} else {
243+
self::model($model)->where($idName, $record[$idName])->update($record);
244+
}
245+
}
246+
return $records;
247+
}
248+
214249
/**
215250
* 删除记录
216251
* @param $model string 数据表

vendor/modstart/modstart/src/Core/Util/AgentUtil.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public static function isPC()
117117
'/detector/i' => 'Other',
118118

119119
// 其他一些库
120-
'/(curl|python|java|node-fetch|http-client|msray-plus|guzzlehttp|wget|okhttp|scrapy|panelstart|node-superagent|go-camo|https?:\\/\\/)/i' => 'Other',
121-
120+
'/(curl|python|java|node-fetch|http-client|msray-plus|guzzlehttp|wget|okhttp|scrapy|panelstart|node-superagent|go-camo|cpp-httplib|axios|https?:\\/\\/)/i' => 'Other',
121+
'/^(node)$/i' => 'Other',
122122
// 其他一些爬虫
123123
'/(ows.eu|researchscan|github|LogStatistic|Dataprovider|facebook|YandexImages|Iframely|panscient|netcraft|yahoo|censys|Turnitin)/i' => 'Other',
124124
];

0 commit comments

Comments
 (0)