11
This commit is contained in:
@@ -136,14 +136,14 @@ def fetch_jx3_jiaoyihang(inserver="眉间雪", inname="武技殊影图"):
|
|||||||
|
|
||||||
if not all_items:
|
if not all_items:
|
||||||
logger.error(f"未找到物品: {inname}")
|
logger.error(f"未找到物品: {inname}")
|
||||||
return "无交易行数据"
|
return "未找到改物品"
|
||||||
|
|
||||||
# 提取所有ID
|
# 提取所有ID
|
||||||
ids = [item.get("id") for item in all_items if item.get("id")]
|
ids = [item.get("id") for item in all_items if item.get("id")]
|
||||||
|
|
||||||
if not ids:
|
if not ids:
|
||||||
logger.error(f"物品 {inname} 没有有效的ID")
|
logger.error(f"物品 {inname} 没有有效的ID")
|
||||||
return "无交易行数据"
|
return "未找到改物品"
|
||||||
|
|
||||||
# 返回格式化结果
|
# 返回格式化结果
|
||||||
stringids = ",".join(ids)
|
stringids = ",".join(ids)
|
||||||
@@ -161,6 +161,9 @@ def fetch_jx3_jiaoyihang(inserver="眉间雪", inname="武技殊影图"):
|
|||||||
if not price_data or "data" not in price_data:
|
if not price_data or "data" not in price_data:
|
||||||
return "无交易行数据"
|
return "无交易行数据"
|
||||||
|
|
||||||
|
if not price_data["data"] or (isinstance(price_data["data"], dict) and not price_data["data"]) or (isinstance(price_data["data"], list) and not price_data["data"]):
|
||||||
|
return "无交易行数据"
|
||||||
|
|
||||||
# 第三步:合并数据
|
# 第三步:合并数据
|
||||||
merged_data = merge_item_data_by_itemid(price_data, {"list": all_items})
|
merged_data = merge_item_data_by_itemid(price_data, {"list": all_items})
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,11 @@ class Jx3ApiPlugin(Star):
|
|||||||
items_data = fetch_jx3_jiaoyihang(params["server"], params["name"])
|
items_data = fetch_jx3_jiaoyihang(params["server"], params["name"])
|
||||||
|
|
||||||
if not items_data or items_data == "无交易行数据":
|
if not items_data or items_data == "无交易行数据":
|
||||||
yield f"在服务器【{params['server']}】未找到物品【{params['name']}】的交易行数据"
|
yield event.plain_result(f"在服务器【{params['server']}】未找到物品【{params['name']}】的交易行数据")
|
||||||
|
return
|
||||||
|
|
||||||
|
if not items_data or items_data == "未找到改物品":
|
||||||
|
yield event.plain_result(f"未找到物品【{params['name']}】")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 加载模板
|
# 加载模板
|
||||||
@@ -191,7 +195,7 @@ class Jx3ApiPlugin(Star):
|
|||||||
template_content = load_template("jiaoyihang.html")
|
template_content = load_template("jiaoyihang.html")
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
logger.error(f"加载模板失败: {e}")
|
logger.error(f"加载模板失败: {e}")
|
||||||
yield "系统错误:模板文件不存在"
|
yield event.plain_result("系统错误:模板文件不存在")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 准备模板渲染数据
|
# 准备模板渲染数据
|
||||||
@@ -201,14 +205,23 @@ class Jx3ApiPlugin(Star):
|
|||||||
"update_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
"update_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
}
|
}
|
||||||
|
|
||||||
# 渲染为图片 - 可能需要调整选项以适应完整HTML文档
|
# 调整渲染图片的尺寸
|
||||||
options = {
|
options = {
|
||||||
|
"viewport": {
|
||||||
|
"width": 800,
|
||||||
|
"height": 600,
|
||||||
|
"device_scale_factor": 1 # 明确设置设备缩放因子
|
||||||
|
},
|
||||||
"clip": {
|
"clip": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600
|
"height": 600
|
||||||
}
|
},
|
||||||
|
"full_page": False,
|
||||||
|
"type": "jpeg",
|
||||||
|
"quality": 85,
|
||||||
|
"scale": "device" # 尝试使用设备缩放
|
||||||
}
|
}
|
||||||
|
|
||||||
url = await self.html_render(template_content, render_data, options)
|
url = await self.html_render(template_content, render_data, options)
|
||||||
@@ -216,7 +229,7 @@ class Jx3ApiPlugin(Star):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"交易行查询出错: {e}")
|
logger.error(f"交易行查询出错: {e}")
|
||||||
yield "查询交易行数据时出错,请稍后再试"
|
yield event.plain_result("查询交易行数据时出错,请稍后再试")
|
||||||
|
|
||||||
async def terminate(self):
|
async def terminate(self):
|
||||||
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
||||||
|
|||||||
+112
-42
@@ -4,94 +4,162 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>剑网3交易行价格查询</title>
|
<title>剑网3交易行价格查询</title>
|
||||||
<style>
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
body {
|
body {
|
||||||
font-family: 'Microsoft YaHei', sans-serif;
|
font-family: 'Microsoft YaHei', sans-serif;
|
||||||
width: 700px;
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
||||||
background-color: #f9f9f9;
|
padding: 20px;
|
||||||
padding: 15px;
|
min-height: 100vh;
|
||||||
margin: 0;
|
display: flex;
|
||||||
box-sizing: border-box;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 1280px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.header {
|
.header {
|
||||||
color: #333;
|
background: linear-gradient(135deg, #4a90e2 0%, #2a5298 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 25px 30px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-bottom: 2px solid #4a90e2;
|
}
|
||||||
padding-bottom: 8px;
|
.header h1 {
|
||||||
margin: 0 0 15px 0;
|
font-size: 32px;
|
||||||
font-size: 24px;
|
margin-bottom: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
.server-info {
|
||||||
|
font-size: 18px;
|
||||||
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
.summary {
|
.summary {
|
||||||
background-color: #4a90e2;
|
background-color: #f8f9fa;
|
||||||
color: white;
|
padding: 15px 30px;
|
||||||
padding: 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
color: #495057;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.items-count {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #4a90e2;
|
||||||
|
}
|
||||||
|
.update-time {
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.table-container {
|
||||||
|
padding: 0 30px 30px 30px;
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
background-color: white;
|
margin-top: 20px;
|
||||||
border-radius: 4px;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||||
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-size: 14px;
|
|
||||||
}
|
}
|
||||||
th {
|
th {
|
||||||
background-color: #4a90e2;
|
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
||||||
color: white;
|
color: white;
|
||||||
padding: 8px;
|
padding: 16px 20px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 2px solid #ddd;
|
font-weight: 500;
|
||||||
|
font-size: 16px;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
th:first-child {
|
||||||
|
border-top-left-radius: 8px;
|
||||||
|
}
|
||||||
|
th:last-child {
|
||||||
|
border-top-right-radius: 8px;
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
padding: 8px;
|
padding: 14px 20px;
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #495057;
|
||||||
}
|
}
|
||||||
tr:nth-child(even) {
|
tr:nth-child(even) {
|
||||||
background-color: #f2f2f2;
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
tr:hover {
|
||||||
|
background-color: #e9f7fe;
|
||||||
|
transition: background-color 0.2s;
|
||||||
}
|
}
|
||||||
.item-name {
|
.item-name {
|
||||||
color: #333;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
max-width: 350px;
|
color: #2c3e50;
|
||||||
overflow: hidden;
|
max-width: 500px;
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
.price {
|
.price {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
color: #e74c3c;
|
color: #e74c3c;
|
||||||
font-weight: bold;
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
.sample {
|
.sample {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #7f8c8d;
|
color: #6c757d;
|
||||||
}
|
}
|
||||||
.footer {
|
.footer {
|
||||||
margin-top: 12px;
|
background-color: #343a40;
|
||||||
|
color: #f8f9fa;
|
||||||
|
padding: 15px 30px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #7f8c8d;
|
font-size: 14px;
|
||||||
font-size: 12px;
|
}
|
||||||
|
.highlight {
|
||||||
|
background-color: #fff3cd;
|
||||||
|
}
|
||||||
|
@media (max-width: 1320px) {
|
||||||
|
body {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1280px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1 class="header">剑网3交易行价格查询</h1>
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
<div class="summary">
|
<h1>剑网3交易行价格查询</h1>
|
||||||
共找到 <strong>{{ items|length }}</strong> 件物品 | 服务器: {{ server }}
|
<div class="server-info">服务器: {{ server }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="summary">
|
||||||
|
<div class="items-count">共找到 <strong>{{ items|length }}</strong> 件物品</div>
|
||||||
|
<div class="update-time">数据更新时间: {{ update_time }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-container">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>物品名称</th>
|
<th style="width: 55%;">物品名称</th>
|
||||||
<th style="text-align: right;">最低价</th>
|
<th style="width: 25%; text-align: right;">最低价</th>
|
||||||
<th style="text-align: center;">样本数</th>
|
<th style="width: 20%; text-align: center;">数量</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
<tr>
|
<tr {% if loop.index <= 3 %}class="highlight"{% endif %}>
|
||||||
<td class="item-name">{{ item.name }}</td>
|
<td class="item-name">{{ item.name }}</td>
|
||||||
<td class="price">{{ item.price }}</td>
|
<td class="price">{{ item.price }}</td>
|
||||||
<td class="sample">{{ item.sample_size }}</td>
|
<td class="sample">{{ item.sample_size }}</td>
|
||||||
@@ -99,9 +167,11 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
数据更新时间: {{ update_time }}
|
© 2025 剑网3交易行查询系统 | 数据仅供参考,以游戏内实际价格为准
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
+176
-5
@@ -1,6 +1,177 @@
|
|||||||
<div>
|
<!DOCTYPE html>
|
||||||
<h1>测试页面</h1>
|
<html>
|
||||||
<p>服务器: {{ server }}</p>
|
<head>
|
||||||
<p>物品数量: {{ items|length }}</p>
|
<meta charset="UTF-8">
|
||||||
<p>时间: {{ update_time }}</p>
|
<title>剑网3交易行价格查询</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: 'Microsoft YaHei', sans-serif;
|
||||||
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
||||||
|
padding: 20px;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 1280px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background: linear-gradient(135deg, #4a90e2 0%, #2a5298 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 25px 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.header h1 {
|
||||||
|
font-size: 32px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
.server-info {
|
||||||
|
font-size: 18px;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
.summary {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
padding: 15px 30px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #495057;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.items-count {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #4a90e2;
|
||||||
|
}
|
||||||
|
.update-time {
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.table-container {
|
||||||
|
padding: 0 30px 30px 30px;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 20px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 16px 20px;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 16px;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
th:first-child {
|
||||||
|
border-top-left-radius: 8px;
|
||||||
|
}
|
||||||
|
th:last-child {
|
||||||
|
border-top-right-radius: 8px;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 14px 20px;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #495057;
|
||||||
|
}
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
tr:hover {
|
||||||
|
background-color: #e9f7fe;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
.item-name {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #2c3e50;
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
.price {
|
||||||
|
text-align: right;
|
||||||
|
color: #e74c3c;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.sample {
|
||||||
|
text-align: center;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
background-color: #343a40;
|
||||||
|
color: #f8f9fa;
|
||||||
|
padding: 15px 30px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.highlight {
|
||||||
|
background-color: #fff3cd;
|
||||||
|
}
|
||||||
|
@media (max-width: 1320px) {
|
||||||
|
body {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1280px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>剑网3交易行价格查询</h1>
|
||||||
|
<div class="server-info">服务器: {{ server }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="summary">
|
||||||
|
<div class="items-count">共找到 <strong>{{ items|length }}</strong> 件物品</div>
|
||||||
|
<div class="update-time">数据更新时间: {{ update_time }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-container">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 55%;">物品名称</th>
|
||||||
|
<th style="width: 25%; text-align: right;">最低价</th>
|
||||||
|
<th style="width: 20%; text-align: center;">数量</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in items %}
|
||||||
|
<tr {% if loop.index <= 3 %}class="highlight"{% endif %}>
|
||||||
|
<td class="item-name">{{ item.name }}</td>
|
||||||
|
<td class="price">{{ item.price }}</td>
|
||||||
|
<td class="sample">{{ item.sample_size }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
© 2025 剑网3交易行查询系统 | 数据仅供参考,以游戏内实际价格为准
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user