فهرست منبع

:bug: Fix `name` attribute could not be visited in the plugin constructor (#10071)

Yingyi / 颖逸 1 سال پیش
والد
کامیت
796df79931
2فایلهای تغییر یافته به همراه6 افزوده شده و 5 حذف شده
  1. 6 0
      app/src/plugin/index.ts
  2. 0 5
      app/src/plugin/loader.ts

+ 6 - 0
app/src/plugin/index.ts

@@ -68,6 +68,12 @@ export class Plugin {
         this.i18n = options.i18n;
         this.displayName = options.displayName;
         this.eventBus = new EventBus(options.name);
+
+        // https://github.com/siyuan-note/siyuan/issues/9943
+        Object.defineProperty(this, "name", {
+            value: options.name,
+            writable: false,
+        });
     }
 
     public onload() {

+ 0 - 5
app/src/plugin/loader.ts

@@ -64,11 +64,6 @@ const loadPluginJS = async (app: App, item: IPluginData) => {
         name: item.name,
         i18n: item.i18n
     });
-    // https://github.com/siyuan-note/siyuan/issues/9943
-    Object.defineProperty(plugin, "name", {
-        value: item.name,
-        writable: false,
-    });
     app.plugins.push(plugin);
     try {
         await plugin.onload();