feat: TUI帮助功能与样式改进
Some checks failed
Release / build (push) Failing after 37s

- 添加帮助信息栏 (bubbles help组件, Ctrl+H切换)
- 翻译卡片样式优化 (Padding空隙、上方内边距)
- 扩展build.sh支持跨平台编译
- release.yaml使用build.sh构建
This commit is contained in:
2026-04-08 02:08:34 +08:00
parent a9b7a69224
commit 0a40258d9a
6 changed files with 211 additions and 11 deletions

View File

@@ -1,3 +1,94 @@
#!/bin/bash
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "")
go build -ldflags "-X github.com/titor/fanyi/internal/logo.version=${VERSION}" -o yoyo ./cmd/yoyo
set -e
cd "$(dirname "$0")"
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
show_help() {
echo "YOYO 编译脚本"
echo ""
echo "用法:"
echo " ./build.sh 构建当前平台,输出 yoyo"
echo " ./build.sh <平台> 交叉编译指定平台"
echo " ./build.sh -h 显示帮助"
echo ""
echo "参数:"
echo " -h 显示帮助信息"
echo " -o <文件名> 指定输出文件名"
echo ""
echo "支持的平台:"
echo " linux/amd64, linux/arm64"
echo " darwin/amd64, darwin/arm64"
echo " windows/amd64"
echo ""
echo "示例:"
echo " ./build.sh # 构建当前平台"
echo " ./build.sh linux/amd64 # 编译 Linux x64"
echo " ./build.sh darwin/arm64 # 编译 macOS ARM"
echo " ./build.sh windows/amd64 -o app.exe # 编译 Windows x64自定义输出名"
echo ""
echo "输出文件名格式: yoo-<os>-<arch>[.exe]"
echo " yoo-linux-amd64"
echo " yoo-darwin-arm64"
echo " yoo-windows-amd64.exe"
}
OUTPUT_NAME="yoyo"
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
-o|--output)
OUTPUT_NAME="$2"
shift 2
;;
linux/amd64)
GOOS=linux GOARCH=amd64
PLATFORM="linux-amd64"
shift
;;
linux/arm64)
GOOS=linux GOARCH=arm64
PLATFORM="linux-arm64"
shift
;;
darwin/amd64)
GOOS=darwin GOARCH=amd64
PLATFORM="darwin-amd64"
shift
;;
darwin/arm64)
GOOS=darwin GOARCH=arm64
PLATFORM="darwin-arm64"
shift
;;
windows/amd64)
GOOS=windows GOARCH=amd64
PLATFORM="windows-amd64"
if [[ "$OUTPUT_NAME" == "yoyo" ]]; then
OUTPUT_NAME="yoo-windows-amd64.exe"
fi
shift
;;
*)
echo "未知平台: $1"
show_help
exit 1
;;
esac
done
echo "Building yoyo version: $VERSION"
if [ -n "$GOOS" ]; then
echo "Target: $PLATFORM"
go build -ldflags "-s -w -X github.com/titor/fanyi/internal/logo.version=${VERSION}" -o "$OUTPUT_NAME" ./cmd/yoyo
else
go build -ldflags "-s -w -X github.com/titor/fanyi/internal/logo.version=${VERSION}" -o "$OUTPUT_NAME" ./cmd/yoyo
fi
echo "Build complete: ./$OUTPUT_NAME"