1
0
Эх сурвалжийг харах

Update libs/src/LSPlugin.user.ts

Co-authored-by: Peng Xiao <[email protected]>
Charlie 3 жил өмнө
parent
commit
9885dc64e0

+ 14 - 8
libs/src/LSPlugin.user.ts

@@ -586,15 +586,21 @@ export class LSPluginUser
               const handler = args[0]
               caller[f](type, handler)
 
-              if (!isOff) {
-                that.App._installPluginHook(pid, type)
-              }
+  const unlisten = () => {
+    caller.off(type, handler)
+    if (!caller.listenerCount(type)) {
+      that.App._uninstallPluginHook(pid, type)
+    }
+  }
+  
+  if (!isOff) {
+    that.App._installPluginHook(pid, type)
+  } else {
+    unlisten()
+    return
+  }
 
-              return () => {
-                caller.off(type, handler)
-                if (!caller.listenerCount(type)) {
-                  that.App._uninstallPluginHook(pid, type)
-                }
+  return unlisten
               }
             }
           }