From d6a85cd71ece7277b31e3ac2df4bc7ac6842263e Mon Sep 17 00:00:00 2001 From: ShiMaRing <97494720+ShiMaRing@users.noreply.github.com> Date: Sat, 8 Oct 2022 14:38:26 +0800 Subject: [PATCH] fix(info): adapt to new page dom structure (#51) also: 1. prevent adding duplicated account 2. show the current plan stage --- pkg/cmd/config.go | 2 +- pkg/cmd/info.go | 4 ++-- pkg/handler/dashboard.go | 9 +++++---- pkg/model/config.go | 10 +++++++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 12c2a6f..0d41992 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -149,7 +149,7 @@ var ( password := ctx.String("password") if password != "" { if err = account.SetPassword(ctx.String("password"), []byte(ctx.String("secret"))); err != nil { - return fmt.Errorf("fail to set account:\n\t'%s' not found", username) + return fmt.Errorf("fail to set password:\n\t'%v'", err) } } diff --git a/pkg/cmd/info.go b/pkg/cmd/info.go index 57422f5..785c7af 100644 --- a/pkg/cmd/info.go +++ b/pkg/cmd/info.go @@ -128,7 +128,7 @@ func (i *infoPrinter) PrintDevices() { return } for _, device := range devices { - console.InfoF("\tNo.%d\t%s\t%s\t%s\n", device.ID, device.IP, device.StartTime, device.SID) + console.InfoF("\tNo.%d\t%s\t%s\t%8s\t%s\n", device.ID, device.IP, device.StartTime, device.SID, device.Stage) } } @@ -154,7 +154,7 @@ func (i *infoPrinter) PrintLog(page int) { return } for _, record := range records { - console.InfoF("\t%s - %s\t%s\t%s\n", record.StartTime, record.EndTime, record.IP, record.Traffic) + console.InfoF("\t%s - %s\t%s\t%10s\t%s\n", record.StartTime, record.EndTime, record.IP, record.Traffic, record.UsedDuration) } } diff --git a/pkg/handler/dashboard.go b/pkg/handler/dashboard.go index e36f94a..ae6af17 100644 --- a/pkg/handler/dashboard.go +++ b/pkg/handler/dashboard.go @@ -115,7 +115,7 @@ func (d *DashboardHandler) GetPackage() (*Package, error) { return nil, err } - infos, _ := utils.MatchMultiple(regexp.MustCompile(`