koishi-plugin-maichuni-scorehelper 0.0.10-test → 0.0.11-test

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.
@@ -288,7 +288,16 @@ class MaimaiStatus extends koishi_1.Service {
288
288
  */
289
289
  async fetchHeartbeats() {
290
290
  try {
291
- const data = await this.ctx.http.get(this.API_URL);
291
+ let data = await this.ctx.http.get(this.API_URL);
292
+ // 如果不是对象,尝试解析 JSON (因为 Object.keys 打印出了索引,说明是字符串)
293
+ if (typeof data === 'string') {
294
+ try {
295
+ data = JSON.parse(data);
296
+ }
297
+ catch {
298
+ return null;
299
+ }
300
+ }
292
301
  // 返回原始对象,包含 heartbeatList 和 uptimeList
293
302
  return data || {};
294
303
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-maichuni-scorehelper",
3
- "version": "0.0.10-test",
3
+ "version": "0.0.11-test",
4
4
  "description": "一个基础的 Koishi 插件,未来用于舞萌中二节奏分数辅助。",
5
5
  "keywords": [
6
6
  "koishi",
@@ -346,7 +346,17 @@ export class MaimaiStatus extends Service {
346
346
  */
347
347
  private async fetchHeartbeats(): Promise<any> {
348
348
  try {
349
- const data = await this.ctx.http.get(this.API_URL)
349
+ let data = await this.ctx.http.get(this.API_URL)
350
+
351
+ // 如果不是对象,尝试解析 JSON (因为 Object.keys 打印出了索引,说明是字符串)
352
+ if (typeof data === 'string') {
353
+ try {
354
+ data = JSON.parse(data)
355
+ } catch {
356
+ return null
357
+ }
358
+ }
359
+
350
360
  // 返回原始对象,包含 heartbeatList 和 uptimeList
351
361
  return data || {}
352
362
  } catch (e) {