SychO Thanks for your help. As you suggested, I modify then request like this,
oncreate(vnode) {
const currentDate = new Date(); // 获取当前日期和时间
const oneWeekAgo = new Date(currentDate.getTime() - 7 * 24 * 60 * 60 * 1000); // 一周前的日期
oneWeekAgo.setHours(0, 0, 0, 0);
const limitHotDisc = app.forum.attribute('justoverclock-hot-discussions.discLimit') || 10;
const filterDiscussions = app.forum.attribute('justoverclock-hot-discussions.hideClosed') === "1" ? '-is:locked' : '';
const formattedDate = oneWeekAgo.toISOString().split('T')[0];
const hotDisc = app.store
.find('discussions', {
sort: '-commentCount',
filter: {
q: filterDiscussions,
created: `${formattedDate}..`, // 一周前以后的帖子
},
page: { limit: limitHotDisc },
})
.then((results) => {
this.hotDisc = results;
this.loading = false;
m.redraw();
});
}
But the query result still contains the data before the create date.
{
"links": {
"first": "http://test.nodeloc.com/api/discussions?sort=-commentCount&filter%5Bq%5D=&filter%5Bcreated%5D=2024-02-09..2024-02-17&page%5Blimit%5D=10",
"next": "http://test.nodeloc.com/api/discussions?sort=-commentCount&filter%5Bq%5D=&filter%5Bcreated%5D=2024-02-09..2024-02-17&page%5Blimit%5D=10&page%5Boffset%5D=10"
},
"data": [
{
"type": "discussions",
"id": "64",
"attributes": {
"title": "Test code highlight.",
"slug": "64-test-code-highlight",
"commentCount": 3,
"participantCount": 1,
"createdAt": "2024-02-15T12:22:34+08:00",
"lastPostedAt": "2024-02-17T02:14:17+08:00",
"lastPostNumber": 3,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": false,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "42"
}
}
}
},
{
"type": "discussions",
"id": "61",
"attributes": {
"title": "1111111111111111111111111",
"slug": "61-1111111111111111111111111",
"commentCount": 2,
"participantCount": 1,
"createdAt": "2024-02-03T10:52:56+08:00",
"lastPostedAt": "2024-02-03T10:58:13+08:00",
"lastPostNumber": 2,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "38"
}
}
}
},
{
"type": "discussions",
"id": "58",
"attributes": {
"title": "TTTT001",
"slug": "58-tttt001",
"commentCount": 2,
"participantCount": 1,
"createdAt": "2024-02-02T22:46:12+08:00",
"lastPostedAt": "2024-02-03T10:47:55+08:00",
"lastPostNumber": 2,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "34"
}
}
}
},
{
"type": "discussions",
"id": "57",
"attributes": {
"title": "最少100个人。。。。。。。。。。。 ",
"slug": "57-100",
"commentCount": 2,
"participantCount": 2,
"createdAt": "2024-02-02T15:43:28+08:00",
"lastPostedAt": "2024-02-02T16:01:49+08:00",
"lastPostNumber": 2,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "2"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "32"
}
}
}
},
{
"type": "discussions",
"id": "63",
"attributes": {
"title": "test code.",
"slug": "63-test-code",
"commentCount": 1,
"participantCount": 1,
"createdAt": "2024-02-14T22:58:06+08:00",
"lastPostedAt": "2024-02-14T22:58:06+08:00",
"lastPostNumber": 1,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": false,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "41"
}
}
}
},
{
"type": "discussions",
"id": "62",
"attributes": {
"title": "22222222222222222",
"slug": "62-22222222222222222",
"commentCount": 1,
"participantCount": 1,
"createdAt": "2024-02-03T10:58:40+08:00",
"lastPostedAt": "2024-02-03T10:58:40+08:00",
"lastPostNumber": 1,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "40"
}
}
}
},
{
"type": "discussions",
"id": "60",
"attributes": {
"title": "测试一下抽奖",
"slug": "60",
"commentCount": 1,
"participantCount": 1,
"createdAt": "2024-02-03T10:52:07+08:00",
"lastPostedAt": "2024-02-03T10:52:07+08:00",
"lastPostNumber": 1,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": false,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "37"
}
}
}
},
{
"type": "discussions",
"id": "59",
"attributes": {
"title": "435234",
"slug": "59-435234",
"commentCount": 1,
"participantCount": 1,
"createdAt": "2024-02-02T23:42:14+08:00",
"lastPostedAt": "2024-02-02T23:42:14+08:00",
"lastPostNumber": 1,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "2"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "2"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "35"
}
}
}
},
{
"type": "discussions",
"id": "56",
"attributes": {
"title": "最少100人,不然就流产。",
"slug": "56-100",
"commentCount": 1,
"participantCount": 1,
"createdAt": "2024-02-02T15:39:43+08:00",
"lastPostedAt": "2024-02-02T15:39:43+08:00",
"lastPostNumber": 1,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "31"
}
}
}
},
{
"type": "discussions",
"id": "52",
"attributes": {
"title": "回复一个,卖得贵。",
"slug": "52",
"commentCount": 1,
"participantCount": 1,
"createdAt": "2024-02-02T04:13:41+08:00",
"lastPostedAt": "2024-02-02T04:13:41+08:00",
"lastPostNumber": 1,
"canReply": false,
"canRename": false,
"canDelete": false,
"canHide": false,
"isApproved": true,
"canTag": false,
"hasLottery": true,
"canStartLottery": false,
"subscription": null,
"isSticky": false,
"canSticky": false,
"isLocked": false,
"canLock": false
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1"
}
},
"lastPostedUser": {
"data": {
"type": "users",
"id": "1"
}
},
"tags": {
"data": [
{
"type": "tags",
"id": "1"
}
]
},
"firstPost": {
"data": {
"type": "posts",
"id": "28"
}
}
}
}
],
Any mistake in my codes? Thanks again.