修复网页端编码问题

This commit is contained in:
2026-06-02 20:46:59 +08:00
parent 59719586a1
commit c7f466c99b
6 changed files with 31 additions and 7 deletions
+4
View File
@@ -10,6 +10,7 @@ import (
"strings"
"mail_go/config"
"mail_go/internal/mailutil"
"mail_go/internal/storage"
"mail_go/internal/store"
"mail_go/internal/web/handlers"
@@ -73,6 +74,9 @@ func templateFuncs() template.FuncMap {
"formatBytes": func(b int64) string {
return formatBytes(b)
},
"decodeHeader": func(s string) string {
return mailutil.DecodeRFC2047(s)
},
}
}
+1 -1
View File
@@ -35,7 +35,7 @@
</div>
<h2>{{if .message.Subject}}{{.message.Subject}}{{else}}(无主题){{end}}</h2>
<div class="mail-meta" style="margin-top:12px;">
<p><strong>发件人:</strong> {{.message.FromAddr}}</p>
<p><strong>发件人:</strong> {{decodeHeader .message.FromAddr}}</p>
<p><strong>收件人:</strong> {{.message.ToAddr}}</p>
{{if .message.CcAddr}}<p><strong>抄送:</strong> {{.message.CcAddr}}</p>{{end}}
<p><strong>所属用户:</strong> {{if .message.User.ID}}{{.message.User.Username}}{{else}}—{{end}}</p>
+1 -1
View File
@@ -46,7 +46,7 @@
<tbody>
{{range .messages}}
<tr style="cursor:pointer;" onclick="location.href='/admin/mails/{{.ID}}'">
<td>{{.FromAddr}}</td>
<td>{{decodeHeader .FromAddr}}</td>
<td>{{.ToAddr}}</td>
<td>{{.Subject}}</td>
<td>{{if .User.ID}}{{.User.Username}}{{else}}—{{end}}</td>
+1 -1
View File
@@ -36,7 +36,7 @@
<tbody>
{{range .messages}}
<tr class="{{if not .IsRead}}unread{{end}}">
<td>{{.FromAddr}}</td>
<td>{{decodeHeader .FromAddr}}</td>
<td>
<a href="/inbox/{{.ID}}" class="message-subject">
{{if .Subject}}{{.Subject}}{{else}}(无主题){{end}}
+2 -2
View File
@@ -34,7 +34,7 @@
</div>
<h2>{{if .message.Subject}}{{.message.Subject}}{{else}}(无主题){{end}}</h2>
<div class="mail-meta" style="margin-top:12px;">
<p><strong>发件人:</strong> {{.message.FromAddr}}</p>
<p><strong>发件人:</strong> {{decodeHeader .message.FromAddr}}</p>
<p><strong>收件人:</strong> {{.message.ToAddr}}</p>
{{if .message.CcAddr}}<p><strong>抄送:</strong> {{.message.CcAddr}}</p>{{end}}
<p><strong>时间:</strong> {{.message.Date.Format "2006-01-02 15:04:05"}}</p>
@@ -62,7 +62,7 @@
onsubmit="return confirm('确定要删除这封邮件吗?');">
<button type="submit" class="btn btn-danger">删除邮件</button>
</form>
<a href="/compose?to={{.message.FromAddr}}&subject={{if .message.Subject}}Re: {{.message.Subject}}{{end}}" class="btn btn-primary" style="margin-left:8px;">回复</a>
<a href="/compose?to={{decodeHeader .message.FromAddr}}&subject={{if .message.Subject}}Re: {{.message.Subject}}{{end}}" class="btn btn-primary" style="margin-left:8px;">回复</a>
</div>
</div>
</div>