This commit is contained in:
cdle
2023-06-07 15:11:14 +08:00
parent ad6208bc43
commit 90f302a682
6 changed files with 217 additions and 1 deletions
+23
View File
@@ -262,6 +262,9 @@ func SetPluginMethod(vm *goja.Runtime, uuid string, on_start bool) {
})
})
}
o.Set("static", func(path string) {
addStatic(uuid, path)
})
return o
})
// registry.RegisterNativeModule("express", func(runtime *goja.Runtime, module *goja.Object) {
@@ -410,6 +413,26 @@ func SetPluginMethod(vm *goja.Runtime, uuid string, on_start bool) {
}
return Script(str)
})
vm.Set("Temp", func(pre string, sec int) interface{} {
return map[string]interface{}{
"set": func(key string, value interface{}, num int) {
if sec != 0 && num == 0 {
num = sec
}
temp.Set(pre+"_"+key, value, num)
},
"get": func(key string, def interface{}) interface{} {
v := temp.Get(pre + "_" + key)
if v == nil {
v = def
}
return v
},
"delete": func(key string) {
temp.Delete(pre + "_" + key)
},
}
})
}
func EncryptPlugin(script string) string {