浏览代码

fix: copy && paste file not working well on linux

Tienson Qin 4 年之前
父节点
当前提交
f83cfd15fa
共有 2 个文件被更改,包括 4 次插入3 次删除
  1. 4 2
      resources/js/preload.js
  2. 0 1
      src/main/frontend/components/editor.cljs

+ 4 - 2
resources/js/preload.js

@@ -9,9 +9,11 @@ function getFilePathFromClipboard () {
   if (IS_WIN32) {
     const rawFilePath = clipboard.read('FileNameW')
     return rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '')
+  } else if (IS_MAC) {
+    return clipboard.read('public.file-url').replace('file://', '')
+  } else{
+    return clipboard.readText()
   }
-
-  return clipboard.read('public.file-url').replace('file://', '')
 }
 
 function isClipboardHasImage () {

+ 0 - 1
src/main/frontend/components/editor.cljs

@@ -742,7 +742,6 @@
                                        (let [pick-one-allowed-item
                                              (fn [items]
                                                (if (util/electron?)
-
                                                  (let [existed-file-path (js/window.apis.getFilePathFromClipboard)
                                                        has-file-path? (not (string/blank? existed-file-path))
                                                        has-image? (js/window.apis.isClipboardHasImage)]