This commit is contained in:
1-6
2023-07-27 21:59:07 +08:00
parent 41c8fc7233
commit cdfce0a8b6
22 changed files with 90 additions and 71 deletions
+8 -8
View File
@@ -179,15 +179,13 @@ func initNodePlugins() {
}
}
func RemNodePlugin(name string) error {
func RemNodePlugin(name string) bool {
if name == "" {
return nil
return false
}
pluginLock.Lock()
defer pluginLock.Unlock()
key := nameUuid(name)
// plugins_id.Delete(key)
// fmt.Println("rem", key, name)
for i := range Functions {
if Functions[i].UUID == key {
f := Functions[i]
@@ -206,12 +204,11 @@ func RemNodePlugin(name string) error {
CancelHttpListen(key)
remStatic(key)
storage.DisableHandle(key)
console.Log("已移除 %s%s", f.Title, f.Suffix)
break
return true
}
}
return nil
return false
}
func nameUuid(name string) string {
@@ -233,7 +230,6 @@ func AddNodePlugin(path, name string) error {
plugins.Set(uuid, "")
pluginLock.Lock()
defer pluginLock.Unlock()
file, err := os.Open(path)
if err != nil {
return err
@@ -249,6 +245,10 @@ func AddNodePlugin(path, name string) error {
// plugins_id.Store(uuid, path)
// fmt.Println("add,", uuid, name)
f, cbs := pluginParse(script, uuid)
f.Reload = func() { //重载
RemNodePlugin(path)
AddNodePlugin(path, name)
}
f.Suffix = ".js"
f.Type = "node"
f.Path = path