Feat: login done
This commit is contained in:
51
plays/base.go
Normal file
51
plays/base.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package plays
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.konchin.com/ytshih/inp2025/game/types"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
refreshTick = 100 * time.Millisecond
|
||||
refetchTick = 1 * time.Second
|
||||
)
|
||||
|
||||
func Tick(d time.Duration) tea.Cmd {
|
||||
return tea.Tick(d, func(t time.Time) tea.Msg {
|
||||
return types.TickMsg(t)
|
||||
})
|
||||
}
|
||||
|
||||
type Base struct {
|
||||
client *resty.Client
|
||||
}
|
||||
|
||||
func NewBase(client *resty.Client) *Base {
|
||||
return &Base{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Base) Init() tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Base) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "ctrl+l":
|
||||
return m, tea.ClearScreen
|
||||
case "ctrl+c":
|
||||
return m, tea.Interrupt
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m *Base) View() string {
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user