mirror of https://github.com/logseq/logseq
Fix router reload issue
parent
d1b511eafe
commit
2f0734ebbd
|
@ -4,23 +4,27 @@
|
||||||
[frontend.page :as page]
|
[frontend.page :as page]
|
||||||
[frontend.routes :as routes]
|
[frontend.routes :as routes]
|
||||||
[reitit.frontend :as rf]
|
[reitit.frontend :as rf]
|
||||||
[reitit.frontend.easy :as rfe]
|
[reitit.frontend.easy :as rfe]))
|
||||||
[reitit.coercion :as rc]
|
|
||||||
[reitit.coercion.spec :as rss]))
|
(defn set-router!
|
||||||
|
[]
|
||||||
|
(rfe/start!
|
||||||
|
(rf/router routes/routes {})
|
||||||
|
handler/set-route-match!
|
||||||
|
;; set to false to enable HistoryAPI
|
||||||
|
{:use-fragment false}))
|
||||||
|
|
||||||
(defn start []
|
(defn start []
|
||||||
(rum/mount (page/current-page)
|
(rum/mount
|
||||||
(.getElementById js/document "root")))
|
(page/current-page)
|
||||||
|
(.getElementById js/document "root"))
|
||||||
|
(set-router!))
|
||||||
|
|
||||||
(defn ^:export init []
|
(defn ^:export init []
|
||||||
|
(prn "init!")
|
||||||
;; init is called ONCE when the page loads
|
;; init is called ONCE when the page loads
|
||||||
;; this is called in the index.html and must be exported
|
;; this is called in the index.html and must be exported
|
||||||
;; so it is available even in :advanced release builds
|
;; so it is available even in :advanced release builds
|
||||||
(rfe/start!
|
|
||||||
(rf/router routes/routes {:data {:coercion rss/coercion}})
|
|
||||||
handler/set-route-match!
|
|
||||||
;; set to false to enable HistoryAPI
|
|
||||||
{:use-fragment false})
|
|
||||||
|
|
||||||
;; (handler/get-me)
|
;; (handler/get-me)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
[]
|
[]
|
||||||
(let [state (rum/react state/state)
|
(let [state (rum/react state/state)
|
||||||
route-match (:route-match state)]
|
route-match (:route-match state)]
|
||||||
|
(prn "route: " route-match)
|
||||||
(if route-match
|
(if route-match
|
||||||
(when-let [view (:view (:data route-match))]
|
(when-let [view (:view (:data route-match))]
|
||||||
(view route-match)))))
|
(view route-match)))))
|
||||||
|
|
Loading…
Reference in New Issue