Draft: feat login

This commit is contained in:
2025-09-05 03:59:25 +08:00
parent 6d7074198f
commit fd694704be
43 changed files with 2090 additions and 93 deletions

51
plays/base.go Normal file
View 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 ""
}