Browse Source

enhance(electron): refine app proxy test url

Andelf 2 years ago
parent
commit
6fc5a265b5
2 changed files with 13 additions and 3 deletions
  1. 6 2
      src/electron/electron/handler.cljs
  2. 7 1
      src/main/frontend/components/plugins.cljs

+ 6 - 2
src/electron/electron/handler.cljs

@@ -358,8 +358,12 @@
   (utils/get-ls-dotdir-root))
 
 (defmethod handle :testProxyUrl [win [_ url]]
-  (p/let [_ (utils/fetch url)]
-    (utils/send-to-renderer win :notification {:type "success" :payload (str "Successfully: " url)})))
+  (p/let [resp (utils/fetch url)
+          code (.-status resp)]
+    (js/console.debug resp code)
+    (if (<= 200 code 299)
+      (utils/send-to-renderer win :notification {:type "success" :payload (str "Success: " url " status " code)})
+      (utils/send-to-renderer win :notification {:type "error" :payload (str "Failed: " url " status " code)}))))
 
 (defmethod handle :httpFetchJSON [_win [_ url options]]
   (p/let [res (utils/fetch url options)

+ 7 - 1
src/main/frontend/components/plugins.cljs

@@ -409,10 +409,16 @@
        [:span.w-60
         [:input.form-input.is-small
          {:ref         *test-input
+          :list        "proxy-test-url-datalist"
+          :type        "url"
           :placeholder "http://"
           :on-change   #(set-opts!
                          (assoc opts :test (util/trim-safe (util/evalue %))))
-          :value       (:test opts)}]]
+          :value       (:test opts)}]
+        [:datalist#proxy-test-url-datalist
+         [:option "https://www.google.com"]
+         [:option "https://s3.amazonaws.com"]
+         [:option "https://clients3.google.com/generate_204"]]]
 
        (ui/button (if testing? (ui/loading "Testing") "Test URL")
                   :intent "logseq" :large? false