修复判断bug

This commit is contained in:
ZtRXR 2023-09-02 00:38:53 +08:00
parent 56b1a8617f
commit ff40cc6a27

View File

@ -10,14 +10,26 @@ export class HotTopController{
let hours = 1
let rawHours = parseInt(request.query.hours as unknown as string)
if(request.query.hours && !isNaN(rawHours) && rawHours <=24 && rawHours > 0)
if (request.query.hours !=undefined && !isNaN(rawHours) && rawHours <= 24 && rawHours > 0) {
hours = parseInt(request.query.hours as unknown as string)
}
else {
response.status(404)
return "error"
}
yestDay.setHours(nowDate.getHours() - hours)
// console.log(yestDay.toLocaleString())
let limit: number
if(request.query.limit) limit = parseInt(request.query.limit as unknown as string)
if(isNaN(limit) || limit>50 || limit<1) limit = 10
if (request.query.limit == undefined) {
response.status(404)
return "error"
}
limit = Number.parseInt(request.query.limit as string)
if (isNaN(limit) || limit > 50 || limit < 1) {
response.status(404)
return "error"
}
// console.log(limit,hours)
// return "OK"