feat: 实现模块1 - TUI基础框架 (bubbletea)
This commit is contained in:
31
internal/tui/app.go
Normal file
31
internal/tui/app.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"github.com/charmbracelet/bubbletea"
|
||||
"github.com/titor/fanyi/internal/config"
|
||||
"github.com/titor/fanyi/internal/translator"
|
||||
)
|
||||
|
||||
type model struct {
|
||||
config *config.Config
|
||||
translator *translator.Translator
|
||||
}
|
||||
|
||||
func NewApp(cfg *config.Config, t *translator.Translator) *tea.Program {
|
||||
return tea.NewProgram(model{
|
||||
config: cfg,
|
||||
translator: t,
|
||||
})
|
||||
}
|
||||
|
||||
func (m model) Init() tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m model) View() string {
|
||||
return "YOYO翻译 TUI\n\n(基础框架搭建中...)\n"
|
||||
}
|
||||
Reference in New Issue
Block a user