feat: 实现模块3 - TUI翻译显示区
This commit is contained in:
32
memory.md
32
memory.md
@@ -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"
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user