Files: 1c6860950766a4374f50d28c62707f3897061a41 / src / app / main.cljs
1282 bytesRaw
1 | (ns app.main |
2 | (:require [reagent.core :as reagent])) |
3 | |
4 | (def app (js/require "app")) |
5 | (def BrowserWindow (js/require "browser-window")) |
6 | |
7 | (goog-define dev? false) |
8 | |
9 | (defn load-page |
10 | "When compiling with `:none` the compiled JS that calls .loadUrl is |
11 | in a different place than it would be when compiling with optimizations |
12 | that produce a single artifact (`:whitespace, :simple, :advanced`). |
13 | |
14 | Because of this we need to dispatch the loading based on the used |
15 | optimizations, for this we defined `dev?` above that we can override |
16 | at compile time using the `:clojure-defines` compiler option." |
17 | [window] |
18 | (if dev? |
19 | (.loadUrl window (str "file://" js/__dirname "/../../index.html")) |
20 | (.loadUrl window (str "file://" js/__dirname "/index.html")))) |
21 | |
22 | (def main-window (atom nil)) |
23 | |
24 | (defn mk-window [w h frame? show?] |
25 | (BrowserWindow. #js {:width w :height h :frame frame? :show show?})) |
26 | |
27 | (defn init-browser [] |
28 | (reset! main-window (mk-window 800 600 true true)) |
29 | (load-page @main-window) |
30 | (if dev? (.openDevTools @main-window)) |
31 | (.on @main-window "closed" #(reset! main-window nil))) |
32 | |
33 | (defn init [] |
34 | (.on app "window-all-closed" #(when-not (= js/process.platform "darwin") (.quit app))) |
35 | (.on app "ready" init-browser) |
36 | (set! *main-cli-fn* (fn [] nil))) |
37 | |
38 |
Built with git-ssb-web