Update plugin.py

This commit is contained in:
2026-11-01 15:32:23 +08:00
parent ed9a9b7860
commit dfa2163407

View File

@@ -872,8 +872,17 @@ class plugin(object):
package = self.__plugin_dir + '/' + name
if not os.path.exists(package):
return (False, "插件不存在!")
if not package in sys.path:
sys.path.append(package)
# 各插件脚本同名(如 index.py),目标插件目录需置于 sys.path 最前
if package in sys.path:
sys.path.remove(package)
sys.path.insert(0, package)
# 清除其他插件的同名模块缓存,避免 __import__ 命中错误模块
if script in sys.modules:
mod_file = getattr(sys.modules[script], '__file__', '') or ''
if not mod_file.startswith(package):
del sys.modules[script]
cmd = "__import__('" + script + "')." + func + '(' + args + ')'
if mw.isDebugMode():