koishi-plugin-tmp-bot 1.21.2 → 1.21.4

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.
@@ -197,13 +197,13 @@ function normalizeHistory(playerHistory) {
197
197
 
198
198
  if (!playerHistory || playerHistory.length === 0) return [];
199
199
 
200
- // 手动解析时间字符串,避免不同环境下 Date 解析行为不一致
200
+ // API 返回的是北京时间(UTC+8),用 Date.UTC 生成时间戳再减去8小时偏移
201
201
  function parseTime(str) {
202
202
  const [datePart, timePart] = str.trim().replace('T', ' ').split(' ');
203
203
  const [y, m, d] = datePart.split('-').map(Number);
204
204
  const parts = timePart.split(':').map(Number);
205
205
  const h = parts[0] || 0, min = parts[1] || 0;
206
- return new Date(y, m - 1, d, h, min, 0).getTime();
206
+ return Date.UTC(y, m - 1, d, h, min, 0) - 8 * 3600000;
207
207
  }
208
208
 
209
209
  const now = Date.now();
@@ -238,12 +238,15 @@ function createServerCard(server) {
238
238
  if (server.collisionsEnable === 1) {
239
239
  featuresHTML += '<span class="feature">💥 碰撞</span>';
240
240
  }
241
- if (server.afkEnable === 1) {
241
+ if (server.afkEnable === 0) {
242
242
  featuresHTML += '<span class="feature">💤 挂机</span>';
243
243
  }
244
244
  if (server.policeCarEnable === 1) {
245
245
  featuresHTML += '<span class="feature">🚓 警车</span>';
246
246
  }
247
+ if (server.speedLimiterEnable === 1) {
248
+ featuresHTML += '<span class="feature">🐢 限速</span>';
249
+ }
247
250
 
248
251
  // 队列
249
252
  let queueText = '';
@@ -285,45 +288,6 @@ function setData(apiData) {
285
288
 
286
289
  listEl.innerHTML = '';
287
290
 
288
- // === DEBUG: 诊断信息输出到页面 ===
289
- const debugEl = document.createElement('div');
290
- debugEl.id = 'debug-info';
291
- debugEl.style.cssText = 'color:#0f0;font-size:11px;padding:6px 10px;background:#111;margin:4px 10px;border-radius:4px;font-family:monospace;white-space:pre-wrap;';
292
- listEl.appendChild(debugEl);
293
-
294
- const dbg = [];
295
- dbg.push('now=' + Date.now() + ' new Date=' + new Date().toISOString());
296
- dbg.push('timezone=' + Intl.DateTimeFormat().resolvedOptions().timeZone);
297
- dbg.push('offset(min)=' + new Date().getTimezoneOffset());
298
-
299
- const first = servers[0];
300
- if (first && first.playerHistory && first.playerHistory.length > 0) {
301
- const sample = first.playerHistory[0];
302
- dbg.push('sample.updateTime=' + JSON.stringify(sample.updateTime));
303
- const replaced = sample.updateTime.replace(' ', 'T');
304
- dbg.push('replaced=' + replaced);
305
- dbg.push('new Date(str).getTime()=' + new Date(replaced).getTime());
306
- dbg.push('new Date(str)=' + new Date(replaced).toISOString());
307
-
308
- // 手动解析
309
- const [datePart, timePart] = sample.updateTime.trim().replace('T', ' ').split(' ');
310
- const [y, m, d] = datePart.split('-').map(Number);
311
- const parts = timePart.split(':').map(Number);
312
- const h = parts[0] || 0, min = parts[1] || 0;
313
- const manualTs = new Date(y, m - 1, d, h, min, 0).getTime();
314
- dbg.push('manual parse: y=' + y + ' m=' + m + ' d=' + d + ' h=' + h + ' min=' + min);
315
- dbg.push('manualTs=' + manualTs + ' ISO=' + new Date(manualTs).toISOString());
316
-
317
- // normalizeHistory 结果
318
- const normalized = normalizeHistory(first.playerHistory);
319
- const nonZero = normalized.filter(v => v !== 0);
320
- dbg.push('normalized.len=' + normalized.length + ' nonZero=' + nonZero.length);
321
- dbg.push('first5=' + JSON.stringify(normalized.slice(0, 5)));
322
- dbg.push('last5=' + JSON.stringify(normalized.slice(-5)));
323
- }
324
- debugEl.innerText = dbg.join('\n');
325
- // === END DEBUG ===
326
-
327
291
  servers.forEach(server => {
328
292
  listEl.appendChild(createServerCard(server));
329
293
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-tmp-bot",
3
3
  "description": "欧洲卡车模拟2 TMP查询插件,不会部署的可以直接使用此机器人->QQ:3523283907",
4
- "version": "1.21.2",
4
+ "version": "1.21.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",