Переглянути джерело

fix(plugin): invalid custom theme link href

charlie 9 місяців тому
батько
коміт
7f2eb16ad5

+ 2 - 2
src/main/frontend/components/plugins.cljs

@@ -103,8 +103,8 @@
               :class    (util/classnames
                           [{:is-selected current-selected?
                             :is-active   (= idx @*cursor)}])
-              :on-click #(do (js/LSPluginCore.selectTheme (bean/->js opt))
-                             (state/close-modal!))}
+              :on-click #(do (js/LSPluginCore.selectTheme (bean/->js (plugin-handler/assets-theme-to-file opt)))
+                           (state/close-modal!))}
              [:div.flex.items-center.text-xs
               [:div.opacity-60 (str (or (:name plg) "Logseq") " •")]
               [:div.name.ml-1 (:name opt)]]

+ 9 - 1
src/main/frontend/handler/plugin.cljs

@@ -53,6 +53,13 @@
 (defonce stats-url (str central-endpoint "stats.json"))
 (declare select-a-plugin-theme)
 
+(defn assets-theme-to-file
+  [theme]
+  (when theme
+    (cond-> theme
+      (util/electron?)
+      (update :url #(some-> % (string/replace-first "assets://" "file://"))))))
+
 (defn load-plugin-preferences
   []
   (-> (invoke-exported-api "load_user_preferences")
@@ -416,7 +423,7 @@
 (defn select-a-plugin-theme
   [pid]
   (when-let [themes (get (group-by :pid (:plugin/installed-themes @state/state)) pid)]
-    (when-let [theme (first themes)]
+    (when-let [theme (assets-theme-to-file (first themes))]
       (js/LSPluginCore.selectTheme (bean/->js theme)))))
 
 (defn update-plugin-settings-state
@@ -741,6 +748,7 @@
 
                                 (.on "theme-selected" (fn [^js theme]
                                                         (let [theme (bean/->clj theme)
+                                                              theme (assets-theme-to-file theme)
                                                               url   (:url theme)
                                                               mode  (:mode theme)]
                                                           (when mode