Minor improvements on app initialization.

This commit is contained in:
Andrey Antukh 2020-04-30 09:15:44 +02:00 committed by Alonso Torres
parent e9d5eccd16
commit c2847bec4d
3 changed files with 11 additions and 40 deletions

View file

@ -4,14 +4,12 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>UXBOX - The Open-Source prototyping tool</title> <title>UXBOX - The Open-Source prototyping tool</title>
<link id="theme" href="/css/main-{{& th}}.css?ts={{& ts}}" rel="stylesheet" type="text/css" /> <link id="theme" href="/css/main-{{& th}}.css?ts={{& ts}}"
rel="stylesheet" type="text/css" />
<link rel="icon" href="/images/favicon.png" /> <link rel="icon" href="/images/favicon.png" />
<!-- <link rel="preload" as="image" type="image/svg+xml" -->
<!-- href="/images/svg-sprite/symbol/svg/sprite.symbol.svg" /> -->
</head> </head>
<body> <body>
<section id="app" tabindex="1"></section> <section id="app" tabindex="1"></section>
<section id="loader"></section>
<section id="modal"></section> <section id="modal"></section>
<script> <script>
window.uxboxConfig = JSON.parse({{& config }}); window.uxboxConfig = JSON.parse({{& config }});

View file

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UXBOX View</title>
<link href="/css/view-{{& th}}.css?ts={{& ts}}" rel="stylesheet" type="text/css" />
<link rel="icon" href="/images/favicon.png" />
</head>
<body>
<section id="app" tabindex="1"></section>
<section id="loader"></section>
<section id="modal"></section>
<script>
window.uxboxConfig = JSON.parse({{& config }});
window.uxboxTranslations = JSON.parse({{& translations }});
</script>
<script src="/js/shared.js?ts={{& ts}}"></script>
<script src="/js/view.js?ts={{& ts}}"></script>
<script>uxbox.view.init()</script>
</body>
</html>

View file

@ -18,7 +18,6 @@
[uxbox.main.store :as st] [uxbox.main.store :as st]
[uxbox.main.ui :as ui] [uxbox.main.ui :as ui]
[uxbox.main.ui.modal :refer [modal]] [uxbox.main.ui.modal :refer [modal]]
[uxbox.main.ui.loader :refer [loader]]
[uxbox.main.worker] [uxbox.main.worker]
[uxbox.util.dom :as dom] [uxbox.util.dom :as dom]
[uxbox.util.html.history :as html-history] [uxbox.util.html.history :as html-history]
@ -32,14 +31,17 @@
(defn- on-navigate (defn- on-navigate
[router path] [router path]
(let [match (rt/match router path)] (let [match (rt/match router path)
(cond profile (:profile storage)]
(and (= path "") (:auth storage)) (prn "on-navigate" match path)
(st/emit! (rt/nav :dashboard-projects))
(and (= path "") (not (:auth storage))) (cond
(and (= path "") (not profile))
(st/emit! (rt/nav :login)) (st/emit! (rt/nav :login))
(and (= path "") profile)
(st/emit! (rt/nav :dashboard-team {:team-id (:default-team-id profile)}))
(nil? match) (nil? match)
(st/emit! (rt/nav :not-found)) (st/emit! (rt/nav :not-found))
@ -59,19 +61,15 @@
(mf/mount (mf/element ui/app) (dom/get-element "app")) (mf/mount (mf/element ui/app) (dom/get-element "app"))
(mf/mount (mf/element modal) (dom/get-element "modal")) (mf/mount (mf/element modal) (dom/get-element "modal"))
(mf/mount (mf/element loader) (dom/get-element "loader"))
(on-navigate router cpath))) (on-navigate router cpath)))
(def app-sym (.for js/Symbol "uxbox.app"))
(defn ^:export init (defn ^:export init
[] []
(let [translations (gobj/get goog.global "uxboxTranslations") (let [translations (gobj/get goog.global "uxboxTranslations")
themes (gobj/get goog.global "uxboxThemes")] themes (gobj/get goog.global "uxboxThemes")]
(i18n/init! translations) (i18n/init! translations)
(theme/init! themes) (theme/init! themes)
(unchecked-set js/window app-sym "main")
(st/init) (st/init)
(init-ui))) (init-ui)))
@ -80,11 +78,9 @@
(remove-watch html-history/path ::main) (remove-watch html-history/path ::main)
(mf/unmount (dom/get-element "app")) (mf/unmount (dom/get-element "app"))
(mf/unmount (dom/get-element "modal")) (mf/unmount (dom/get-element "modal"))
(mf/unmount (dom/get-element "loader"))
(init-ui)) (init-ui))
(defn ^:dev/after-load after-load (defn ^:dev/after-load after-load
[] []
(when (= "main" (unchecked-get js/window app-sym)) (reinit))
(reinit)))