Răsfoiți Sursa

enhance(plugin): app proxy call

charlie 9 luni în urmă
părinte
comite
25adb80b96
3 a modificat fișierele cu 12 adăugiri și 5 ștergeri
  1. 1 0
      libs/src/LSPlugin.ts
  2. 7 2
      libs/src/LSPlugin.user.ts
  3. 4 3
      src/main/logseq/api.cljs

+ 1 - 0
libs/src/LSPlugin.ts

@@ -145,6 +145,7 @@ export interface AppUserInfo {
 
 export interface AppInfo {
   version: string
+  supportDb: boolean
 
   [key: string]: unknown
 }

+ 7 - 2
libs/src/LSPlugin.user.ts

@@ -734,7 +734,8 @@ export class LSPluginUser
 
         return function (this: any, ...args: any) {
           if (origMethod) {
-            const ret = origMethod.apply(that, args.concat(tag))
+            if (args?.length !== 0) args.concat(tag)
+            const ret = origMethod.apply(that, args)
             if (ret !== PROXY_CONTINUE) return ret
           }
 
@@ -817,11 +818,15 @@ export class LSPluginUser
     return this._execCallableAPIAsync(`_callMainWin`, ...args)
   }
 
+  // User Proxies
+  #appProxy: IAppProxy
+
   /**
    * The interface methods of {@link IAppProxy}
    */
   get App (): IAppProxy {
-    return this._makeUserProxy(app, 'app')
+    if (this.#appProxy) return this.#appProxy
+    return (this.#appProxy = this._makeUserProxy(app, 'app'))
   }
 
   get Editor (): IEditorProxy {

+ 4 - 3
src/main/logseq/api.cljs

@@ -128,9 +128,10 @@
 (defn ^:export get_app_info
   ;; get app base info
   []
-  (bean/->js
-   (sdk-utils/normalize-keyword-for-json
-    {:version fv/version})))
+  (-> (sdk-utils/normalize-keyword-for-json
+        {:version fv/version
+         :supportDb true})
+    (bean/->js)))
 
 (def ^:export get_user_configs
   (fn []