fix:webui auth ratelimit

This commit is contained in:
手瓜一十雪 committed 2024-05-07 22:04:21 +08:00
1 parent 09eaa3116a
commit 24658edc45
2 files changed
+4 -2

No files matched your search

+3 -1
View File
@@ -22,12 +22,14 @@ let LoginRuntime: LoginRuntimeType = {
}
export const DataRuntime = {
checkLoginRate: async function (RateLimit: number): Promise<boolean> {
LoginRuntime.LoginCurrentRate++;
//console.log(RateLimit, LoginRuntime.LoginCurrentRate, Date.now() - LoginRuntime.LoginCurrentTime);
if (Date.now() - LoginRuntime.LoginCurrentTime > 1000 * 60) {
LoginRuntime.LoginCurrentRate = 0;//超出时间重置限速
LoginRuntime.LoginCurrentTime = Date.now();
return true;
}
if (LoginRuntime.LoginCurrentRate <= RateLimit) {
LoginRuntime.LoginCurrentRate++;
return true;
}
return false;