x
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ type Language struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var plugin_dir = utils.ExecPath + "/plugins"
|
var plugin_dir = utils.ExecPath + "/plugins"
|
||||||
var release = "20230731"
|
var release = "20230732"
|
||||||
|
|
||||||
var languages = []Language{
|
var languages = []Language{
|
||||||
{
|
{
|
||||||
|
|||||||
+13
-6
@@ -217,7 +217,7 @@ func AddNodePlugin(path, name string) error {
|
|||||||
f.Suffix = ".js"
|
f.Suffix = ".js"
|
||||||
f.Type = "node"
|
f.Type = "node"
|
||||||
f.Path = path
|
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}
|
console := &Console{UUID: uuid}
|
||||||
s.SetPluginID(uuid)
|
s.SetPluginID(uuid)
|
||||||
plt := s.GetImType()
|
plt := s.GetImType()
|
||||||
@@ -263,13 +263,20 @@ func AddNodePlugin(path, name string) error {
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
scanner := bufio.NewScanner(stderr)
|
scanner := bufio.NewScanner(stderr)
|
||||||
|
if f.OnStart {
|
||||||
|
for scanner.Scan() {
|
||||||
|
fmt.Println(scanner.Text())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines := []string{}
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
data := scanner.Text()
|
data := scanner.Text()
|
||||||
fmt.Println(data)
|
lines = append(lines, data)
|
||||||
console.Error(data)
|
}
|
||||||
// if _, err := file.WriteString(data + "\n"); err != nil {
|
if len(lines) != 0 {
|
||||||
// fmt.Printf("写入文件失败:%v\n", err)
|
console.Error(strings.Join(lines, "\n"))
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
processes.Store(cmd, s)
|
processes.Store(cmd, s)
|
||||||
|
|||||||
+8
-16
@@ -375,29 +375,21 @@ class Bucket {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
reverseTransform(value) {
|
reverseTransform(value) {
|
||||||
if (typeof value === "number" || typeof value === "boolean") {
|
if (typeof value === "number") {
|
||||||
return value.toString();
|
if (value % 1 === 0) {
|
||||||
|
return `d:${value}`;
|
||||||
|
}
|
||||||
|
return `f:${value}`;
|
||||||
|
}
|
||||||
|
if (typeof value === "boolean") {
|
||||||
|
return `b:${value}`;
|
||||||
}
|
}
|
||||||
if (typeof value === "object" && value !== null) {
|
if (typeof value === "object" && value !== null) {
|
||||||
return "o:" + JSON.stringify(value);
|
return "o:" + JSON.stringify(value);
|
||||||
}
|
}
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (typeof value === "string") {
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return "";
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
async get(key, defaultValue = undefined) {
|
async get(key, defaultValue = undefined) {
|
||||||
|
|||||||
+8
-16
@@ -425,29 +425,21 @@ class Bucket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reverseTransform(value: any): string {
|
reverseTransform(value: any): string {
|
||||||
if (typeof value === "number" || typeof value === "boolean") {
|
if (typeof value === "number") {
|
||||||
return value.toString();
|
if (value % 1 === 0) {
|
||||||
|
return `d:${value}`;
|
||||||
|
}
|
||||||
|
return `f:${value}`;
|
||||||
|
}
|
||||||
|
if (typeof value === "boolean") {
|
||||||
|
return `b:${value}`;
|
||||||
}
|
}
|
||||||
if (typeof value === "object" && value !== null) {
|
if (typeof value === "object" && value !== null) {
|
||||||
return "o:" + JSON.stringify(value);
|
return "o:" + JSON.stringify(value);
|
||||||
}
|
}
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (typeof value === "string") {
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return "";
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user