feat: webui login limit

This commit is contained in:
手瓜一十雪
2024-05-06 22:24:27 +08:00
parent fa4a403f38
commit 9471e63857
6 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
let LoginRuntime = {
LoginCurrentTime: Date.now(),
LoginCurrentRate: 0
}
export const Data = {
checkLoginRate: async function (RateLimit: number): Promise<boolean> {
if (Date.now() - LoginRuntime.LoginCurrentTime > 1000 * 60) {
LoginRuntime.LoginCurrentRate = 0;//超出时间重置限速
return true;
}
if (LoginRuntime.LoginCurrentRate <= RateLimit) {
LoginRuntime.LoginCurrentRate++;
return true;
}
return false;
}
}