koishi-plugin-jscn-aaaquery 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +11 -32
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -51,21 +51,21 @@ function evaluateOpticalPower(power) {
51
51
  }
52
52
  }
53
53
  __name(evaluateOpticalPower, "evaluateOpticalPower");
54
- var CACHE_EXPIRE_TIME = 2 * 60 * 1e3;
54
+ var CACHE_EXPIRE_TIME = 1 * 60 * 1e3;
55
55
  var CACHE_CLEAN_INTERVAL = 60 * 1e3;
56
56
  var CACHE_STATS_RESET_INTERVAL = 24 * 60 * 60 * 1e3;
57
- var QUEUE_EXPIRE_TIME = 2 * 60 * 1e3;
57
+ var QUEUE_EXPIRE_TIME = 1 * 60 * 1e3;
58
58
  var QUEUE_CLEAN_INTERVAL = 30 * 1e3;
59
59
  var MAX_CONCURRENT_REQUESTS = 5;
60
- var MESSAGE_TIMEOUT = 2 * 60 * 1e3;
60
+ var MESSAGE_TIMEOUT = 1 * 60 * 1e3;
61
61
  var MESSAGE_CLEAN_INTERVAL = 60 * 1e3;
62
62
  function apply(ctx, config) {
63
- const CACHE_EXPIRATION = 2 * 60 * 1e3;
64
- const CACHE_CLEANUP_INTERVAL = 10 * 60 * 1e3;
63
+ const CACHE_EXPIRATION = 1 * 60 * 1e3;
64
+ const CACHE_CLEANUP_INTERVAL = 5 * 60 * 1e3;
65
65
  const CACHE_STATS_RESET_INTERVAL2 = 24 * 60 * 60 * 1e3;
66
- const REQUEST_QUEUE_EXPIRATION = 5 * 60 * 1e3;
67
- const REQUEST_QUEUE_CLEANUP_INTERVAL = 10 * 60 * 1e3;
68
- const TOKEN_REFRESH_THRESHOLD = 5 * 60 * 1e3;
66
+ const REQUEST_QUEUE_EXPIRATION = 1 * 60 * 1e3;
67
+ const REQUEST_QUEUE_CLEANUP_INTERVAL = 5 * 60 * 1e3;
68
+ const TOKEN_REFRESH_THRESHOLD = 30 * 60 * 1e3;
69
69
  let currentToken = null;
70
70
  let tokenExpireTime = 0;
71
71
  const requestQueue = {};
@@ -83,7 +83,7 @@ function apply(ctx, config) {
83
83
  const requestWaitQueue = [];
84
84
  const messageQueue = [];
85
85
  let isProcessingMessage = false;
86
- const MESSAGE_TIMEOUT2 = 2 * 60 * 1e3;
86
+ const MESSAGE_TIMEOUT2 = 1 * 60 * 1e3;
87
87
  const MESSAGE_CLEAN_INTERVAL2 = 60 * 1e3;
88
88
  const MAX_QUEUE_LENGTH = 50;
89
89
  function getCacheKey(type, params) {
@@ -309,11 +309,6 @@ function apply(ctx, config) {
309
309
  __name(refreshToken, "refreshToken");
310
310
  async function queryAccount(account) {
311
311
  const formattedAccount = formatAccount(account);
312
- const cachedData = getFromCache("account", { account: formattedAccount });
313
- if (cachedData) {
314
- console.log("使用缓存的账号信息");
315
- return cachedData;
316
- }
317
312
  return addToQueue("account", { account: formattedAccount }, async () => {
318
313
  let retryCount = 0;
319
314
  const maxRetries = 1;
@@ -338,7 +333,6 @@ function apply(ctx, config) {
338
333
  if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
339
334
  if (!response.data.startTime) response.data.startTime = response.data.onlineFailTime || "未知";
340
335
  if (!response.data.nickName) response.data.nickName = response.data.nickName || "未知";
341
- setCache("account", { account: formattedAccount }, response.data);
342
336
  return response.data;
343
337
  }
344
338
  if (response.data.onlineStatus === "离线" || response.data.onlineStatus === "不在线" || response.data.isPass === "原因未知") {
@@ -351,13 +345,11 @@ function apply(ctx, config) {
351
345
  if (!response.data.mac) response.data.mac = "未知";
352
346
  if (!response.data.userIp) response.data.userIp = "未知";
353
347
  if (!response.data.accessDomain) response.data.accessDomain = "未知";
354
- setCache("account", { account: formattedAccount }, response.data);
355
348
  return response.data;
356
349
  }
357
350
  if (!isAccountResponseComplete(response.data)) {
358
351
  throw new Error("账号信息有误,请检查账号是否正确");
359
352
  }
360
- setCache("account", { account: formattedAccount }, response.data);
361
353
  return response.data;
362
354
  }
363
355
  throw new Error(`查询失败:${response.message || "未知错误"}`);
@@ -426,11 +418,6 @@ function apply(ctx, config) {
426
418
  }
427
419
  __name(queryAccountDetail, "queryAccountDetail");
428
420
  async function queryOnuList(mac) {
429
- const cachedData = getFromCache("onuList", { mac });
430
- if (cachedData) {
431
- console.log("使用缓存的设备信息");
432
- return cachedData;
433
- }
434
421
  return addToQueue("onuList", { mac }, async () => {
435
422
  let retryCount = 0;
436
423
  const maxRetries = 1;
@@ -451,12 +438,10 @@ function apply(ctx, config) {
451
438
  const activeOnu = response.data.rows.find((row) => row.status === 1);
452
439
  if (activeOnu) {
453
440
  console.log("找到在线设备:", activeOnu);
454
- setCache("onuList", { mac }, activeOnu);
455
441
  return activeOnu;
456
442
  }
457
443
  const lastOnu = response.data.rows[response.data.rows.length - 1];
458
444
  console.log("没有在线设备,返回最后一条记录:", lastOnu);
459
- setCache("onuList", { mac }, lastOnu);
460
445
  return lastOnu;
461
446
  }
462
447
  throw new Error(`查询失败:${response.message || "未找到设备信息"}`);
@@ -483,11 +468,6 @@ function apply(ctx, config) {
483
468
  }
484
469
  __name(queryOnuList, "queryOnuList");
485
470
  async function queryOnuDetailInfo(onuId) {
486
- const cachedData = getFromCache("onuDetail", { onuId });
487
- if (cachedData) {
488
- console.log("使用缓存的设备详细信息");
489
- return cachedData;
490
- }
491
471
  return addToQueue("onuDetail", { onuId }, async () => {
492
472
  let retryCount = 0;
493
473
  const maxRetries = 1;
@@ -505,7 +485,6 @@ function apply(ctx, config) {
505
485
  });
506
486
  console.log("查询响应:", JSON.stringify(response, null, 2));
507
487
  if (response.status === 200 && response.data) {
508
- setCache("onuDetail", { onuId }, response.data);
509
488
  return response.data;
510
489
  }
511
490
  throw new Error(`查询失败:${response.message || "未知错误"}`);
@@ -1138,7 +1117,7 @@ function apply(ctx, config) {
1138
1117
  `账号: ${input}`,
1139
1118
  `RADIUS状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
1140
1119
  "",
1141
- "⚠️ 账号详细信息查询失败,只显示基本信息",
1120
+ "⚠️ 账号信息查询失败",
1142
1121
  `错误信息: ${accountError.message || "未知错误"}`,
1143
1122
  ""
1144
1123
  ];
@@ -1277,7 +1256,7 @@ function apply(ctx, config) {
1277
1256
  `账号: ${account}`,
1278
1257
  `RADIUS状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
1279
1258
  "",
1280
- "⚠️ 账号详细信息查询失败,只显示基本信息",
1259
+ "⚠️ 账号信息查询失败",
1281
1260
  `错误信息: ${accountError.message || "未知错误"}`,
1282
1261
  ""
1283
1262
  ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-jscn-aaaquery",
3
3
  "description": "江苏有线无锡分公司宽带信息查询插件",
4
- "version": "1.0.14",
4
+ "version": "1.0.15",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [