koishi-plugin-ets2-tools-tmp 3.3.5 → 3.3.61

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.
package/lib/index.js CHANGED
@@ -67,7 +67,8 @@ exports.inject = {
67
67
 
68
68
  exports.Config = koishi_1.Schema.intersect([
69
69
  koishi_1.Schema.object({
70
- debugMode: koishi_1.Schema.boolean().default(false).description('启用调试模式(输出详细日志)')
70
+ debugMode: koishi_1.Schema.boolean().default(false).description('启用调试模式(输出详细日志)'),
71
+ apiRetryCount: koishi_1.Schema.number().default(2).min(0).max(10).step(1).description('API请求失败时的重试次数(0=不重试,默认2次)')
71
72
  }).description('基本配置'),
72
73
  koishi_1.Schema.object({
73
74
  commands: koishi_1.Schema.object({
@@ -439,7 +440,7 @@ function registerBaseCommands(ctx, cfg) {
439
440
 
440
441
  function apply(ctx, cfg) {
441
442
  // 初始化 API 请求日志(调试模式开启后,truckersmp/trucky 等接口会输出请求与错误日志)
442
- apiLog.init(ctx, cfg.debugMode);
443
+ apiLog.init(ctx, cfg.debugMode, cfg.apiRetryCount);
443
444
 
444
445
  try {
445
446
  model(ctx);
@@ -1,6 +1,6 @@
1
1
  let mapConfig = {
2
2
  ets: {
3
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/ets2/05102019/{z}/{x}/{y}.png',
3
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-ets-yellow/Tiles/{z}/{x}/{y}.png',
4
4
  multipliers: {
5
5
  x: 70272,
6
6
  y: 76157
@@ -26,7 +26,7 @@ let mapConfig = {
26
26
  }
27
27
  },
28
28
  promods: {
29
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/promods/05102019/{z}/{x}/{y}.png',
29
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-promods-yellow/Tiles/{z}/{x}/{y}.png',
30
30
  multipliers: {
31
31
  x: 51953,
32
32
  y: 76024
@@ -121,7 +121,7 @@
121
121
  <script>
122
122
  let mapConfig = {
123
123
  ets: {
124
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/ets2/05102019/{z}/{x}/{y}.png',
124
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-ets-yellow/Tiles/{z}/{x}/{y}.png',
125
125
  multipliers: {
126
126
  x: 70272,
127
127
  y: 76157
@@ -147,7 +147,7 @@
147
147
  }
148
148
  },
149
149
  promods: {
150
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/promods/05102019/{z}/{x}/{y}.png',
150
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-promods-yellow/Tiles/{z}/{x}/{y}.png',
151
151
  multipliers: {
152
152
  x: 51953,
153
153
  y: 76024
@@ -351,6 +351,13 @@
351
351
  width: 100%;
352
352
  height: 180px;
353
353
  border-radius: 0 0 16px 16px;
354
+ /* 未加载到瓦片的区域使用卡片同款深蓝底色,避免白底突兀 */
355
+ background: #0f1439;
356
+ }
357
+
358
+ /* 瓦片暗色化:部分反转(0.6)让底色为浅中灰,色相回转 + 提饱和保持黄色道路鲜亮 */
359
+ .map-section .leaflet-tile-pane {
360
+ filter: invert(0.78) hue-rotate(180deg) saturate(1.35) brightness(2);
354
361
  }
355
362
 
356
363
  /* ===== SPONSOR SECTION ===== */
@@ -585,7 +592,7 @@
585
592
  <script>
586
593
  let mapConfig = {
587
594
  ets: {
588
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/ets2/05102019/{z}/{x}/{y}.png',
595
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-ets-yellow/Tiles/{z}/{x}/{y}.png',
589
596
  multipliers: { x: 70272, y: 76157 },
590
597
  breakpoints: { uk: { x: -31056.8, y: -5832.867 } },
591
598
  bounds: { y: 131072, x: 131072 },
@@ -596,7 +603,7 @@
596
603
  }
597
604
  },
598
605
  promods: {
599
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/promods/05102019/{z}/{x}/{y}.png',
606
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-promods-yellow/Tiles/{z}/{x}/{y}.png',
600
607
  multipliers: { x: 51953, y: 76024 },
601
608
  breakpoints: { uk: { x: -31056.8, y: -5832.867 } },
602
609
  bounds: { y: 131072, x: 131072 },
@@ -774,7 +781,7 @@
774
781
  map.unproject([mapConfig[mapType].bounds.x, 0], mapConfig[mapType].maxZoom)
775
782
  ));
776
783
  L.circleMarker(map.unproject(mapConfig[mapType].calculateMapCoordinate(x, y), 8), {
777
- color: '#2f2f2f', weight: 2, fillColor: '#1cb715', fillOpacity: 1, radius: 5, zIndex: 1000
784
+ color: '#e2e8f0', weight: 2, fillColor: '#22c55e', fillOpacity: 1, radius: 5, zIndex: 1000
778
785
  }).addTo(map);
779
786
  map.setView(map.unproject(mapConfig[mapType].calculateMapCoordinate(x, y), 8), 5);
780
787
  }
@@ -246,7 +246,7 @@
246
246
  <script>
247
247
  let mapConfig = {
248
248
  ets: {
249
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/ets2/05102019/{z}/{x}/{y}.png',
249
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-ets-yellow/Tiles/{z}/{x}/{y}.png',
250
250
  multipliers: { x: 70272, y: 76157 },
251
251
  breakpoints: { uk: { x: -31056.8, y: -5832.867 } },
252
252
  bounds: { y: 131072, x: 131072 },
@@ -256,7 +256,7 @@
256
256
  }
257
257
  },
258
258
  promods: {
259
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/promods/05102019/{z}/{x}/{y}.png',
259
+ tileUrl: 'https://ets_tiles.cnly.top/20260903/tmp-promods-yellow/Tiles/{z}/{x}/{y}.png',
260
260
  multipliers: { x: 51953, y: 76024 },
261
261
  breakpoints: { uk: { x: -31056.8, y: -5832.867 } },
262
262
  bounds: { y: 131072, x: 131072 },
@@ -3,6 +3,11 @@
3
3
  // 请求失败日志始终输出,便于排查接口异常
4
4
  let logger = null
5
5
  let debugMode = false
6
+ let retryCount = 2
7
+
8
+ function sleep(ms) {
9
+ return new Promise(resolve => setTimeout(resolve, ms))
10
+ }
6
11
 
7
12
  // 从异常对象中尽可能提取错误信息(错误名、消息、HTTP 状态码、错误码、底层原因、响应体)
8
13
  // 仅用 e.message 时,网络层异常可能只有空消息(如只显示 "Error"),需补充状态码等上下文
@@ -37,9 +42,10 @@ module.exports = {
37
42
  /**
38
43
  * 初始化(在插件 apply 时调用)
39
44
  */
40
- init(ctx, enabled) {
45
+ init(ctx, enabled, retries) {
41
46
  logger = ctx.logger
42
47
  debugMode = !!enabled
48
+ retryCount = retries != null ? Math.max(0, retries) : 2
43
49
  },
44
50
  /**
45
51
  * 记录调试日志(仅调试模式开启时输出)
@@ -62,28 +68,43 @@ module.exports = {
62
68
  */
63
69
  formatError,
64
70
  /**
65
- * 发起 GET 请求并记录日志,失败时记录含错误码等详细信息的错误日志后抛出异常(由调用方原有 catch 处理)
71
+ * 发起 GET 请求并记录日志,失败时自动重试(重试次数由配置控制),最终失败抛出异常
72
+ * 重试间隔递增:500ms、1000ms、1500ms...
66
73
  */
67
74
  async get(http, tag, url) {
68
75
  if (debugMode && logger) {
69
76
  logger.info(`[TMP-BOT API] [${tag}] GET ${url}`)
70
77
  }
71
- const start = Date.now()
72
- try {
73
- const result = await http.get(url)
74
- if (debugMode && logger) {
75
- logger.info(`[TMP-BOT API] [${tag}] 响应成功, 耗时: ${Date.now() - start}ms`)
76
- }
77
- return result
78
- } catch (e) {
79
- if (logger) {
80
- logger.error(`[TMP-BOT API] [${tag}] 请求失败: ${url} (${formatError(e)})`)
81
- // 调试模式下输出堆栈,便于定位异常来源
82
- if (debugMode && e && e.stack) {
83
- logger.error(`[TMP-BOT API] [${tag}] 堆栈: ${e.stack}`)
78
+ const maxAttempts = retryCount + 1
79
+ let lastError = null
80
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
81
+ const start = Date.now()
82
+ try {
83
+ const result = await http.get(url)
84
+ if (debugMode && logger) {
85
+ logger.info(`[TMP-BOT API] [${tag}] 响应成功, 耗时: ${Date.now() - start}ms${attempt > 1 ? ` (第${attempt}次尝试)` : ''}`)
86
+ }
87
+ return result
88
+ } catch (e) {
89
+ lastError = e
90
+ const isLast = attempt >= maxAttempts
91
+ if (logger) {
92
+ if (isLast) {
93
+ // 最终失败,输出错误日志 + 堆栈
94
+ logger.error(`[TMP-BOT API] [${tag}] 请求失败(已重试${retryCount}次): ${url} (${formatError(e)})`)
95
+ if (debugMode && e && e.stack) {
96
+ logger.error(`[TMP-BOT API] [${tag}] 堆栈: ${e.stack}`)
97
+ }
98
+ } else {
99
+ // 中间失败,输出警告(始终可见,便于观察重试情况)
100
+ logger.warn(`[TMP-BOT API] [${tag}] 第${attempt}/${maxAttempts}次请求失败, 将重试: ${formatError(e)}`)
101
+ }
102
+ }
103
+ if (!isLast) {
104
+ await sleep(500 * attempt)
84
105
  }
85
106
  }
86
- throw e
87
107
  }
108
+ throw lastError
88
109
  }
89
110
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ets2-tools-tmp",
3
3
  "description": "欧卡2 TruckersMP信息查询、车队平台查询及活动提醒",
4
- "version": "3.3.5",
4
+ "version": "3.3.61",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>",
7
7
  "bot_actions <168329908@qq.com>"