diff --git a/src/controller/api.js b/src/controller/api.js index b294ba9..f2a23f0 100644 --- a/src/controller/api.js +++ b/src/controller/api.js @@ -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, diff --git a/view/scripts/controllers/tags-controller.js b/view/scripts/controllers/tags-controller.js index 86605b3..335ce68 100644 --- a/view/scripts/controllers/tags-controller.js +++ b/view/scripts/controllers/tags-controller.js @@ -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(`
`); - $("#" + bookmarks[bookmarks.length * 4 / 5 - 1].id).after(``); + $("#" + bookmarks[bookmarks.length / 2 - 1].id).after(``); }, 100); } diff --git a/view/views/tags.html b/view/views/tags.html index cbb01ca..e09be22 100644 --- a/view/views/tags.html +++ b/view/views/tags.html @@ -100,8 +100,8 @@