Skip to content

Commit 56223e5

Browse files
committed
add: 修复详情页加载问题
1 parent a44458d commit 56223e5

File tree

7 files changed

+29
-44
lines changed

7 files changed

+29
-44
lines changed

consts/keymap.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,24 @@ type KeyMap struct {
2323
F1 key.Binding
2424
}
2525

26-
// ShortHelp returns keybindings to be shown in the mini help view. It's part
27-
// of the key.Map interface.
2826
func (k KeyMap) ShortHelp() []key.Binding {
29-
return []key.Binding{
30-
k.Up, k.Down, k.Left, k.Right, k.Tab, k.ShiftTab, k.KeyE, // first column
31-
k.HelpPage, k.SettingPage, k.CtrlQuit, // second column
32-
k.SwitchShowMode,
33-
}
27+
return []key.Binding{}
3428
}
3529

3630
// FullHelp returns keybindings for the expanded help view. It's part of the
3731
// key.Map interface.
3832
func (k KeyMap) FullHelp() [][]key.Binding {
3933
return [][]key.Binding{
40-
{k.Up, k.Down, k.Left, k.Right, k.Tab, k.ShiftTab, k.KeyE, k.KeyQ, k.KeyR, k.UpgradeApp}, // first column
41-
{k.CtrlQuit, k.HelpPage, k.SettingPage, k.SwitchShowMode, k.Space, k.F1}, // second column
34+
{
35+
k.Up, k.Down, k.Left, k.Right,
36+
k.Tab, k.ShiftTab,
37+
k.KeyE, k.KeyQ, k.KeyR,
38+
}, // first column
39+
{
40+
k.CtrlQuit, k.HelpPage, k.SettingPage,
41+
k.UpgradeApp,
42+
k.SwitchShowMode, k.Space, k.F1,
43+
}, // second column
4244
}
4345
}
4446

@@ -52,11 +54,11 @@ func (k KeyMap) FullHelp() [][]key.Binding {
5254
var AppKeyMap = KeyMap{
5355
Up: key.NewBinding(
5456
key.WithKeys("w", "up", "k"),
55-
key.WithHelp("w/↑", "[主题页]移动到上一个"),
57+
key.WithHelp("w/↑", "[主题页]列表上一个"),
5658
),
5759
Down: key.NewBinding(
5860
key.WithKeys("s", "down", "j"),
59-
key.WithHelp("s/↓", "[主题页]列表移动到下一个"),
61+
key.WithHelp("s/↓", "[主题页]列表下一个"),
6062
),
6163
Left: key.NewBinding(
6264
key.WithKeys("a", "left", "h"),
@@ -80,38 +82,38 @@ var AppKeyMap = KeyMap{
8082
),
8183
Tab: key.NewBinding(
8284
key.WithKeys("tab"),
83-
key.WithHelp("tab", "[主题页]切换下一个节点"),
85+
key.WithHelp("tab", "[主题页]下一个节点"),
8486
),
8587
Space: key.NewBinding(
8688
key.WithKeys(" "),
87-
key.WithHelp("空格键", "老板键"),
89+
key.WithHelp("空格", "老板键"),
8890
),
8991
ShiftTab: key.NewBinding(
9092
key.WithKeys("shift+tab"),
91-
key.WithHelp("shift+tab", "[主题页]切换上一个切点"),
93+
key.WithHelp("shift+tab", "[主题页]上一个切点"),
9294
),
9395
CtrlQuit: key.NewBinding(
9496
key.WithKeys("esc", "ctrl+c"),
9597
key.WithHelp("esc", "退出程序"),
9698
),
9799
KeyE: key.NewBinding(
98100
key.WithKeys("e", "enter", "o"),
99-
key.WithHelp("e/enter", "[主题页]查看主题详情"),
101+
key.WithHelp("e/enter", "[主题页]查看主题详情 / [详情页]加载评论"),
100102
),
101103
SwitchShowMode: key.NewBinding(
102104
key.WithKeys("="),
103-
key.WithHelp("=", "[减号]切换底部显示隐藏"),
105+
key.WithHelp("=", "[等于号]切换底部显示隐藏"),
104106
),
105107
KeyR: key.NewBinding(
106108
key.WithKeys("r"),
107-
key.WithHelp("r", "加载图片"),
109+
key.WithHelp("r", "[主题页]切换接口版本 / [详情页]加载图片"),
108110
),
109111
UpgradeApp: key.NewBinding(
110112
key.WithKeys("ctrl+u"),
111113
key.WithHelp("ctrl+u", "更新应用(需要网络可以访问 github)"),
112114
),
113115
F1: key.NewBinding(
114116
key.WithKeys("f1"),
115-
key.WithHelp("f1", "打开详情或者打开配置文件"),
117+
key.WithHelp("f1", "[详情页]打开链接 / [配置页]打开配置文件"),
116118
),
117119
}

consts/showmode.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package consts
22

33
const (
44
ShowModeAll = iota
5-
ShowModeHideHelp
65
ShowModeHideLimit
76
ShowModeHideAll
87
)

model/file.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func (c *FileConfig) GetShowModeText() string {
6161
var (
6262
m = map[int]string{
6363
consts.ShowModeAll: "显示所有",
64-
consts.ShowModeHideHelp: "隐藏帮助",
6564
consts.ShowModeHideLimit: "隐藏请求限制",
6665
consts.ShowModeHideAll: "隐藏所有",
6766
}

pages/detail.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ import (
2828
"github.com/seth-shi/go-v2ex/v2/messages"
2929
)
3030

31-
const (
32-
detailKeyHelp = "[q:返回 e:加载评论 r:加载图片 w/s/鼠标:滑动 a/d:翻页 =:显示页脚]"
33-
)
34-
3531
var (
3632
titleStyle = func() lipgloss.Style {
3733
b := lipgloss.RoundedBorder()
@@ -358,5 +354,5 @@ func (m *detailPage) onDetailResult(detail response.V2DetailResult) tea.Cmd {
358354
}
359355

360356
func (m detailPage) showStatusBarText(firstText string) tea.Cmd {
361-
return commands.Post(messages.ShowStatusBarTextRequest{FirstText: firstText, HelpText: detailKeyHelp})
357+
return commands.Post(messages.ShowStatusBarTextRequest{FirstText: firstText})
362358
}

pages/topics.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"log/slog"
87
"strconv"
98
"strings"
109

@@ -27,8 +26,6 @@ import (
2726
"github.com/dromara/carbon/v2"
2827
)
2928

30-
const keyHelp = "[a/d:翻页 w/s:移动 e:详情 tab/shift+tab:节点 空格:老板键 ?:帮助页 `:设置页 =:显示页脚]"
31-
3229
var (
3330
cellStyle = styles.Primary.Padding(0, 1).Width(5)
3431
headerStyle = styles.Primary.Bold(true).Align(lipgloss.Center)
@@ -146,8 +143,7 @@ func (m topicPage) onSwitchApiMode() tea.Cmd {
146143
conf.ChooseAPIV2 = !conf.ChooseAPIV2
147144
},
148145
)
149-
150-
return messages.ErrorOrToast(err, g.Config.Get().GetShowModeText())
146+
return messages.ErrorOrToast(err, "切换成功: V1 接口信息更多 / V2 接口有分页")
151147
}
152148
}
153149

@@ -171,7 +167,6 @@ func (m topicPage) moveTabs(add int) (tea.Model, tea.Cmd) {
171167
saveTabFn := func() tea.Msg {
172168
return g.Config.Save(
173169
func(conf *model.FileConfig) {
174-
slog.Info("save index")
175170
conf.ActiveTab = g.TabNodeIndex(conf.ActiveTab, add)
176171
},
177172
)
@@ -206,7 +201,6 @@ func (m topicPage) onTopicResult(msgType messages.GetTopicResponse) (tea.Model,
206201
return m, commands.Post(
207202
messages.ShowStatusBarTextRequest{
208203
FirstText: fmt.Sprintf("%s %s", apiText, pageInfo.ToString()),
209-
HelpText: keyHelp,
210204
},
211205
)
212206
}

pages/ui_footer.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ func NewFooter(appVersion string) FooterComponents {
5454
statusbar.ColorConfig{
5555
// 强调区
5656
Foreground: lipgloss.AdaptiveColor{Dark: "#FFFFFF", Light: "#FFFFFF"},
57-
Background: lipgloss.AdaptiveColor{Light: "#636e72", Dark: "#636e72"},
57+
Background: lipgloss.AdaptiveColor{Light: "#005FB8", Dark: "#005FB8"},
5858
},
5959
)
6060

6161
sb.SetContent(
6262
"",
6363
"",
64-
"",
64+
"?查看帮助",
6565
fmt.Sprintf("%s[%s]@%s", consts.AppName, appVersion, consts.AppOwner),
6666
)
6767

@@ -147,7 +147,7 @@ func (m FooterComponents) View() string {
147147
conf = g.Config.Get()
148148
content strings.Builder
149149
w, _ = g.Window.GetSize()
150-
secondText = m.GetSecondColumnContent(conf.ShowHelp())
150+
secondText = m.GetSecondColumnContent()
151151
)
152152

153153
if !conf.ShowFooter() {
@@ -171,13 +171,12 @@ func (m FooterComponents) View() string {
171171

172172
}
173173

174-
func (m FooterComponents) GetSecondColumnContent(showHelp bool) string {
174+
func (m FooterComponents) GetSecondColumnContent() string {
175175
// loadings 是一个 map
176176
var (
177177
loadingKeys = lo.Keys(m.loadings)
178178
loadingIcon = m.spinner.View()
179179
loadingText strings.Builder
180-
secondText string
181180
)
182181
slices.Sort(loadingKeys)
183182

@@ -190,9 +189,5 @@ func (m FooterComponents) GetSecondColumnContent(showHelp bool) string {
190189
},
191190
)
192191

193-
if showHelp {
194-
secondText = m.secondText
195-
}
196-
197-
return styles.Hint.Render(loadingText.String(), secondText)
192+
return styles.Hint.Render(loadingText.String(), m.secondText)
198193
}

pkg/html.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/charmbracelet/glamour"
88
"github.com/charmbracelet/glamour/ansi"
99
"github.com/charmbracelet/glamour/styles"
10-
"github.com/muesli/termenv"
10+
"github.com/charmbracelet/lipgloss"
1111
"golang.org/x/term"
1212
)
1313

@@ -38,7 +38,7 @@ func getDefaultStyle() ansi.StyleConfig {
3838
if !term.IsTerminal(int(os.Stdout.Fd())) {
3939
conf = styles.NoTTYStyleConfig
4040
} else {
41-
if termenv.HasDarkBackground() {
41+
if lipgloss.HasDarkBackground() {
4242
conf = styles.DarkStyleConfig
4343
} else {
4444
conf = styles.LightStyleConfig

0 commit comments

Comments
 (0)