We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54bef9c commit 4c9089dCopy full SHA for 4c9089d
client/src/mock/api.ts
@@ -159,12 +159,21 @@ export class MockApiService {
159
160
let items = [...mockAlertsData.items]
161
162
- // 根据state参数过滤数据
+ // 1. 先按时间排序(从新到旧)
163
+ items.sort((a, b) => new Date(b.alertSince).getTime() - new Date(a.alertSince).getTime())
164
+
165
+ // 2. 根据 start 参数筛选数据(分页逻辑)
166
+ if (start) {
167
+ const startTime = new Date(start)
168
+ items = items.filter(alert => new Date(alert.alertSince) <= startTime)
169
+ }
170
171
+ // 3. 根据state参数过滤数据
172
if (state) {
173
items = items.filter(alert => alert.state === state)
174
}
175
- // 根据limit限制返回数量
176
+ // 4. 根据limit限制返回数量
177
if (limit && limit > 0) {
178
items = items.slice(0, limit)
179
0 commit comments