From a6e272b673ef53a473b521ec802be15c7fba7df1 Mon Sep 17 00:00:00 2001 From: 1-6 Date: Mon, 31 Jul 2023 17:06:59 +0800 Subject: [PATCH] x --- core/grpc_asset.go | 2 +- core/grpc_plugins.go | 23 +++++++++++++++-------- proto3/sillygirl.js | 26 +++++++++----------------- proto3/sillygirl.ts | 26 +++++++++----------------- 4 files changed, 34 insertions(+), 43 deletions(-) diff --git a/core/grpc_asset.go b/core/grpc_asset.go index ae9d478..3d7f36c 100644 --- a/core/grpc_asset.go +++ b/core/grpc_asset.go @@ -24,7 +24,7 @@ type Language struct { } var plugin_dir = utils.ExecPath + "/plugins" -var release = "20230731" +var release = "20230732" var languages = []Language{ { diff --git a/core/grpc_plugins.go b/core/grpc_plugins.go index c6ddb24..f298264 100644 --- a/core/grpc_plugins.go +++ b/core/grpc_plugins.go @@ -217,7 +217,7 @@ func AddNodePlugin(path, name string) error { f.Suffix = ".js" f.Type = "node" f.Path = path - f.Handle = func(s common.Sender, f func(vm *goja.Runtime)) interface{} { + f.Handle = func(s common.Sender, _ func(vm *goja.Runtime)) interface{} { console := &Console{UUID: uuid} s.SetPluginID(uuid) plt := s.GetImType() @@ -263,13 +263,20 @@ func AddNodePlugin(path, name string) error { go func() { defer wg.Done() scanner := bufio.NewScanner(stderr) - for scanner.Scan() { - data := scanner.Text() - fmt.Println(data) - console.Error(data) - // if _, err := file.WriteString(data + "\n"); err != nil { - // fmt.Printf("写入文件失败:%v\n", err) - // } + if f.OnStart { + for scanner.Scan() { + fmt.Println(scanner.Text()) + } + } else { + lines := []string{} + for scanner.Scan() { + data := scanner.Text() + lines = append(lines, data) + } + if len(lines) != 0 { + console.Error(strings.Join(lines, "\n")) + } + } }() processes.Store(cmd, s) diff --git a/proto3/sillygirl.js b/proto3/sillygirl.js index 4f77e69..ddce08c 100644 --- a/proto3/sillygirl.js +++ b/proto3/sillygirl.js @@ -375,29 +375,21 @@ class Bucket { return v; } reverseTransform(value) { - if (typeof value === "number" || typeof value === "boolean") { - return value.toString(); + if (typeof value === "number") { + if (value % 1 === 0) { + return `d:${value}`; + } + return `f:${value}`; + } + if (typeof value === "boolean") { + return `b:${value}`; } if (typeof value === "object" && value !== null) { return "o:" + JSON.stringify(value); } - if (value === undefined || value === null) { + if (!value) { return ""; } - if (typeof value === "string") { - if (!value) { - return ""; - } - if (!isNaN(parseFloat(value))) { - return "f:" + parseFloat(value); - } - if (!isNaN(parseInt(value))) { - return "d:" + parseInt(value); - } - if (value === "true" || value === "false") { - return "b:" + (value === "true"); - } - } return value; } async get(key, defaultValue = undefined) { diff --git a/proto3/sillygirl.ts b/proto3/sillygirl.ts index b883439..823a5db 100644 --- a/proto3/sillygirl.ts +++ b/proto3/sillygirl.ts @@ -425,29 +425,21 @@ class Bucket { } reverseTransform(value: any): string { - if (typeof value === "number" || typeof value === "boolean") { - return value.toString(); + if (typeof value === "number") { + if (value % 1 === 0) { + return `d:${value}`; + } + return `f:${value}`; + } + if (typeof value === "boolean") { + return `b:${value}`; } if (typeof value === "object" && value !== null) { return "o:" + JSON.stringify(value); } - if (value === undefined || value === null) { + if (!value) { return ""; } - if (typeof value === "string") { - if (!value) { - return ""; - } - if (!isNaN(parseFloat(value))) { - return "f:" + parseFloat(value); - } - if (!isNaN(parseInt(value))) { - return "d:" + parseInt(value); - } - if (value === "true" || value === "false") { - return "b:" + (value === "true"); - } - } return value; }