feat: 实现模块3 - TUI翻译显示区

This commit is contained in:
2026-04-06 05:11:23 +08:00
parent 6f872ff285
commit 7321951d05
4 changed files with 74 additions and 13 deletions

View File

@@ -612,9 +612,33 @@ m.textInput.View()
### Lipgloss样式定义
```go
var style = lipgloss.NewStyle().
Foreground(lipgloss.Color("#FAFAFA")).
Background(lipgloss.Color("#1A1A2E"))
var (
headerStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#00D9FF")).
Bold(true)
resultStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#98FB98")).
Background(lipgloss.Color("#0D1B2A"))
helpStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#888888"))
)
```
ti.TextStyle = style // 应用到textinput
### 多区域View渲染
```go
func (m model) View() string {
return "\n" +
" " + headerStyle.Render("YOYO翻译") + "\n" +
" " + divider + "\n\n" +
" " + m.textInput.View() + "\n\n" +
m.renderResult() +
helpText
}
func (m model) renderResult() string {
if m.result == "" {
return " " + helpStyle.Render("翻译结果将显示在这里...") + "\n"
}
return " " + resultStyle.Render(m.result) + "\n"
}
```