1
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
昔念
2026-04-20 00:45:55 +08:00
parent ec608d69cd
commit 04038cd16b
3 changed files with 28 additions and 28 deletions

View File

@@ -2,10 +2,12 @@ package model
import (
"blazing/cool"
"encoding/json"
"fmt"
"strings"
"github.com/dop251/goja"
"github.com/gogf/gf/v2/frame/g"
)
const (
@@ -157,6 +159,26 @@ func bindBossScriptFunctions(vm *goja.Runtime, hookAction any) {
ctx.SwitchPetFn(uint32(catchTime))
return goja.Undefined()
})
_ = vm.Set("debug", func(call goja.FunctionCall) goja.Value {
if len(call.Arguments) == 0 {
g.Log().Debugf(ctx, "[boss-script] debug() called with no arguments")
return goja.Undefined()
}
parts := make([]string, 0, len(call.Arguments))
for _, arg := range call.Arguments {
exported := arg.Export()
if bytes, err := json.Marshal(exported); err == nil {
parts = append(parts, string(bytes))
continue
}
parts = append(parts, arg.String())
}
g.Log().Debugf(ctx, "[boss-script] %s", strings.Join(parts, " "))
return goja.Undefined()
})
}
func defaultHookActionResult(hookAction any) bool {