From 5f3c3e4b368c1602a1711b261a08a74cf7cddfa3 Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 26 Dec 2022 09:09:19 +0800 Subject: [PATCH] opt some --- base/web/option.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/web/option.go b/base/web/option.go index c3da46c9..af506301 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -76,6 +76,9 @@ func Toast30s(m *ice.Message, text string, arg ...ice.Any) { } func GoToast(m *ice.Message, title string, cb func(toast func(string, int, int))) { cb(func(name string, count, total int) { + if total == 0 { + total = 1 + } Toast(m, kit.Format("%s %s/%s", name, strings.TrimSuffix(kit.FmtSize(int64(count)), "B"), strings.TrimSuffix(kit.FmtSize(int64(total)), "B")), kit.Format("%s %d%%", title, count*100/total),