feat: enhance learn-number with dynamic SVG icons, multi-page support, and modular UI
Build and Push Docker Image / build (push) Successful in 2m26s

This commit is contained in:
2026-02-25 23:29:35 -08:00
parent 0be94026c5
commit 7cd611140e
12 changed files with 4330 additions and 279 deletions
+10 -6
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"toolbox/pkg/base"
"toolbox/pkg/learnnumber/data"
"toolbox/pkg/learnnumber/logic"
"github.com/gin-gonic/gin"
@@ -18,14 +19,22 @@ func init() {
func (t *learnNumberTool) ID() string { return "learn-number" }
func (t *learnNumberTool) Name() string { return "幼儿数学助手" }
func (t *learnNumberTool) Description() string { return "包含数图形、基础加减法等趣味数学练习" }
func (t *learnNumberTool) Emoji() string { return "🔢" }
func (t *learnNumberTool) Init() error {
fmt.Println("Initializing Learn-Number tool...")
return nil
// 动态加载匿名对象
return data.LoadIcons("pkg/learnnumber/data/fruit.svg")
}
func (t *learnNumberTool) RegisterRoutes(r *gin.RouterGroup) {
r.POST("/counting", t.handleCounting)
r.GET("/categories", t.handleCategories)
}
func (t *learnNumberTool) handleCategories(c *gin.Context) {
// 返回分类信息供前端预览
c.JSON(http.StatusOK, data.IconCategories)
}
func (t *learnNumberTool) handleCounting(c *gin.Context) {
@@ -34,15 +43,10 @@ func (t *learnNumberTool) handleCounting(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
if req.TotalCount <= 0 { req.TotalCount = 20 }
if req.TotalCount > 30 { req.TotalCount = 30 }
pdfBytes, err := logic.GenerateCountingPDF(req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.Data(http.StatusOK, "application/pdf", pdfBytes)
}