Skip to content

Commit

Permalink
名片支持自定义头像显示
Browse files Browse the repository at this point in the history
  • Loading branch information
IJNKAWAKAZE committed Jun 21, 2024
1 parent cd6f578 commit 50ece3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/core/web/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io"
"log"
"net/http"
"net/url"
"strconv"
"strings"
)
Expand Down Expand Up @@ -129,7 +130,16 @@ func cardData(userId int64, sklandId, uid string) (PlayerCard, error) {
playerCard.Level = playerData.Status.Level
playerCard.RegTime = playerData.Status.RegisterTs
playerCard.MainStageProgress = playerData.StageInfoMap[playerData.Status.MainStageProgress].Code
playerCard.Avatar = playerData.Status.Secretary.SkinID
avatarId := playerData.Status.Avatar.Id
if strings.HasPrefix(avatarId, "char") {
playerCard.Avatar = fmt.Sprintf("https://web.hycdn.cn/arknights/game/assets/char_skin/avatar/%s.png", url.QueryEscape(avatarId))
} else {
// 头像
paintingName := fmt.Sprintf("%s.png", strings.ToUpper(avatarId[:1])+avatarId[1:])
m := utils.Md5(paintingName)
path := "https://media.prts.wiki/thumb" + fmt.Sprintf("/%s/%s/", m[:1], m[:2])
playerCard.Avatar = path + paintingName + "/80px-" + paintingName
}
playerCard.Resume = playerData.Status.Resume
playerCard.CharCnt = len(playerData.Chars)
playerCard.NationList = getNationList(playerData)
Expand Down
2 changes: 1 addition & 1 deletion template/Card.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</div>
<div id="nameCard">
<img style="top: 30px; left: 30px;" src="/assets/card/headicon_back.png"/>
<img id="avatar" src="https://web.hycdn.cn/arknights/game/assets/char_skin/avatar/{{urlquery .Avatar}}.png" onerror="this.src='assets/common/amiya.png'"/>
<img id="avatar" src="{{.Avatar}}" onerror="this.src='assets/common/amiya.png'"/>
<div id="level">
<img style="position: absolute;" src="/assets/card/level_bg.png"/>
<div style="font-size: 20px;padding-top: 8px;">{{.Level}}</div>
Expand Down
2 changes: 1 addition & 1 deletion template/OldCard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<div id="main">
<table id="card" style="border-spacing: 0">
<tr>
<td rowspan="3" style="width: 100px"><img class="avatar" src="https://web.hycdn.cn/arknights/game/assets/char_skin/avatar/{{urlquery .Avatar}}.png" onerror="this.src='assets/common/amiya.png'"/></td>
<td rowspan="3" style="width: 100px"><img class="avatar" src="{{.Avatar}}" onerror="this.src='assets/common/amiya.png'"/></td>
<td colspan="2" style="color: white">{{.Name}}&nbsp&nbsp({{.ServerName}})</td>
</tr>
<tr>
Expand Down

0 comments on commit 50ece3d

Please sign in to comment.