2
0
mirror of https://github.com/acepanel/helper.git synced 2026-02-03 19:07:15 +08:00

feat: 优化

This commit is contained in:
2026-01-18 00:06:00 +08:00
parent 4bb0533d0f
commit b70dfa660f
2 changed files with 32 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"os/exec"
"strings"
"time"
@@ -43,8 +44,11 @@ const (
// 消息类型
type (
progressMsg types.Progress
installCompleteMsg struct{ err error }
progressMsg types.Progress
installCompleteMsg struct {
err error
info string
}
uninstallCompleteMsg struct{ err error }
mountCompleteMsg struct{ err error }
countdownTickMsg struct{ remaining int }
@@ -84,6 +88,7 @@ type App struct {
installErr error
installRunning bool
installDone bool
installInfo string // 安装完成后的面板信息
// 卸载
uninstallCountdown int
@@ -341,6 +346,7 @@ func (a *App) updateInstall(msg tea.Msg) (tea.Model, tea.Cmd) {
a.installRunning = false
a.installDone = true
a.installErr = msg.err
a.installInfo = msg.info
return a, nil
case spinner.TickMsg:
@@ -393,7 +399,15 @@ func (a *App) startInstall() tea.Cmd {
close(progressCh)
time.Sleep(100 * time.Millisecond)
return installCompleteMsg{err: err}
// 安装成功后获取面板信息
var info string
if err == nil {
cmd := exec.CommandContext(ctx, "/usr/local/sbin/acepanel", "info")
output, _ := cmd.Output()
info = string(output)
}
return installCompleteMsg{err: err, info: info}
}
}
@@ -411,6 +425,10 @@ func (a *App) viewInstall() string {
sb.WriteString(ErrorBoxStyle.Render(a.installErr.Error()))
} else {
sb.WriteString(RenderSuccess(i18n.T.Get("Installation successful")))
if a.installInfo != "" {
sb.WriteString("\n\n")
sb.WriteString(InfoBoxStyle.Render(strings.TrimSpace(a.installInfo)))
}
}
sb.WriteString("\n\n")
sb.WriteString(RenderHelp("Enter", i18n.T.Get("Back")))

View File

@@ -15,11 +15,12 @@ var (
// Logo ASCII艺术
const Logo = `
_ ____ _
/ \ ___ ___ | _ \ __ _ _ __ ___| |
/ _ \ / __/ _ \ | |_) / _` + "`" + ` | '_ \ / _ \ |
/ ___ \ (_| __/ | __/ (_| | | | | __/ |
/_/ \_\___\___| |_| \__,_|_| |_|\___|_|
█████╗ ██████╗███████╗██████╗ █████╗ ███╗ ██╗███████╗██╗
██╔══██╗██╔════╝██╔════╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██║
███████║██║ █████╗ ██████╔╝███████║██╔██╗ ██║█████╗ ██║
██╔══██║██║ ██╔══╝ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║
██║ ██║╚██████╗███████╗██║ ██║ ██║██║ ╚████║███████╗███████╗
╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝
`
// 样式定义
@@ -64,6 +65,11 @@ var (
BorderForeground(ColorError).
Padding(1, 2)
InfoBoxStyle = lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(ColorPrimary).
Padding(1, 2)
LogStyle = lipgloss.NewStyle().
Foreground(ColorMuted).
PaddingLeft(4)