feat: add openrouter
This commit is contained in:
@@ -279,7 +279,7 @@ func (m *Model) updateViewportSize() {
|
||||
bodyH := m.bodyHeight()
|
||||
eventH, streamH := m.splitHeights(bodyH)
|
||||
m.viewport.Width = centerW - 2
|
||||
m.viewport.Height = eventH
|
||||
m.viewport.Height = eventH - 1 // -1 为 event panel header 行
|
||||
m.streamVP.Width = centerW - 2
|
||||
m.streamVP.Height = streamH - 1 // -1 为 stream panel header 行
|
||||
}
|
||||
@@ -366,16 +366,16 @@ func (m Model) View() string {
|
||||
centerW := m.width - leftW - rightW
|
||||
eventH, streamH := m.splitHeights(bodyH)
|
||||
|
||||
if m.viewport.Width != centerW-2 || m.viewport.Height != eventH {
|
||||
if m.viewport.Width != centerW-2 || m.viewport.Height != eventH-1 {
|
||||
m.viewport.Width = centerW - 2
|
||||
m.viewport.Height = eventH
|
||||
m.viewport.Height = eventH - 1 // -1 为 event panel header 行
|
||||
}
|
||||
if m.streamVP.Width != centerW-2 || m.streamVP.Height != streamH-1 {
|
||||
m.streamVP.Width = centerW - 2
|
||||
m.streamVP.Height = streamH - 1 // -1 为 stream panel header 行
|
||||
}
|
||||
|
||||
eventFlow := renderEventFlowViewport(m.viewport, centerW, eventH)
|
||||
eventFlow := renderEventFlowViewport(m.viewport, centerW, eventH, !m.focusStream)
|
||||
streamPanel := renderStreamPanel(m.streamVP, centerW, streamH, m.focusStream)
|
||||
center := lipgloss.JoinVertical(lipgloss.Left, eventFlow, streamPanel)
|
||||
|
||||
|
||||
@@ -170,13 +170,30 @@ func renderEventContent(events []app.UIEvent, width int) string {
|
||||
}
|
||||
|
||||
// renderEventFlowViewport 用 viewport 包装渲染事件流面板。
|
||||
func renderEventFlowViewport(vp viewport.Model, width, height int) string {
|
||||
func renderEventFlowViewport(vp viewport.Model, width, height int, focused bool) string {
|
||||
// 标题栏
|
||||
titleColor := colorDim
|
||||
if focused {
|
||||
titleColor = colorAccent
|
||||
}
|
||||
title := lipgloss.NewStyle().Foreground(titleColor).Render("✦ 事件流")
|
||||
lineW := width - lipgloss.Width(title) - 4
|
||||
if lineW < 0 {
|
||||
lineW = 0
|
||||
}
|
||||
separator := lipgloss.NewStyle().Foreground(colorDim).Render(strings.Repeat("─", lineW))
|
||||
header := " " + title + " " + separator
|
||||
|
||||
vpH := height - 1
|
||||
if vpH < 1 {
|
||||
vpH = 1
|
||||
}
|
||||
style := lipgloss.NewStyle().
|
||||
Width(width).
|
||||
Height(height).
|
||||
Height(vpH).
|
||||
Padding(0, 1)
|
||||
|
||||
return style.Render(vp.View())
|
||||
return header + "\n" + style.Render(vp.View())
|
||||
}
|
||||
|
||||
// renderStreamPanel 渲染流式输出面板(中间列下半部分)。
|
||||
|
||||
Reference in New Issue
Block a user