This commit is contained in:
2025-12-19 17:31:49 +08:00
parent 03ca1574d3
commit 204f2ff8a6
5 changed files with 574 additions and 28 deletions
+51 -1
View File
@@ -666,4 +666,54 @@ class JX3Service:
return_data["data"]["list"] = data["data"] return_data["data"]["list"] = data["data"]
return_data["code"] = 200 return_data["code"] = 200
return return_data return return_data
async def zhanji(self, name: str, server:str, mode:str) -> Dict[str, Any]:
"""战绩+名片"""
return_data = self._init_return_data()
# 获取配置中的 Token
token = self._config.get("jx3api_token", "")
if token == "":
return_data["msg"] = "系统未配置API访问Token"
return return_data
# 1. 构造请求参数
params = {"server": server, "name":name, "mode":mode, "token": token}
# 2. 调用基础请求
data: Optional[Dict[str, Any]] = await self._base_request(
"jx3_zhanji", "GET", params=params
)
if not data:
return_data["msg"] = "查询角色战绩失败"
return return_data
logger.info("战绩获取完成")
# 角色名片获取
datamp = await self.jueshemingpian(server,name)
if datamp["code"] == 200:
data["showAvatar"] = datamp['data']['showAvatar']
logger.info("名片获取完成")
else:
data["showAvatar"] = ""
logger.info("名片获取失败")
# 3. 处理返回数据 (直接提取图片 URL)
# 4. 加载模板
try:
return_data["temp"] = load_template("zhanji.html")
except FileNotFoundError as e:
logger.error(f"加载模板失败: {e}")
return_data["msg"] = "系统错误:模板文件不存在"
return return_data
return_data["data"] = data
return_data["code"] = 200
return return_data
+12
View File
@@ -216,5 +216,17 @@
"name": "秃盒", "name": "秃盒",
"token":"" "token":""
} }
},
"jx3_zhanji":{
"url":"https://www.jx3api.com/data/arena/recent",
"method":"GET",
"description":"此接口用于查询角色近期的名剑战绩记录,包括角色基本信息、战绩详情以及比赛趋势。",
"params":{
"server": "梦江南",
"name": "飞翔大野猪",
"mode": "33",
"ticket": "a7fd656a52d747d7830cfa6d686e6030:qsc20001102:kingsoft::sVpKi7nFKzFlbTwtBMTg2w==",
"token":""
}
} }
} }
+16
View File
@@ -372,6 +372,22 @@ class Jx3ApiPlugin(Star):
yield event.plain_result("猪脑过载,请稍后再试") yield event.plain_result("猪脑过载,请稍后再试")
@jx3.command("战绩")
async def jx3_zhanji(self, event: AstrMessageEvent,name: str = "飞翔大野猪", server: str = None, mode:str = "33"):
"""剑三 战绩 角色 服务器 类型"""
try:
data= await self.jx3fun.zhanji(name,await self.serverdefault(server),mode)
if data["code"] == 200:
url = await self.html_render(data["temp"], data["data"], options={})
yield event.image_result(url)
else:
yield event.plain_result(data["msg"])
return
except Exception as e:
logger.error(f"功能函数执行错误: {e}")
yield event.plain_result("猪脑过载,请稍后再试")
async def terminate(self): async def terminate(self):
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。""" """可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
# 关闭数据库连接 # 关闭数据库连接
+246 -27
View File
@@ -1,30 +1,249 @@
<div style="width: 1220px; margin: 0 auto;"> <!DOCTYPE html>
<h1 style="text-align: center;">剑网3交易行价格查询</h1> <html lang="zh-CN">
<p style="text-align: center;">服务器: {{ server }}</p> <head>
<meta charset="UTF-8" />
<title>剑网三 3v3 战绩面板</title>
<div style="overflow-x: auto; overflow-y: hidden;"> <style>
<table style="width: 100%; border-collapse: collapse; margin: 0 auto;"> body {
<thead> margin: 0;
<tr style="height: 50px; text-align: center;"> padding: 20px;
<th style="border:1px solid #000; padding:4px;">物品名称</th> background: #f2f3f7;
<th style="border:1px solid #000; padding:4px;">最低价</th> color: #2b2b2b;
<th style="border:1px solid #000; padding:4px;">总数量</th> font-family: "Microsoft YaHei", Arial, sans-serif;
<th style="border:1px solid #000; padding:4px;">数据更新时间</th> }
</tr>
</thead> .panel {
<tbody> width: 1100px;
{% for item in items %} margin: auto;
<tr style="height: 45px; text-align: center;"> background: #ffffff;
<td style="border:1px solid #000; padding:4px; text-align: left;"> border-radius: 12px;
<img src="{{ item.IconID }}" alt="icon" style="width:20px; height:20px; vertical-align:middle; border-radius:4px; margin-right:6px;"> padding: 22px;
{{ item.Name }} box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
</td> }
<td style="border:1px solid #000; padding:4px;">{{ item.AvgPrice }}</td>
<td style="border:1px solid #000; padding:4px;">{{ item.SampleSize }}</td> /* ===== 头部 ===== */
<td style="border:1px solid #000; padding:4px;">{{ item.Date }}</td> .header {
</tr> display: flex;
{% endfor %} justify-content: space-between;
</tbody> border-bottom: 1px solid #ddd;
</table> padding-bottom: 14px;
}
.role-name {
font-size: 36px;
font-weight: bold;
color: #1f1f1f;
}
.sub-info {
margin-top: 6px;
font-size: 18px;
color: #666;
}
/* ===== 头像 + 核心数据 ===== */
.stats-wrap {
display: flex;
gap: 24px;
margin: 26px 0;
align-items: stretch;
}
/* 头像区域 */
.avatar-box {
width: 280px;
height: 360px;
background: #e9ebf1;
border-radius: 16px;
overflow: hidden;
flex-shrink: 0;
}
.avatar-box img {
width: 100%;
height: 100%;
object-fit: cover;
}
/* 右侧数据 */
.stats {
flex: 1;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 14px;
}
/* 单个数据块 */
.stat-box {
background: #f5f6fa;
border-radius: 12px;
padding: 20px;
text-align: center;
}
.stat-title {
font-size: 26px;
color: #777;
}
.stat-value {
font-size: 36px;
margin-top: 8px;
font-weight: bold;
color: #222;
}
.winrate {
color: #2fbf71;
}
.mmr {
color: #f5a623;
}
/* ===== 表格 ===== */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
font-size: 22px;
}
thead {
background: #f0f1f5;
}
th, td {
padding: 10px;
text-align: center;
}
th {
color: #666;
font-weight: normal;
}
tbody tr:nth-child(even) {
background: #fafbfe;
}
tbody tr:nth-child(odd) {
background: #ffffff;
}
.win {
color: #2fbf71;
font-weight: bold;
}
.lose {
color: #e65050;
font-weight: bold;
}
.mmr-up {
color: #2fbf71;
}
.mmr-down {
color: #e65050;
}
.mvp {
color: #f5a623;
font-weight: bold;
}
</style>
</head>
<body>
<div class="panel">
<!-- 角色信息 -->
<div class="header">
<div>
<div class="role-name">{{ roleName }}</div>
<div class="sub-info">
{{ serverName }} {{ forceName }} {{ campName }} {{ tongName }}
</div>
</div>
<div class="sub-info">
角色ID{{ roleId }}
</div>
</div> </div>
<!-- 头像 + 当前 3v3 表现 -->
<div class="stats-wrap">
<!-- 左侧头像 -->
<div class="avatar-box">
<img src="{{ showAvatar }}" alt="avatar">
</div>
<!-- 右侧数据 -->
<div class="stats">
<div class="stat-box">
<div class="stat-title">名剑积分</div>
<div class="stat-value mmr">{{ performance['3v3'].mmr }}</div>
</div>
<div class="stat-box">
<div class="stat-title">名剑段位</div>
<div class="stat-value">{{ performance['3v3'].grade }}</div>
</div>
<div class="stat-box">
<div class="stat-title">胜率</div>
<div class="stat-value winrate">{{ performance['3v3'].winRate }}%</div>
</div>
<div class="stat-box">
<div class="stat-title">总场数</div>
<div class="stat-value">{{ performance['3v3'].totalCount }}</div>
</div>
<div class="stat-box">
<div class="stat-title">MVP次数</div>
<div class="stat-value">{{ performance['3v3'].mvpCount }}</div>
</div>
</div>
</div>
<!-- 对战记录表 -->
<table>
<thead>
<tr>
<th>对战时长</th>
<th>心法</th>
<th>胜负</th>
<th>积分变化</th>
<th>最终积分</th>
<th>平均段位</th>
<th>MVP</th>
</tr>
</thead>
<tbody>
{% for m in history %}
<tr>
<td>{{ m.endTime - m.startTime }}</td>
<td>{{ m.kungfu }}</td>
<td class="{{ 'win' if m.won else 'lose' }}">{{ '胜' if m.won else '负' }}</td>
<td class="{{ 'mmr-up' if m.mmr > 0 else 'mmr-down' }}">
{{ m.mmr }}
</td>
<td>{{ m.totalMmr }}</td>
<td>{{ m.avgGrade }}</td>
<td class="{{ 'mvp' if m.mvp else '' }}">
{{ '是' if m.mvp else '-' }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div> </div>
</body>
</html>
+249
View File
@@ -0,0 +1,249 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>剑网三 3v3 战绩面板</title>
<style>
body {
margin: 0;
padding: 20px;
background: #f2f3f7;
color: #2b2b2b;
font-family: "Microsoft YaHei", Arial, sans-serif;
}
.panel {
width: 1100px;
margin: auto;
background: #ffffff;
border-radius: 12px;
padding: 22px;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}
/* ===== 头部 ===== */
.header {
display: flex;
justify-content: space-between;
border-bottom: 1px solid #ddd;
padding-bottom: 14px;
}
.role-name {
font-size: 40px;
font-weight: bold;
color: #1f1f1f;
}
.sub-info {
margin-top: 6px;
font-size: 22px;
color: #666;
}
/* ===== 头像 + 核心数据 ===== */
.stats-wrap {
display: flex;
gap: 24px;
margin: 26px 0;
align-items: stretch;
}
/* 头像区域 */
.avatar-box {
width: 280px;
height: 360px;
background: #e9ebf1;
border-radius: 16px;
overflow: hidden;
flex-shrink: 0;
}
.avatar-box img {
width: 100%;
height: 100%;
object-fit: cover;
}
/* 右侧数据 */
.stats {
flex: 1;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 14px;
}
/* 单个数据块 */
.stat-box {
background: #f5f6fa;
border-radius: 12px;
padding: 20px;
text-align: center;
}
.stat-title {
font-size: 26px;
color: #777;
}
.stat-value {
font-size: 36px;
margin-top: 8px;
font-weight: bold;
color: #222;
}
.winrate {
color: #2fbf71;
}
.mmr {
color: #f5a623;
}
/* ===== 表格 ===== */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
font-size: 22px;
}
thead {
background: #f0f1f5;
}
th, td {
padding: 10px;
text-align: center;
}
th {
color: #666;
font-weight: normal;
}
tbody tr:nth-child(even) {
background: #fafbfe;
}
tbody tr:nth-child(odd) {
background: #ffffff;
}
.win {
color: #2fbf71;
font-weight: bold;
}
.lose {
color: #e65050;
font-weight: bold;
}
.mmr-up {
color: #2fbf71;
}
.mmr-down {
color: #e65050;
}
.mvp {
color: #f5a623;
font-weight: bold;
}
</style>
</head>
<body>
<div class="panel">
<!-- 角色信息 -->
<div class="header">
<div>
<div class="role-name">{{ roleName }}</div>
<div class="sub-info">
{{ serverName }} {{ forceName }} {{ campName }} {{ tongName }}
</div>
</div>
<div class="sub-info">
角色ID{{ roleId }}
</div>
</div>
<!-- 头像 + 当前 3v3 表现 -->
<div class="stats-wrap">
<!-- 左侧头像 -->
<div class="avatar-box">
<img src="{{ showAvatar }}" alt="avatar">
</div>
<!-- 右侧数据 -->
<div class="stats">
<div class="stat-box">
<div class="stat-title">名剑积分</div>
<div class="stat-value mmr">{{ performance['3v3'].mmr }}</div>
</div>
<div class="stat-box">
<div class="stat-title">名剑段位</div>
<div class="stat-value">{{ performance['3v3'].grade }}</div>
</div>
<div class="stat-box">
<div class="stat-title">胜率</div>
<div class="stat-value winrate">{{ performance['3v3'].winRate }}%</div>
</div>
<div class="stat-box">
<div class="stat-title">总场数</div>
<div class="stat-value">{{ performance['3v3'].totalCount }}</div>
</div>
<div class="stat-box">
<div class="stat-title">MVP次数</div>
<div class="stat-value">{{ performance['3v3'].mvpCount }}</div>
</div>
</div>
</div>
<!-- 对战记录表 -->
<table>
<thead>
<tr>
<th>对战时长</th>
<th>心法</th>
<th>胜负</th>
<th>积分变化</th>
<th>最终积分</th>
<th>平均段位</th>
<th>MVP</th>
</tr>
</thead>
<tbody>
{% for m in history %}
<tr>
<td>{{ m.endTime - m.startTime }}</td>
<td>{{ m.kungfu }}</td>
<td class="{{ 'win' if m.won else 'lose' }}">{{ '胜' if m.won else '负' }}</td>
<td class="{{ 'mmr-up' if m.mmr > 0 else 'mmr-down' }}">
{{ m.mmr }}
</td>
<td>{{ m.totalMmr }}</td>
<td>{{ m.avgGrade }}</td>
<td class="{{ 'mvp' if m.mvp else '' }}">
{{ '是' if m.mvp else '-' }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>