forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abdad56
commit 8e5a589
Showing
9 changed files
with
456 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const {ipcRenderer, contextBridge} = require('electron'); | ||
|
||
contextBridge.exposeInMainWorld('api', { | ||
doAction: async (arg) => { | ||
return await ipcRenderer.invoke('main', arg); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
(ns electron.handler) | ||
(ns electron.handler | ||
(:require ["electron" :refer [ipcMain]])) | ||
|
||
(defn set-ipc-handler! [window] | ||
(.handle ipcMain "main" | ||
(fn [event args-js] | ||
(prn "receive event: " args-js) | ||
args-js))) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns electron.ipc | ||
(:require [cljs-bean.core :as bean] | ||
[promesa.core :as p])) | ||
|
||
(defn ipc | ||
[& args] | ||
(js/window.api.doAction (bean/->js args))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,41 @@ | ||
(ns frontend.fs.node | ||
(:require [frontend.fs.protocol :as protocol] | ||
[frontend.util :as util] | ||
[clojure.string :as string])) | ||
[clojure.string :as string] | ||
[promesa.core :as p] | ||
[electron.ipc :as ipc])) | ||
|
||
;; (defonce fs (when (util/electron?) | ||
;; (js/require "fs"))) | ||
|
||
;; (defonce path (when (util/electron?) | ||
;; (js/require "path"))) | ||
|
||
;; (defn ls-dir [dir] | ||
;; (->> (tree-seq | ||
;; (fn [f] (.isDirectory (.statSync fs f) ())) | ||
;; (fn [d] (map #(.join path d %) (.readdirSync fs d))) | ||
;; dir) | ||
;; (apply concat) | ||
;; (doall))) | ||
|
||
(defrecord Node [] | ||
protocol/Fs | ||
(mkdir! [this dir] | ||
nil) | ||
(readdir [this dir] | ||
nil) | ||
(unlink! [this path opts] | ||
nil) | ||
(ipc/ipc "mkdir" {:path dir})) | ||
(readdir [this dir] ; recursive | ||
(ipc/ipc "readdir" {:dir dir})) | ||
(unlink! [this path _opts] | ||
(ipc/ipc "unlink" {:path path})) | ||
(rmdir! [this dir] | ||
nil) | ||
(read-file [this dir path] | ||
nil) | ||
(ipc/ipc "readFile" {:path (str dir "/" path)})) | ||
(write-file! [this repo dir path content opts] | ||
nil) | ||
(ipc/ipc "writeFile" {:path (str dir "/" path) | ||
:content content})) | ||
(rename! [this repo old-path new-path] | ||
nil) | ||
(ipc/ipc "rename" {:old-path old-path | ||
:new-path new-path})) | ||
(stat [this dir path] | ||
nil)) | ||
(ipc/ipc "stat" {:path (str dir path)}))) |
Oops, something went wrong.