Compare commits
17 Commits
v0.8.2
...
v0.0.1-tes
| Author | SHA1 | Date | |
|---|---|---|---|
| d327bedf04 | |||
| 8c5eff79cc | |||
| 0ba6df60b0 | |||
| 1733d7b1cc | |||
| a4f3f1fef3 | |||
| 9b0a5dcb4c | |||
| 15759ec42d | |||
| 6fbf9a68cf | |||
| cdf661734f | |||
| 4b12c90e50 | |||
| a3bc91bdaf | |||
| 1d12134314 | |||
| cd90a9c1b3 | |||
| 60c9f99525 | |||
| aded7dba33 | |||
| 917002834c | |||
| b04092fd68 |
56
.gitea/workflows/release.yaml
Normal file
56
.gitea/workflows/release.yaml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: golang:1.26-alpine
|
||||||
|
env:
|
||||||
|
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
run: |
|
||||||
|
apk add git
|
||||||
|
git clone -b dev https://hub.gaomia.site/titor/yoyo.git project
|
||||||
|
cp -r project/* .
|
||||||
|
cp -r project/.* . 2>/dev/null || true
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
for p in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
|
||||||
|
os=${p%/*}
|
||||||
|
arch=${p#*/}
|
||||||
|
ext=""
|
||||||
|
[ "$os" = "windows" ] && ext=".exe"
|
||||||
|
GOOS=$os GOARCH=$arch go build -buildvcs=false -o "yoo-${os}-${arch}${ext}" ./cmd/yoyo
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Checksums
|
||||||
|
run: sha256sum yoo-* > checksums.txt
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.release_token }}
|
||||||
|
run: |
|
||||||
|
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
||||||
|
|
||||||
|
# 创建 Release
|
||||||
|
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/yoyo/releases" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"Automated release\"}"
|
||||||
|
|
||||||
|
# 上传产物
|
||||||
|
for f in yoo-* checksums.txt; do
|
||||||
|
[ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/yoyo/releases/upload?name=${TAG_NAME}" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-F "attachment=@$f"
|
||||||
|
done
|
||||||
29
changelog.md
29
changelog.md
@@ -441,4 +441,31 @@ yoyo onboard --force
|
|||||||
- View() 方法返回 `tea.View` 类型
|
- View() 方法返回 `tea.View` 类型
|
||||||
- KeyMsg 改为 KeyPressMsg,使用 `msg.String()` 判断键位
|
- KeyMsg 改为 KeyPressMsg,使用 `msg.String()` 判断键位
|
||||||
|
|
||||||
**讨论记录**: [taolun.md#版本-0.8.1-翻译结果卡片组件设计](taolun.md#版本-081---翻译结果卡片组件设计)
|
**讨论记录**: [taolun.md#版本-0.8.1-翻译结果卡片组件设计](taolun.md#版本-081---翻译结果卡片组件设计)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v1.0.0-beta (2026-04-07)
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
- ASCII艺术Logo标题,带紫色→粉色渐变效果
|
||||||
|
- 输入框改造:
|
||||||
|
- 使用 `:::` 紫色分隔符替代上下边框
|
||||||
|
- Ctrl+J 换行功能
|
||||||
|
- 信息栏改造:
|
||||||
|
- 合并显示:语言、模型名、缓存记录数
|
||||||
|
- 添加翻译状态 Spinner 动画 (MiniDot)
|
||||||
|
- 翻译结果卡片优化:
|
||||||
|
- 底部 `▣` 图标左侧边距从3减少到2
|
||||||
|
- `▣` 与文字间距从3减少到2
|
||||||
|
|
||||||
|
### 技术细节
|
||||||
|
- 使用 lipgloss 实现 True Color 渐变效果
|
||||||
|
- 使用 charmbracelet/bubbles spinner 组件实现加载动画
|
||||||
|
- 版本号显示在Logo右侧 [v1.0.0-beta]
|
||||||
|
- 动态调整 viewport 高度适应终端
|
||||||
|
|
||||||
|
### 版本号规则
|
||||||
|
- 版本号需与 git 标签、changelog.md 中的版本号保持三方同步
|
||||||
|
|
||||||
|
**讨论记录**: [taolun.md#版本-100-beta-Logo和信息栏改造](taolun.md#版本-100-beta-logo和信息栏改造)
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "1.0.0"
|
Version = "1.0.0-beta"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DetectLanguage(text string) string {
|
func DetectLanguage(text string) string {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ type Translator struct {
|
|||||||
cache cache.Cache
|
cache cache.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Translator) GetCache() cache.Cache {
|
||||||
|
return t.cache
|
||||||
|
}
|
||||||
|
|
||||||
// NewTranslator 创建翻译器实例
|
// NewTranslator 创建翻译器实例
|
||||||
func NewTranslator(config *config.Config, provider provider.Provider) *Translator {
|
func NewTranslator(config *config.Config, provider provider.Provider) *Translator {
|
||||||
translator := &Translator{
|
translator := &Translator{
|
||||||
|
|||||||
@@ -3,19 +3,27 @@ package tui
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"charm.land/bubbles/v2/spinner"
|
||||||
"charm.land/bubbles/v2/textarea"
|
"charm.land/bubbles/v2/textarea"
|
||||||
"charm.land/bubbles/v2/viewport"
|
"charm.land/bubbles/v2/viewport"
|
||||||
"charm.land/bubbletea/v2"
|
"charm.land/bubbletea/v2"
|
||||||
"charm.land/lipgloss/v2"
|
"charm.land/lipgloss/v2"
|
||||||
"github.com/titor/fanyi/internal/config"
|
"github.com/titor/fanyi/internal/config"
|
||||||
|
"github.com/titor/fanyi/internal/content"
|
||||||
"github.com/titor/fanyi/internal/translator"
|
"github.com/titor/fanyi/internal/translator"
|
||||||
)
|
)
|
||||||
|
|
||||||
var supportedLangs = []string{"zh-CN", "en-US", "ja", "ko", "zh-TW", "es", "fr", "de"}
|
var supportedLangs = []string{"zh-CN", "en-US", "ja", "ko", "zh-TW", "es", "fr", "de"}
|
||||||
|
|
||||||
|
var logoPattern = "l_ _ _____ _____ " + "\n" +
|
||||||
|
"( \\/ ( _ ( _ ) " + "\n" +
|
||||||
|
" \\ / )(_)( )(_)( " + "\n" +
|
||||||
|
" (__)(_____(_____((() [v" + content.Version + "]"
|
||||||
|
|
||||||
type translateMsg struct {
|
type translateMsg struct {
|
||||||
result string
|
result string
|
||||||
tokens int
|
tokens int
|
||||||
@@ -29,6 +37,7 @@ type model struct {
|
|||||||
messages []ChatMessage
|
messages []ChatMessage
|
||||||
input textarea.Model
|
input textarea.Model
|
||||||
viewport viewport.Model
|
viewport viewport.Model
|
||||||
|
spinner spinner.Model
|
||||||
keys KeyMap
|
keys KeyMap
|
||||||
|
|
||||||
targetLang string
|
targetLang string
|
||||||
@@ -45,25 +54,31 @@ func NewApp(cfg *config.Config, t *translator.Translator) *tea.Program {
|
|||||||
keys := NewKeyMap()
|
keys := NewKeyMap()
|
||||||
|
|
||||||
ta := textarea.New()
|
ta := textarea.New()
|
||||||
ta.Placeholder = "输入要翻译的文本... (Ctrl+J 换行)"
|
ta.Placeholder = "在这里输入你要翻译的内容。(Enter 翻译,Ctrl+J 启用换行)"
|
||||||
ta.Focus()
|
ta.Focus()
|
||||||
ta.Prompt = ""
|
ta.Prompt = ""
|
||||||
ta.ShowLineNumbers = false
|
ta.ShowLineNumbers = false
|
||||||
ta.SetWidth(60)
|
ta.SetWidth(60)
|
||||||
ta.SetHeight(5)
|
ta.SetHeight(5)
|
||||||
ta.SetStyles(textarea.DefaultStyles(false))
|
ta.SetStyles(textarea.DefaultStyles(true))
|
||||||
|
|
||||||
|
ta.KeyMap.InsertNewline.SetKeys("ctrl+j")
|
||||||
ta.KeyMap.InsertNewline.SetEnabled(true)
|
ta.KeyMap.InsertNewline.SetEnabled(true)
|
||||||
|
|
||||||
vp := viewport.New(viewport.WithWidth(50), viewport.WithHeight(20))
|
vp := viewport.New(viewport.WithWidth(50), viewport.WithHeight(20))
|
||||||
vp.SetContent("")
|
vp.SetContent("")
|
||||||
|
|
||||||
|
sp := spinner.New()
|
||||||
|
sp.Spinner = spinner.MiniDot
|
||||||
|
sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("#8B5CF6"))
|
||||||
|
|
||||||
return tea.NewProgram(model{
|
return tea.NewProgram(model{
|
||||||
config: cfg,
|
config: cfg,
|
||||||
translator: t,
|
translator: t,
|
||||||
messages: make([]ChatMessage, 0),
|
messages: make([]ChatMessage, 0),
|
||||||
input: ta,
|
input: ta,
|
||||||
viewport: vp,
|
viewport: vp,
|
||||||
|
spinner: sp,
|
||||||
keys: keys,
|
keys: keys,
|
||||||
targetLang: getDefaultLang(cfg),
|
targetLang: getDefaultLang(cfg),
|
||||||
})
|
})
|
||||||
@@ -77,7 +92,7 @@ func getDefaultLang(cfg *config.Config) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Init() tea.Cmd {
|
func (m model) Init() tea.Cmd {
|
||||||
return nil
|
return m.spinner.Tick
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
@@ -135,6 +150,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.viewport, cmd = m.viewport.Update(msg)
|
m.viewport, cmd = m.viewport.Update(msg)
|
||||||
cmds = append(cmds, cmd)
|
cmds = append(cmds, cmd)
|
||||||
|
|
||||||
|
m.spinner, cmd = m.spinner.Update(msg)
|
||||||
|
cmds = append(cmds, cmd)
|
||||||
|
|
||||||
return m, tea.Batch(cmds...)
|
return m, tea.Batch(cmds...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,34 +231,24 @@ func (m *model) updateViewportContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *model) renderTranslationCard(msg ChatMessage) string {
|
func (m *model) renderTranslationCard(msg ChatMessage) string {
|
||||||
metaContent := lipgloss.JoinHorizontal(
|
contentWidth := m.viewport.Width() - 2
|
||||||
lipgloss.Left,
|
|
||||||
CardMetaStyle.Render(fmt.Sprintf("Tokens: %d", msg.Tokens)),
|
|
||||||
CardMetaSeparatorStyle,
|
|
||||||
CardMetaStyle.Render(fmt.Sprintf("耗时: %s", msg.Timestamp.Format("15:04:05"))),
|
|
||||||
CardMetaSeparatorStyle,
|
|
||||||
CardMetaStyle.Render(fmt.Sprintf("模型: %s", msg.Model)),
|
|
||||||
)
|
|
||||||
|
|
||||||
metaBlock := lipgloss.NewStyle().
|
timeStr := msg.Timestamp.Format("15:04")
|
||||||
BorderStyle(lipgloss.Border{
|
timeLabel := CardTimeStyle.Render("# " + timeStr)
|
||||||
Top: "─",
|
|
||||||
Bottom: "─",
|
|
||||||
Left: "│",
|
|
||||||
Right: "│",
|
|
||||||
}).
|
|
||||||
BorderForeground(lipgloss.Color("#374151")).
|
|
||||||
Width(m.viewport.Width() - 2).
|
|
||||||
Render(metaContent)
|
|
||||||
|
|
||||||
inputContent := lipgloss.NewStyle().
|
inputText := lipgloss.NewStyle().
|
||||||
Width(m.viewport.Width() - 2).
|
Width(contentWidth).
|
||||||
Render(msg.Input)
|
Render(msg.Input)
|
||||||
|
|
||||||
inputBlock := lipgloss.NewStyle().
|
inputBlock := lipgloss.NewStyle().
|
||||||
Background(lipgloss.Color("#1A1A1A")).
|
Background(lipgloss.Color("#1A1A1A")).
|
||||||
|
Padding(1, 3).
|
||||||
Width(m.viewport.Width()).
|
Width(m.viewport.Width()).
|
||||||
Render(inputContent)
|
Render(lipgloss.JoinVertical(
|
||||||
|
lipgloss.Top,
|
||||||
|
timeLabel,
|
||||||
|
inputText,
|
||||||
|
))
|
||||||
|
|
||||||
var outputBlock string
|
var outputBlock string
|
||||||
if msg.Error != "" {
|
if msg.Error != "" {
|
||||||
@@ -249,6 +257,7 @@ func (m *model) renderTranslationCard(msg ChatMessage) string {
|
|||||||
Render(msg.Error)
|
Render(msg.Error)
|
||||||
outputBlock = lipgloss.NewStyle().
|
outputBlock = lipgloss.NewStyle().
|
||||||
Foreground(lipgloss.Color("#F87171")).
|
Foreground(lipgloss.Color("#F87171")).
|
||||||
|
Padding(0, 3, 1, 3).
|
||||||
Width(m.viewport.Width()).
|
Width(m.viewport.Width()).
|
||||||
Render(outputContent)
|
Render(outputContent)
|
||||||
} else {
|
} else {
|
||||||
@@ -256,16 +265,25 @@ func (m *model) renderTranslationCard(msg ChatMessage) string {
|
|||||||
Width(m.viewport.Width() - 2).
|
Width(m.viewport.Width() - 2).
|
||||||
Render(msg.Output)
|
Render(msg.Output)
|
||||||
outputBlock = lipgloss.NewStyle().
|
outputBlock = lipgloss.NewStyle().
|
||||||
|
Padding(0, 3, 1, 3).
|
||||||
Width(m.viewport.Width()).
|
Width(m.viewport.Width()).
|
||||||
Render(outputContent)
|
Render(outputContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footerContent := lipgloss.NewStyle().
|
||||||
|
MarginLeft(3).
|
||||||
|
Render(lipgloss.JoinHorizontal(
|
||||||
|
lipgloss.Left,
|
||||||
|
CardFooterIconStyle.Render("▣"),
|
||||||
|
CardFooterTextStyle.Render(msg.Model+" · "+strconv.Itoa(msg.Tokens)),
|
||||||
|
))
|
||||||
|
|
||||||
return CardStyle.Render(
|
return CardStyle.Render(
|
||||||
lipgloss.JoinVertical(
|
lipgloss.JoinVertical(
|
||||||
lipgloss.Top,
|
lipgloss.Top,
|
||||||
metaBlock,
|
|
||||||
inputBlock,
|
inputBlock,
|
||||||
outputBlock,
|
outputBlock,
|
||||||
|
footerContent,
|
||||||
),
|
),
|
||||||
) + "\n"
|
) + "\n"
|
||||||
}
|
}
|
||||||
@@ -285,19 +303,55 @@ func (m model) View() tea.View {
|
|||||||
header := m.renderHeader()
|
header := m.renderHeader()
|
||||||
messages := m.viewport.View()
|
messages := m.viewport.View()
|
||||||
inputArea := m.renderInputArea()
|
inputArea := m.renderInputArea()
|
||||||
statusBar := m.renderStatusBar()
|
infoBar := m.renderInfoBar()
|
||||||
|
spinnerView := m.renderSpinner()
|
||||||
|
|
||||||
content := header + "\n" + messages + inputArea + statusBar
|
content := header + "\n" + messages + inputArea + infoBar + spinnerView
|
||||||
v := tea.NewView(content)
|
v := tea.NewView(content)
|
||||||
v.AltScreen = true
|
v.AltScreen = true
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gradientText(text string, startColor, endColor string) string {
|
||||||
|
startR, startG, startB := parseHexColor(startColor)
|
||||||
|
endR, endG, endB := parseHexColor(endColor)
|
||||||
|
|
||||||
|
lines := strings.Split(text, "\n")
|
||||||
|
if len(lines) == 0 {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
var result []string
|
||||||
|
for _, line := range lines {
|
||||||
|
if len(line) == 0 {
|
||||||
|
result = append(result, line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var coloredLine string
|
||||||
|
for i, char := range line {
|
||||||
|
ratio := float64(i) / float64(len(line)-1)
|
||||||
|
r := int(float64(startR) + float64(endR-startR)*ratio)
|
||||||
|
g := int(float64(startG) + float64(endG-startG)*ratio)
|
||||||
|
b := int(float64(startB) + float64(endB-startB)*ratio)
|
||||||
|
coloredLine += fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, string(char))
|
||||||
|
}
|
||||||
|
result = append(result, coloredLine)
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(result, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseHexColor(hex string) (int, int, int) {
|
||||||
|
hex = strings.TrimPrefix(hex, "#")
|
||||||
|
r, _ := strconv.ParseInt(hex[0:2], 16, 64)
|
||||||
|
g, _ := strconv.ParseInt(hex[2:4], 16, 64)
|
||||||
|
b, _ := strconv.ParseInt(hex[4:6], 16, 64)
|
||||||
|
return int(r), int(g), int(b)
|
||||||
|
}
|
||||||
|
|
||||||
func (m model) renderHeader() string {
|
func (m model) renderHeader() string {
|
||||||
title := lipgloss.NewStyle().
|
title := gradientText(logoPattern, "#8B5CF6", "#EC4899")
|
||||||
Foreground(lipgloss.Color("#8B5CF6")).
|
|
||||||
Bold(true).
|
|
||||||
Render("✦ YOYO 翻译")
|
|
||||||
|
|
||||||
width := m.width - 4
|
width := m.width - 4
|
||||||
if width < 20 {
|
if width < 20 {
|
||||||
@@ -310,57 +364,50 @@ func (m model) renderHeader() string {
|
|||||||
|
|
||||||
return lipgloss.NewStyle().
|
return lipgloss.NewStyle().
|
||||||
Width(width).
|
Width(width).
|
||||||
Render(title + strings.Repeat(" ", width-len(title)-len(right)-1) + right)
|
Render(title + strings.Repeat(" ", width-29-len(right)-1) + right)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) renderInputArea() string {
|
func (m model) renderInputArea() string {
|
||||||
inputView := m.input.View()
|
inputView := m.input.View()
|
||||||
|
separator := lipgloss.NewStyle().
|
||||||
container := lipgloss.NewStyle().
|
Foreground(lipgloss.Color("#8B5CF6")).
|
||||||
Width(m.input.Width() + 1).
|
Render(":::")
|
||||||
BorderStyle(lipgloss.Border{
|
return "\n" + separator + "\n" + inputView + "\n"
|
||||||
Top: "─",
|
|
||||||
Bottom: "─",
|
|
||||||
Left: "│",
|
|
||||||
Right: "│",
|
|
||||||
}).
|
|
||||||
BorderForeground(lipgloss.Color("#60A5FA"))
|
|
||||||
|
|
||||||
return "\n" + container.Render(inputView) + "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) renderStatusBar() string {
|
func (m model) renderInfoBar() string {
|
||||||
langInfo := "目标: " + m.targetLang
|
var recordCount int
|
||||||
modelInfo := "模型: " + getModelName(m.config)
|
if m.translator != nil && m.translator.GetCache() != nil {
|
||||||
tokensInfo := "Tokens: -"
|
stats, _ := m.translator.GetCache().Stats(context.Background())
|
||||||
if len(m.messages) > 0 {
|
if stats != nil {
|
||||||
lastMsg := m.messages[len(m.messages)-1]
|
recordCount = stats.TotalRecords
|
||||||
if lastMsg.Tokens > 0 {
|
|
||||||
tokensInfo = fmt.Sprintf("Tokens: %d", lastMsg.Tokens)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statusDot := StatusDotStyle.Render("●")
|
var countInfo string
|
||||||
|
if recordCount == 0 {
|
||||||
|
countInfo = "暂无记录"
|
||||||
|
} else {
|
||||||
|
countInfo = fmt.Sprintf("%d条", recordCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
sep := lipgloss.NewStyle().Foreground(lipgloss.Color("#8B5CF6")).Render(" ")
|
||||||
|
separator := lipgloss.NewStyle().Foreground(lipgloss.Color("#8B5CF6")).Render(":::")
|
||||||
|
lang := lipgloss.NewStyle().Foreground(lipgloss.Color("#F87171")).Render(m.targetLang)
|
||||||
|
model := lipgloss.NewStyle().Foreground(lipgloss.Color("#FAFAFA")).Render(getModelName(m.config))
|
||||||
|
count := lipgloss.NewStyle().Foreground(lipgloss.Color("#6B7280")).Render(countInfo)
|
||||||
|
|
||||||
|
result := separator + sep + lang + sep + model + sep + count
|
||||||
|
|
||||||
if m.loading {
|
if m.loading {
|
||||||
statusDot = LoadingStyle.Render("○")
|
result += sep + m.spinner.View() + " 翻译中..."
|
||||||
}
|
}
|
||||||
|
|
||||||
sep := StatusItemStyle.Render(" │ ")
|
return result + "\n"
|
||||||
|
}
|
||||||
|
|
||||||
width := m.width - 4
|
func (m model) renderSpinner() string {
|
||||||
if width < 30 {
|
return ""
|
||||||
width = 60
|
|
||||||
}
|
|
||||||
|
|
||||||
status := StatusItemStyle.Render(langInfo) +
|
|
||||||
sep + StatusItemStyle.Render(modelInfo) +
|
|
||||||
sep + StatusItemStyle.Render(tokensInfo) +
|
|
||||||
sep + statusDot + " " + StatusValueStyle.Render(m.getStatusText())
|
|
||||||
|
|
||||||
return lipgloss.NewStyle().
|
|
||||||
Width(width).
|
|
||||||
Background(lipgloss.Color("#1F2937")).
|
|
||||||
Render(" " + status)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) getStatusText() string {
|
func (m model) getStatusText() string {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ var (
|
|||||||
Foreground(lipgloss.Color("#34D399"))
|
Foreground(lipgloss.Color("#34D399"))
|
||||||
|
|
||||||
CardStyle = lipgloss.NewStyle().
|
CardStyle = lipgloss.NewStyle().
|
||||||
MarginBottom(5)
|
MarginBottom(1)
|
||||||
|
|
||||||
CardMetaStyle = lipgloss.NewStyle().
|
CardMetaStyle = lipgloss.NewStyle().
|
||||||
Foreground(lipgloss.Color("#6B7280")).
|
Foreground(lipgloss.Color("#6B7280")).
|
||||||
@@ -68,4 +68,17 @@ var (
|
|||||||
|
|
||||||
CardOutputStyle = lipgloss.NewStyle().
|
CardOutputStyle = lipgloss.NewStyle().
|
||||||
Foreground(lipgloss.Color("#FFFFFF"))
|
Foreground(lipgloss.Color("#FFFFFF"))
|
||||||
|
|
||||||
|
CardTimeStyle = lipgloss.NewStyle().
|
||||||
|
Foreground(lipgloss.Color("#6B7280")).
|
||||||
|
MarginBottom(1)
|
||||||
|
|
||||||
|
CardFooterIconStyle = lipgloss.NewStyle().
|
||||||
|
Foreground(lipgloss.Color("#8B5CF6")).
|
||||||
|
AlignVertical(lipgloss.Center)
|
||||||
|
|
||||||
|
CardFooterTextStyle = lipgloss.NewStyle().
|
||||||
|
Foreground(lipgloss.Color("#6B7280")).
|
||||||
|
MarginLeft(2).
|
||||||
|
AlignVertical(lipgloss.Center)
|
||||||
)
|
)
|
||||||
|
|||||||
38
taolun.md
38
taolun.md
@@ -758,4 +758,40 @@ ta.SetHeight(5) // 固定高度,不动态调整
|
|||||||
**下一步**: 实现组件代码
|
**下一步**: 实现组件代码
|
||||||
|
|
||||||
**关联文档**:
|
**关联文档**:
|
||||||
- [changelog.md#0.8.1](changelog.md#081)
|
- [changelog.md#0.8.1](changelog.md#081)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### [2026-04-07] 版本 1.0.0-beta - Logo和信息栏改造
|
||||||
|
|
||||||
|
**原因**: 用户希望改进TUI界面的视觉效果,使标题更独特,输入框和信息栏更美观
|
||||||
|
|
||||||
|
**分析**:
|
||||||
|
- 原标题 "✦ YOYO 翻译" 过于简单
|
||||||
|
- 输入框需要更好的视觉分隔
|
||||||
|
- 需要添加翻译状态动画
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
1. **标题Logo**:
|
||||||
|
- 使用ASCII艺术 "l_ _ _____ _____"
|
||||||
|
- 实现紫色→粉色渐变效果 (ANSI True Color)
|
||||||
|
- 右侧显示版本号 [v1.0.0-beta]
|
||||||
|
|
||||||
|
2. **输入框改造**:
|
||||||
|
- 去掉边框
|
||||||
|
- 上下使用紫色 `:::` 分隔符
|
||||||
|
- Ctrl+J 启用换行
|
||||||
|
|
||||||
|
3. **信息栏改造**:
|
||||||
|
- 合并显示:语言(红色) + 模型名(白色) + 缓存记录(碳黑)
|
||||||
|
- 翻译时显示 Spinner 动画 (MiniDot)
|
||||||
|
|
||||||
|
4. **翻译卡片优化**:
|
||||||
|
- `▣` 图标边距调整
|
||||||
|
|
||||||
|
**版本号规则**:
|
||||||
|
- 版本号需与 git 标签、changelog.md 中的版本号保持三方同步
|
||||||
|
- 遵循语义化版本:主版本.次版本.修订版本
|
||||||
|
- beta版使用 `-beta` 后缀
|
||||||
|
|
||||||
|
**关联版本**: [changelog.md#1.0.0-beta](changelog.md#100-beta-2026-04-07)
|
||||||
Reference in New Issue
Block a user