1
This commit is contained in:
@@ -92,7 +92,7 @@ class DeviceManager {
|
||||
/**
|
||||
* 检查是否可以执行操作
|
||||
*/
|
||||
canExecuteOperation(sn_code, operationType) {
|
||||
canExecuteOperation(sn_code, operation_type) {
|
||||
// 检查工作时间
|
||||
if (!config.isWorkingHours()) {
|
||||
return { allowed: false, reason: '不在工作时间内' };
|
||||
@@ -101,8 +101,8 @@ class DeviceManager {
|
||||
// 检查频率限制
|
||||
const device = this.devices.get(sn_code);
|
||||
if (device) {
|
||||
const lastTime = device[`last${operationType.charAt(0).toUpperCase() + operationType.slice(1)}`] || 0;
|
||||
const interval = config.getRateLimit(operationType);
|
||||
const lastTime = device[`last${operation_type.charAt(0).toUpperCase() + operation_type.slice(1)}`] || 0;
|
||||
const interval = config.getRateLimit(operation_type);
|
||||
if (Date.now() - lastTime < interval) {
|
||||
return { allowed: false, reason: '操作过于频繁' };
|
||||
}
|
||||
@@ -114,11 +114,11 @@ class DeviceManager {
|
||||
if (device.dailyCounts.date !== today) {
|
||||
device.dailyCounts = { date: today, searchCount: 0, applyCount: 0, chatCount: 0 };
|
||||
}
|
||||
const countKey = `${operationType}Count`;
|
||||
const countKey = `${operation_type}Count`;
|
||||
const current = device.dailyCounts[countKey] || 0;
|
||||
const max = config.getDailyLimit(operationType);
|
||||
const max = config.getDailyLimit(operation_type);
|
||||
if (current >= max) {
|
||||
return { allowed: false, reason: `今日${operationType}操作已达上限` };
|
||||
return { allowed: false, reason: `今日${operation_type}操作已达上限` };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,12 +128,12 @@ class DeviceManager {
|
||||
/**
|
||||
* 记录操作
|
||||
*/
|
||||
recordOperation(sn_code, operationType) {
|
||||
recordOperation(sn_code, operation_type) {
|
||||
const device = this.devices.get(sn_code) || {};
|
||||
device[`last${operationType.charAt(0).toUpperCase() + operationType.slice(1)}`] = Date.now();
|
||||
device[`last${operation_type.charAt(0).toUpperCase() + operation_type.slice(1)}`] = Date.now();
|
||||
|
||||
if (device.dailyCounts) {
|
||||
const countKey = `${operationType}Count`;
|
||||
const countKey = `${operation_type}Count`;
|
||||
device.dailyCounts[countKey] = (device.dailyCounts[countKey] || 0) + 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user