首页只返回最近添加与最近点击
This commit is contained in:
parent
ac1758b8da
commit
c8f183fbff
|
|
@ -281,13 +281,13 @@ module.exports = class extends Base {
|
|||
if (page == 0 && tagId == -1) {
|
||||
let count = await this.model('bookmarks').where(condition).count('id');
|
||||
let totalPages = Math.ceil(count / pageSize);
|
||||
// 按照 2:2:1取数据
|
||||
let length = Math.ceil(pageSize * 2 / 5);
|
||||
// 按照 1:1取数据
|
||||
let length = Math.ceil(pageSize / 2);
|
||||
let bookmarks = await this.model('bookmarks').where(condition).order('createdAt DESC').limit(0, length).select(); // 这个取一半
|
||||
|
||||
// 取最近点击部分数据
|
||||
let cnt = 0;
|
||||
let bookmarks2 = await this.model('bookmarks').where(condition).order('lastClick DESC').limit(0, pageSize * 2).select(); // 这个多取一点,有可能跟上面的重复了
|
||||
let bookmarks2 = await this.model('bookmarks').where(condition).order('lastClick DESC').limit(0, pageSize * 4).select(); // 这个多取一点,有可能跟上面的重复了
|
||||
for (const bookmark of bookmarks2) {
|
||||
let find = bookmarks.find(item => item.id == bookmark.id);
|
||||
if (!find) {
|
||||
|
|
@ -297,16 +297,6 @@ module.exports = class extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
// 取点击次数最多部分
|
||||
let bookmarks3 = await this.model('bookmarks').where(condition).order('clickCount DESC').limit(0, pageSize * 2).select(); // 这个多取一点,有可能跟上面的重复了
|
||||
for (const bookmark of bookmarks3) {
|
||||
let find = bookmarks.find(item => item.id == bookmark.id);
|
||||
if (!find) {
|
||||
bookmarks.push(bookmark);
|
||||
if (bookmarks.length >= pageSize) break;
|
||||
}
|
||||
}
|
||||
|
||||
data = {
|
||||
count,
|
||||
totalPages,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
$scope.bookmarks = [];
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 0;
|
||||
$scope.pageSize = 75;
|
||||
$scope.pageSize = 80;
|
||||
$scope.inputPage = '';
|
||||
$scope.currentTagId = ($stateParams && $stateParams.tagId) || (-1);
|
||||
$scope.editMode = false;
|
||||
|
|
@ -88,10 +88,9 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
clearInterval(id);
|
||||
}
|
||||
}, 10);
|
||||
} else if ($scope.showMode == 'item' && bookmarks.length == $scope.pageSize && $scope.currentTagId == -1) {
|
||||
} else if ($scope.showMode == 'item' && bookmarks.length > $scope.pageSize / 2 && $scope.currentTagId == -1) {
|
||||
$timeout(() => {
|
||||
$("#" + bookmarks[bookmarks.length * 2 / 5 - 1].id).after(`<div class="ui divider" style="width:100%;margin:0px 15px"></div>`);
|
||||
$("#" + bookmarks[bookmarks.length * 4 / 5 - 1].id).after(`<div class="ui divider" style="width:100%;margin:0px 15px"></div>`);
|
||||
$("#" + bookmarks[bookmarks.length / 2 - 1].id).after(`<div class="ui divider" style="width:100%;margin:0px 15px"></div>`);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@
|
|||
<div class="ui five column grid">
|
||||
<div ng-repeat="bookmark in bookmarks" class="column js-costomTag-item" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmark:(!bookmarkNormalHover)}" ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}">
|
||||
<img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="https://favicon.lucq.fun/?url={{bookmark.url}}" err-src="./images/default.ico" style="width: 16px; height: 16px" ng-click="detailBookmark(bookmark);$event.stopPropagation()" />
|
||||
<span ng-if="(currentPage==0) && ($index==0 || $index==pageSize*2/5 || $index==pageSize*4/5)" style="font-weight: bold">{{bookmark.title}}</span>
|
||||
<span ng-if="(currentPage!=0) || ($index!=0 && $index!=pageSize*2/5 && $index!=pageSize*4/5)">{{bookmark.title}}</span>
|
||||
<span ng-if="(currentPage==0) && ($index==0 || $index==pageSize/2)" style="font-weight: bold">{{bookmark.title}}</span>
|
||||
<span ng-if="(currentPage!=0) || ($index!=0 && $index!=pageSize/2)">{{bookmark.title}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider" style="width:100%;margin:14px 15px"></div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue