fix(electron): absolute path on win32

pull/1901/head
charlie 2021-05-08 20:02:48 +08:00
parent bba717d533
commit 3e0e85aa03
3 changed files with 15 additions and 4 deletions

View File

@ -139,5 +139,7 @@ contextBridge.exposeInMainWorld('apis', {
setZoomFactor (factor) {
webFrame.setZoomFactor(factor)
}
},
isAbsolutePath: path.isAbsolute.bind(path)
})

View File

@ -138,9 +138,10 @@
([repo dir path]
(create-if-not-exists repo dir path ""))
([repo dir path initial-content]
(let [path (if (util/starts-with? path "/")
path
(str "/" path))]
(let [path (if (util/is-absolute-path path) path
(if (util/starts-with? path "/")
path
(str "/" path)))]
(->
(p/let [stat (stat dir path)]
true)

View File

@ -1070,6 +1070,14 @@
(defonce win32? #?(:cljs goog.userAgent/WINDOWS
:clj nil))
#?(:cljs
(defn is-absolute-path
[path]
(try
(js/window.apis.isAbsolutePath path)
(catch js/Error _
(node-path.isAbsolute path)))))
(defn ->system-modifier
[keyboard-shortcut]
(if mac?