feat(web): Web 界面时间按配置时区显示(默认 Asia/Shanghai),邮件日期 UTC 存储后显示不受影响
- 新增 [web].timezone 配置(IANA 时区或固定偏移,默认 Asia/Shanghai) - 新增 localTime 模板函数;shortDate 的"今天"判断也按展示时区 - view.html 邮件时间改用 localTime 渲染
This commit is contained in:
@@ -39,6 +39,10 @@ type WebConfig struct {
|
||||
// ProtocolLogKeepDays SMTP/IMAP/POP3 协议调用日志保留天数,
|
||||
// 超过该天数的记录会被后台任务自动清理。
|
||||
ProtocolLogKeepDays int `toml:"protocol_log_keep_days"`
|
||||
// Timezone Web 界面显示时间所用的 IANA 时区(如 "Asia/Shanghai")。
|
||||
// 为空时使用服务器本地时区。邮件日期在库中统一为 UTC 存储,
|
||||
// 展示时按此配置转换。
|
||||
Timezone string `toml:"timezone"`
|
||||
}
|
||||
|
||||
// SecretKeyEnvVar 是覆盖会话签名密钥的环境变量名。
|
||||
@@ -212,6 +216,7 @@ func defaultConfig() *Config {
|
||||
Addr: DefaultWebPort,
|
||||
CookieSecure: true,
|
||||
ProtocolLogKeepDays: DefaultProtocolLogKeepDays,
|
||||
Timezone: DefaultTimezone,
|
||||
},
|
||||
SMTP: SMTPConfig{
|
||||
Addr: fmt.Sprintf(":%d", DefaultSMTPPort),
|
||||
@@ -281,6 +286,9 @@ func mergeDefaults(cfg *Config, defaults *Config) *Config {
|
||||
if cfg.Web.ProtocolLogKeepDays == 0 {
|
||||
cfg.Web.ProtocolLogKeepDays = defaults.Web.ProtocolLogKeepDays
|
||||
}
|
||||
if cfg.Web.Timezone == "" {
|
||||
cfg.Web.Timezone = defaults.Web.Timezone
|
||||
}
|
||||
if cfg.SMTP.Addr == "" {
|
||||
cfg.SMTP.Addr = defaults.SMTP.Addr
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ const (
|
||||
// DefaultProtocolLogKeepDays 是 SMTP/IMAP/POP3 协议调用日志的默认保留天数。
|
||||
const DefaultProtocolLogKeepDays = 30
|
||||
|
||||
// DefaultTimezone 是 Web 界面显示时间的默认 IANA 时区(北京时间)。
|
||||
const DefaultTimezone = "Asia/Shanghai"
|
||||
|
||||
// Outbound delivery concurrency defaults.
|
||||
const (
|
||||
// DefaultOutboundWorkers 并发投递 worker 数(0/1 为串行)。
|
||||
|
||||
Reference in New Issue
Block a user