core.cljs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. (ns frontend.core
  2. (:require [rum.core :as rum]
  3. [frontend.handler :as handler]
  4. [frontend.handler.route :as route]
  5. [frontend.page :as page]
  6. [frontend.routes :as routes]
  7. [frontend.spec]
  8. [frontend.log]
  9. [reitit.frontend :as rf]
  10. [reitit.frontend.easy :as rfe]
  11. [api]))
  12. (defn set-router!
  13. []
  14. (rfe/start!
  15. (rf/router routes/routes {})
  16. route/set-route-match!
  17. ;; set to false to enable HistoryAPI
  18. {:use-fragment false}))
  19. (defn display-welcome-message
  20. []
  21. (js/console.log
  22. "
  23. Welcome to Logseq!
  24. If you encounter any problem, feel free to file an issue on GitHub (https://github.com/logseq/logseq)
  25. or join our Discord server (https://discord.gg/KpN4eHY).
  26. .____
  27. | | ____ ____ ______ ____ ______
  28. | | / _ \\ / ___\\/ ___// __ \\/ ____/
  29. | |__( <_> ) /_/ >___ \\\\ ___< <_| |
  30. |_______ \\____/\\___ /____ >\\___ >__ |
  31. \\/ /_____/ \\/ \\/ |__|
  32. "))
  33. (defn start []
  34. (when-let [node (.getElementById js/document "root")]
  35. (set-router!)
  36. (rum/mount (page/current-page) node)
  37. (display-welcome-message)))
  38. (defn ^:export init []
  39. ;; init is called ONCE when the page loads
  40. ;; this is called in the index.html and must be exported
  41. ;; so it is available even in :advanced release builds
  42. (handler/start! start)
  43. ;; popup to notify user, could be toggled in settings
  44. ;; (handler/request-notifications-if-not-asked)
  45. ;; (handler/run-notify-worker!)
  46. )
  47. (defn stop []
  48. ;; stop is called before any code is reloaded
  49. ;; this is controlled by :before-load in the config
  50. (js/console.log "stop"))