This commit is contained in:
2025-12-19 10:41:52 +08:00
parent 84e6074af1
commit 157cbd2602
4 changed files with 120 additions and 41 deletions
+10 -11
View File
@@ -235,20 +235,23 @@ class JX3Service:
return return_data return return_data
async def jinjia(self, server: str) -> Dict[str, Any]: async def jinjia(self, server: str, limit:str) -> Dict[str, Any]:
"""区服金价""" """区服金价"""
return_data = self._init_return_data() return_data = self._init_return_data()
params = {"serverName": server} # 获取配置中的 Token
data_list: Optional[List[Dict[str, Any]]] = await self._base_request("aijx3_jinjia", "POST", params=params) token = self._config.get("jx3api_token", "")
if token == "":
return_data["msg"] = "系统未配置API访问Token"
return return_data
params = {"server": server, "limit": limit, "token": token}
data_list: Optional[List[Dict[str, Any]]] = await self._base_request("jx3_jinjia", "GET", params=params)
if not data_list or not isinstance(data_list, list): if not data_list or not isinstance(data_list, list):
return_data["msg"] = "获取接口信息失败或数据格式错误" return_data["msg"] = "获取接口信息失败或数据格式错误"
return return_data return return_data
# 安全处理列表切片
display_data = data_list[:15]
# 加载模板 # 加载模板
try: try:
return_data["temp"] = load_template("jinjia.html") return_data["temp"] = load_template("jinjia.html")
@@ -259,11 +262,7 @@ class JX3Service:
# 准备模板渲染数据 # 准备模板渲染数据
try: try:
return_data["data"] = { return_data["data"]["items"] = data_list
"items": display_data,
"server": server,
"update_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
}
return_data["code"] = 200 return_data["code"] = 200
except Exception as e: except Exception as e:
logger.error(f"jinjia 模板数据准备失败: {e}") logger.error(f"jinjia 模板数据准备失败: {e}")
+10
View File
@@ -196,5 +196,15 @@
"table": 1, "table": 1,
"token":"" "token":""
} }
},
"jx3_jinjia":{
"url":"https://www.jx3api.com/data/trade/demon",
"method":"GET",
"description":"金价比例信息",
"params":{
"server": "梦江南",
"limit": "10",
"token":""
}
} }
} }
+2 -2
View File
@@ -184,10 +184,10 @@ class Jx3ApiPlugin(Star):
@jx3.command("金价") @jx3.command("金价")
async def jx3_jinjia(self, event: AstrMessageEvent,server: str = "梦江南"): async def jx3_jinjia(self, event: AstrMessageEvent,server: str = "梦江南", limit:str = "15"):
"""剑三 金价 服务器""" """剑三 金价 服务器"""
try: try:
data= await self.jx3fun.jinjia(server) data= await self.jx3fun.jinjia(server,limit)
if data["code"] == 200: if data["code"] == 200:
url = await self.html_render(data["temp"], data["data"], options={}) url = await self.html_render(data["temp"], data["data"], options={})
yield event.image_result(url) yield event.image_result(url)
+91 -21
View File
@@ -1,33 +1,103 @@
<div style="width: 1220px; margin: 0 auto;"> <!DOCTYPE html>
<h1 style="text-align: center" id="剑网三金价">剑网三金价</h1> <html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>区服各平台金价</title>
<div style="overflow-x: auto; overflow-y: hidden;"> <style>
<table style="width: 100%; border-collapse: collapse; margin: 0 auto;"> body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
background: #f1f2f6;
margin: 0;
padding: 20px;
}
.container {
max-width: 1300px;
margin: 0 auto;
text-align: center; /* ★ 让容器内标题更自然居中 */
}
h1 {
font-size: 32px;
margin-bottom: 25px;
color: #222;
font-weight: 800;
text-align: center; /* ★ 强制居中 */
}
table {
width: 100%;
border-collapse: collapse;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
margin-top: 10px;
text-align: left; /* 不影响表格内容 */
}
thead {
background: #d93939;
color: white;
font-size: 18px;
}
th, td {
padding: 14px 12px;
border-bottom: 1px solid #eee;
font-size: 16px;
}
tbody tr:hover {
background: #fff2f2;
}
.text-col {
max-width: 360px;
line-height: 1.5em;
word-break: break-word;
font-weight: 600;
color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>区服各平台金价</h1>
<table>
<thead> <thead>
<tr style="height: 60px; text-align: center;"> <tr>
<th style="border:1px solid #000; padding:2px;">时间</th> <th>服务器</th>
{% for item in items %} <th>贴吧</th>
<th style="border:1px solid #000; padding:2px;">{{ item.date }}</th> <th>万宝楼</th>
{% endfor %} <th>dd373</th>
<th>uu898</th>
<th>5173</th>
<th>7881</th>
<th>时间</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr style="height: 50px; text-align: center;"> {% for m in items %}
<td style="border:1px solid #000; padding:2px;">万宝楼</td> <tr>
{% for item in items %} <td>{{ m.server }}</td>
<td style="border:1px solid #000; padding:2px;">{{ item.priceWanbaolou }}</td> <td>{{ m.tieba }}</td>
{% endfor %} <td>{{ m.wanbaolou }}</td>
<td>{{ m.dd373 }}</td>
<td>{{ m.uu898 }}</td>
<td>{{ m.5173 }}</td>
<td>{{ m.7881 }}</td>
<td>{{ m.date }}</td>
</tr> </tr>
<tr style="height: 50px; text-align: center;">
<td style="border:1px solid #000; padding:2px;">贴吧</td>
{% for item in items %}
<td style="border:1px solid #000; padding:2px;">{{ item.priceTieba }}</td>
{% endfor %} {% endfor %}
</tr>
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</body>
</html>