This commit is contained in:
qsc
2026-01-07 23:17:18 +08:00
parent 98e0d00423
commit d5ffe5c10d
3 changed files with 31 additions and 16 deletions
+1 -6
View File
@@ -1,11 +1,5 @@
# 剑网三数据查询工具 # 剑网三数据查询工具
<div align="center">
![Python Version](https://img.shields.io/badge/Python-3.10.14%2B-blue)
</div>
## 目录 ## 目录
- [剑网三数据查询工具](#-剑网三数据查询工具) - [剑网三数据查询工具](#-剑网三数据查询工具)
@@ -14,6 +8,7 @@
- [更新记录](#-更新记录) - [更新记录](#-更新记录)
- [功能特点](#-功能特点) - [功能特点](#-功能特点)
- [插件配置](#-插件配置) - [插件配置](#-插件配置)
- [使用方式](#-使用方式)
## 简介 ## 简介
+4 -6
View File
@@ -1,6 +1,7 @@
# core/request.py # core/request.py
import json import json
import aiohttp import aiohttp
import asyncio
from typing import Optional, Dict, Any, Union, List from typing import Optional, Dict, Any, Union, List
from aiohttp import ClientTimeout, ClientSession from aiohttp import ClientTimeout, ClientSession
@@ -75,23 +76,20 @@ class APIClient:
"""处理响应:自动识别二进制或JSON""" """处理响应:自动识别二进制或JSON"""
try: try:
logger.debug(f"响应状态: {response.status}") logger.debug(f"响应状态: {response.status}")
response.raise_for_status() # 如果是 4xx/5xx 直接抛出异常 response.raise_for_status()
content_type = response.headers.get('Content-Type', '').lower() content_type = response.headers.get('Content-Type', '').lower()
# 处理二进制流 (图片、文件等)
if 'image' in content_type or 'octet-stream' in content_type: if 'image' in content_type or 'octet-stream' in content_type:
return await response.read() return await response.read()
# 处理 JSON
# 优先尝试标准 json 解析
try: try:
data = await response.json() data = await response.json()
except Exception: except Exception:
# 容错:有些 API 返回 text/html 但内容是 JSON
text = await response.text() text = await response.text()
try: try:
data = json.loads(text) loop = asyncio.get_running_loop()
data = await loop.run_in_executor(None, json.loads, text)
except json.JSONDecodeError: except json.JSONDecodeError:
logger.error(f"无法解析响应为 JSON。原始内容: {text[:100]}...") logger.error(f"无法解析响应为 JSON。原始内容: {text[:100]}...")
return None return None
+26 -4
View File
@@ -102,6 +102,28 @@
color: #d93939; color: #d93939;
font-weight: 700; font-weight: 700;
} }
/* ===== 万宝楼公示(蓝色) ===== */
.table-card.notice .table-title {
color: #1e6bd6;
}
.table-card.notice .price-col {
color: #1e6bd6;
}
.table-card.notice thead {
background: #1e6bd6;
}
/* ===== 万宝楼在售(绿色) ===== */
.table-card.sale .table-title {
color: #2e8b57;
}
.table-card.sale .price-col {
color: #2e8b57;
}
.table-card.sale thead {
background: #2e8b57;
}
</style> </style>
</head> </head>
@@ -123,7 +145,7 @@
<div class="table-wrapper"> <div class="table-wrapper">
<!-- 1 万宝楼公示 --> <!-- 1 万宝楼公示 -->
<div class="table-card"> <div class="table-card notice">
<div class="table-title">万宝楼公示</div> <div class="table-title">万宝楼公示</div>
<table> <table>
<thead> <thead>
@@ -140,7 +162,7 @@
<td class="server-col">{{ item.date }}</td> <td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td> <td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td> <td class="price-col">{{ item.value }}</td>
<td class="server-col"> 公示 </td> <td class="server-col">公示</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@@ -148,7 +170,7 @@
</div> </div>
<!-- 2 万宝楼在售 --> <!-- 2 万宝楼在售 -->
<div class="table-card"> <div class="table-card sale">
<div class="table-title">万宝楼在售</div> <div class="table-title">万宝楼在售</div>
<table> <table>
<thead> <thead>
@@ -165,7 +187,7 @@
<td class="server-col">{{ item.date }}</td> <td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td> <td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td> <td class="price-col">{{ item.value }}</td>
<td class="server-col"> 在售 </td> <td class="server-col">在售</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>