Skip to content

Commit c1f9368

Browse files
committed
enhance(plugin): load plugin from web url for debug
1 parent f7f3963 commit c1f9368

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

src/main/frontend/components/plugins.cljs

+44-13
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@
404404
:intent "link"
405405
:target "_blank"))
406406

407-
(rum/defc user-proxy-settings-panel
407+
(rum/defc user-proxy-settings-container
408408
[{:keys [protocol type] :as agent-opts}]
409409
(let [type (or (not-empty type) (not-empty protocol) "system")
410410
[opts set-opts!] (rum/use-state agent-opts)
411411
[testing? set-testing?!] (rum/use-state false)
412412
*test-input (rum/create-ref)
413413
disabled? (or (= (:type opts) "system") (= (:type opts) "direct"))]
414-
[:div.cp__settings-network-proxy-panel
414+
[:div.cp__settings-network-proxy-cnt
415415
[:h1.mb-2.text-2xl.font-bold (t :settings-page/network-proxy)]
416416
[:div.p-2
417417
[:p [:label [:strong (t :type)]
@@ -478,6 +478,33 @@
478478
(p/let [_ (ipc/ipc :setProxy opts)]
479479
(state/set-state! [:electron/user-cfgs :settings/agent] opts))))]]]))
480480

481+
(rum/defc load-from-web-url-container
482+
[]
483+
(let [[url set-url!] (rum/use-state "")
484+
[pending? set-pending?] (rum/use-state false)
485+
handle-submit! (fn []
486+
(set-pending? true)
487+
(-> (p/delay 3000)
488+
(p/finally
489+
#(set-pending? false))))]
490+
491+
[:div.px-4.pt-4.pb-2.rounded-md.flex.flex-col.gap-2
492+
[:div.flex.flex-col.gap-3
493+
(shui/input {:placeholder "http://"
494+
:value url
495+
:on-change #(set-url! (-> (util/evalue %) (util/trim-safe)))
496+
:auto-focus true})
497+
[:span.text-gray-10
498+
(shui/tabler-icon "info-circle" {:size 13})
499+
[:span "URLs support both GitHub repositories and local development servers.
500+
(For examples: https://github.com/xyhp915/logseq-journals-calendar,
501+
http://localhost:8080/<plugin-dir-root>)"]]
502+
]
503+
[:div.flex.justify-end
504+
(shui/button {:disabled (or pending? (string/blank? url))
505+
:on-click handle-submit!}
506+
(if pending? (ui/loading) "Save"))]]))
507+
481508
(rum/defc auto-check-for-updates-control
482509
[]
483510
(let [[enabled, set-enabled!] (rum/use-state (plugin-handler/get-enabled-auto-check-for-updates?))
@@ -614,17 +641,21 @@
614641

615642
[{:hr true}]
616643

617-
(when (and (state/developer-mode?)
618-
(util/electron?))
619-
[{:title [:span.flex.items-center.gap-1 (ui/icon "file-code") (t :plugin/open-preferences)]
620-
:options {:on-click
621-
#(p/let [root (plugin-handler/get-ls-dotdir-root)]
622-
(js/apis.openPath (str root "/preferences.json")))}}
623-
{:title [:span.flex.items-center.whitespace-nowrap.gap-1
624-
(ui/icon "bug") (t :plugin/open-logseq-dir) [:code "~/.logseq"]]
625-
:options {:on-click
626-
#(p/let [root (plugin-handler/get-ls-dotdir-root)]
627-
(js/apis.openPath root))}}])
644+
(when (state/developer-mode?)
645+
(if (util/electron?)
646+
[{:title [:span.flex.items-center.gap-1 (ui/icon "file-code") (t :plugin/open-preferences)]
647+
:options {:on-click
648+
#(p/let [root (plugin-handler/get-ls-dotdir-root)]
649+
(js/apis.openPath (str root "/preferences.json")))}}
650+
{:title [:span.flex.items-center.whitespace-nowrap.gap-1
651+
(ui/icon "bug") (t :plugin/open-logseq-dir) [:code "~/.logseq"]]
652+
:options {:on-click
653+
#(p/let [root (plugin-handler/get-ls-dotdir-root)]
654+
(js/apis.openPath root))}}]
655+
[{:title [:span.flex.items-center.whitespace-nowrap.gap-1
656+
(ui/icon "plug") (t :plugin/load-from-web-url)]
657+
:options {:on-click
658+
#(shui/dialog-open! load-from-web-url-container)}}]))
628659

629660
[{:title [:span.flex.items-center.gap-1 (ui/icon "alert-triangle") (t :plugin/report-security)]
630661
:options {:on-click #(plugin-handler/open-report-modal!)}}]

src/main/frontend/components/settings.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
}
204204
}
205205

206-
&-network-proxy-panel {
206+
&-network-proxy-cnt {
207207
margin: -15px 0;
208208

209209
label {

src/main/frontend/handler/events.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@
420420

421421
(defmethod handle :go/proxy-settings [[_ agent-opts]]
422422
(shui/dialog-open!
423-
(plugin/user-proxy-settings-panel agent-opts)
423+
(plugin/user-proxy-settings-container agent-opts)
424424
{:id :https-proxy-panel :center? true :class "lg:max-w-2xl"}))
425425

426426
(defmethod handle :redirect-to-home [_]

src/resources/dicts/en.edn

+1
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@
552552
:plugin/checking-for-updates "Checking for plugin updates ..."
553553
:plugin/list-of-updates "Plugin Updates: "
554554
:plugin/auto-check-for-updates "Auto check for updates"
555+
:plugin/load-from-web-url "Load plugin from web url"
555556
:plugin.install-from-file/menu-title "Install from plugins.edn"
556557
:plugin.install-from-file/title "Install plugins from plugins.edn"
557558
:plugin.install-from-file/notice "The following plugins will replace your plugins:"

src/resources/dicts/zh-cn.edn

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@
289289
:plugin/checking-for-updates "正在检查插件更新 ..."
290290
:plugin/list-of-updates "可用的插件更新: "
291291
:plugin/auto-check-for-updates "是否自动检查更新"
292+
:plugin/load-from-web-url "通过URL载入插件"
292293
:plugin.install-from-file/menu-title "从 plugins.edn 安装"
293294
:plugin.install-from-file/title "从 plugins.edn 配置中安装插件"
294295
:plugin.install-from-file/notice "以下插件会替换已安装的插件:"

0 commit comments

Comments
 (0)