diff --git a/core/jx3jiaoyihang.py b/core/jx3jiaoyihang.py index ec890a2..98c5573 100644 --- a/core/jx3jiaoyihang.py +++ b/core/jx3jiaoyihang.py @@ -136,14 +136,14 @@ def fetch_jx3_jiaoyihang(inserver="眉间雪", inname="武技殊影图"): if not all_items: logger.error(f"未找到物品: {inname}") - return "无交易行数据" + return "未找到改物品" # 提取所有ID ids = [item.get("id") for item in all_items if item.get("id")] if not ids: logger.error(f"物品 {inname} 没有有效的ID") - return "无交易行数据" + return "未找到改物品" # 返回格式化结果 stringids = ",".join(ids) @@ -161,6 +161,9 @@ def fetch_jx3_jiaoyihang(inserver="眉间雪", inname="武技殊影图"): if not price_data or "data" not in price_data: 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}) diff --git a/main.py b/main.py index c8db2d7..f95d572 100644 --- a/main.py +++ b/main.py @@ -183,15 +183,19 @@ class Jx3ApiPlugin(Star): items_data = fetch_jx3_jiaoyihang(params["server"], params["name"]) 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 + # 加载模板 try: template_content = load_template("jiaoyihang.html") except FileNotFoundError as e: logger.error(f"加载模板失败: {e}") - yield "系统错误:模板文件不存在" + yield event.plain_result("系统错误:模板文件不存在") return # 准备模板渲染数据 @@ -201,22 +205,31 @@ class Jx3ApiPlugin(Star): "update_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S") } - # 渲染为图片 - 可能需要调整选项以适应完整HTML文档 + # 调整渲染图片的尺寸 options = { - "clip": { + "viewport": { + "width": 800, + "height": 600, + "device_scale_factor": 1 # 明确设置设备缩放因子 + }, + "clip": { "x": 0, "y": 0, "width": 800, "height": 600 - } - } + }, + "full_page": False, + "type": "jpeg", + "quality": 85, + "scale": "device" # 尝试使用设备缩放 + } url = await self.html_render(template_content, render_data, options) yield event.image_result(url) except Exception as e: logger.error(f"交易行查询出错: {e}") - yield "查询交易行数据时出错,请稍后再试" + yield event.plain_result("查询交易行数据时出错,请稍后再试") async def terminate(self): """可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。""" diff --git a/templates/jiaoyihang.html b/templates/jiaoyihang.html index d3fcc93..9d45217 100644 --- a/templates/jiaoyihang.html +++ b/templates/jiaoyihang.html @@ -4,104 +4,174 @@ 剑网3交易行价格查询 -

剑网3交易行价格查询

- -
- 共找到 {{ items|length }} 件物品 | 服务器: {{ server }} -
- - - - - - - - - - - {% for item in items %} - - - - - - {% endfor %} - -
物品名称最低价样本数
{{ item.name }}{{ item.price }}{{ item.sample_size }}
- -