- 添加邮件详情面板显示(主题、发件人、收件人、抄送、账户、时间、正文) - 优化邮件列表卡片样式,增加选中高亮效果 - 窗口宽度 >= 80 时启用双面板布局,左侧列表右侧详情 - 简化依赖包,从 charm.land 使用统一导入路径 - 删除未使用的 golangci/goreleaser 配置文件
46 lines
829 B
Go
46 lines
829 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"path/filepath"
|
|
|
|
"charm.land/bubbles/v2/list"
|
|
tea "charm.land/bubbletea/v2"
|
|
)
|
|
|
|
type attachment string
|
|
|
|
func (a attachment) FilterValue() string {
|
|
return string(a)
|
|
}
|
|
|
|
type attachmentDelegate struct {
|
|
focused bool
|
|
}
|
|
|
|
func (d attachmentDelegate) Height() int {
|
|
return 1
|
|
}
|
|
|
|
func (d attachmentDelegate) Spacing() int {
|
|
return 0
|
|
}
|
|
|
|
func (d attachmentDelegate) Render(w io.Writer, m list.Model, index int, item list.Item) {
|
|
path := filepath.Base(item.(attachment).FilterValue())
|
|
style := textStyle
|
|
if m.Index() == index && d.focused {
|
|
style = activeTextStyle
|
|
}
|
|
|
|
if m.Index() == index {
|
|
_, _ = w.Write([]byte(style.Render("• " + path)))
|
|
} else {
|
|
_, _ = w.Write([]byte(style.Render(" " + path)))
|
|
}
|
|
}
|
|
|
|
func (d attachmentDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd {
|
|
return nil
|
|
}
|