From c8f183fbffcf5c751a37e210ebcc7532bebd0502 Mon Sep 17 00:00:00 2001 From: lcq Date: Sat, 25 Dec 2021 00:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8F=AA=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E6=B7=BB=E5=8A=A0=E4=B8=8E=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/api.js | 16 +++------------- view/scripts/controllers/tags-controller.js | 7 +++---- view/views/tags.html | 4 ++-- 3 files changed, 8 insertions(+), 19 deletions(-) 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 @@
- {{bookmark.title}} - {{bookmark.title}} + {{bookmark.title}} + {{bookmark.title}}