feat: add default env settings

This commit is contained in:
engigu
2026-03-17 11:58:32 +08:00
parent 7b61477a42
commit 5fd7d78026
5 changed files with 77 additions and 38 deletions
+20
View File
@@ -76,3 +76,23 @@ func (c *MiseController) VerifyCommand(ctx *gin.Context) {
}
utils.Success(ctx, gin.H{"command": cmd})
}
// UseGlobal 设置全局默认版本
func (c *MiseController) UseGlobal(ctx *gin.Context) {
var req struct {
Plugin string `json:"plugin"`
Version string `json:"version"`
}
if err := ctx.ShouldBindJSON(&req); err != nil {
utils.BadRequest(ctx, "参数错误: "+err.Error())
return
}
if req.Plugin == "" || req.Version == "" {
utils.BadRequest(ctx, "参数 plugin 和 version 不能为空")
return
}
if err := c.service.UseGlobal(req.Plugin, req.Version); err != nil {
utils.ServerError(ctx, "设置全局版本失败: "+err.Error())
return
}
utils.Success(ctx, nil)
}