Browse Source

feat(electron): polish ui

Tienson Qin 4 years ago
parent
commit
1a9a7e5ec8

+ 2 - 2
src/electron/electron/core.cljs

@@ -21,7 +21,7 @@
   []
   (let [win-opts {:width         980
                   :height        700
-                  :frame         (not mac?)
+                  :frame         win32?
                   :titleBarStyle (if mac? "hidden" nil)
                   :webPreferences
                   {:nodeIntegration         false
@@ -30,7 +30,7 @@
                    :preload                 (path/join js/__dirname "js/preload.js")}}
         url MAIN_WINDOW_ENTRY
         win (BrowserWindow. (clj->js win-opts))]
-    (when-not mac? (.removeMenu win))
+    (when win32? (.removeMenu win))
     (.loadURL win url)
     (when dev? (.. win -webContents (openDevTools)))
     win))

+ 2 - 2
src/main/frontend/components/header.cljs

@@ -159,12 +159,12 @@
        (logo {:white? white?})
 
        (when (util/electron?)
-         [:a.mr-1.opacity-50.hover:opacity-100
+         [:a.mr-1.opacity-50.hover:opacity-100.it
           {:style {:margin-left -10}
            :title "Go Back" :on-click #(js/window.history.back)} (svg/arrow-left)])
 
        (when (util/electron?)
-         [:a.opacity-50.hover:opacity-100
+         [:a.opacity-50.hover:opacity-100.it
           {:style {:margin-right 15}
            :title "Go Forward" :on-click #(js/window.history.forward)} (svg/arrow-right)])
 

+ 3 - 0
src/main/frontend/components/header.css

@@ -12,6 +12,9 @@
   left: 0;
 
   user-select: none;
+  .it svg {
+      transform: scale(0.8);
+  }
 }
 
 .cp__header-left-menu {

+ 1 - 0
src/main/frontend/components/page.cljs

@@ -384,6 +384,7 @@
                   file-path]
 
                  (when (and (not config/mobile?)
+                            (not (util/electron?))
                             (not journal?))
                    (presentation repo page))])]
 

+ 2 - 2
src/main/frontend/components/right_sidebar.cljs

@@ -222,7 +222,7 @@
        {:class (if sidebar-open? "is-open")}
        (if sidebar-open?
          [:div.cp__right-sidebar-inner
-          [:div.flex.flex-row.justify-between.align-items
+          [:div.flex.flex-row.justify-between.items-center
            [:div.cp__right-sidebar-settings.hide-scrollbar {:key "right-sidebar-settings"}
             [:div.ml-4.text-sm
              [:a.cp__right-sidebar-settings-btn {:on-click (fn [e]
@@ -249,7 +249,7 @@
              [:a.cp__right-sidebar-settings-btn {:on-click (fn [_e]
                                                              (state/sidebar-add-block! repo "help" :help nil))}
               (t :right-side-bar/help)]]]
-           [:a.opacity-50.hover:opacity-100 {:on-click state/toggle-sidebar-open?!}
+           [:a.close-arrow.opacity-50.hover:opacity-100 {:on-click state/toggle-sidebar-open?!}
             (svg/big-arrow-right)]]
 
           (for [[idx [repo db-id block-type block-data]] (medley/indexed blocks)]

+ 6 - 0
src/main/frontend/components/sidebar.css

@@ -138,12 +138,14 @@
 
   &-inner {
     padding: 15px;
+    padding-top: 0;
   }
 
   &-settings {
     @apply flex flex-row mb-2;
     margin: -15px;
     margin-bottom: 0;
+    margin-top: 0;
     overflow: auto;
 
     &-btn {
@@ -153,6 +155,10 @@
     }
   }
 
+  .close-arrow svg {
+      transform: scale(0.8);
+  }
+
   &.is-open {
     display: block;
     width: 40%;

+ 2 - 2
src/main/frontend/db/model.cljs

@@ -203,7 +203,7 @@
 (defn set-file-last-modified-at!
   [repo path last-modified-at]
   (when (and repo path last-modified-at)
-    (when-let [conn (conn/get-files-conn repo)]
+    (when-let [conn (conn/get-conn repo false)]
       (d/transact! conn
                    [{:file/path path
                      :file/last-modified-at last-modified-at}]))))
@@ -211,7 +211,7 @@
 (defn get-file-last-modified-at
   [repo path]
   (when (and repo path)
-    (when-let [conn (conn/get-files-conn repo)]
+    (when-let [conn (conn/get-conn repo false)]
       (-> (d/entity (d/db conn) [:file/path path])
           :file/last-modified-at))))
 

+ 5 - 3
src/main/frontend/db/react.cljs

@@ -344,8 +344,7 @@
   [repo path content]
   (when (and repo path)
     (let [tx-data {:file/path path
-                   :file/content content
-                   :file/last-modified-at (util/time-ms)}
+                   :file/content content}
           tx-data (if (config/local-db? repo)
                     (dissoc tx-data :file/last-modified-at)
                     tx-data)]
@@ -353,4 +352,7 @@
        repo
        [tx-data]
        {:key [:file/content path]
-        :files-db? true}))))
+        :files-db? true}))
+    (d/transact! (conn/get-conn repo false)
+                 [{:file/path path
+                   :file/last-modified-at (util/time-ms)}])))

+ 0 - 1
src/main/frontend/db_schema.cljs

@@ -5,7 +5,6 @@
 (def files-db-schema
   {:file/path {:db/unique :db.unique/identity}
    :file/content {}
-   :file/last-modified-at {}
    :file/size {}
    :file/handle {}})
 

+ 0 - 8
src/main/frontend/fs/nfs.cljs

@@ -132,14 +132,6 @@
                   format (-> (util/get-file-ext path)
                              (config/get-file-format))
                   pending-writes (state/get-write-chan-length)]
-             ;; (println {:last-modified-at last-modified-at
-             ;;           :local-last-modified-at local-last-modified-at
-             ;;           :not-changed? not-changed?
-             ;;           :new-created? new-created?
-             ;;           :pending-writes pending-writes
-             ;;           :local-content local-content
-             ;;           :old-content old-content
-             ;;           :new? new?})
             (if (and local-content old-content new?
                      (or
                       (> pending-writes 0)

+ 4 - 0
src/main/frontend/fs/watcher_handler.cljs

@@ -13,6 +13,10 @@
 
 (defn handle-changed!
   [type {:keys [dir path content stat] :as payload}]
+  ;; (prn {:type type
+  ;;       :payload payload
+  ;;       :db-content (db/get-file path)
+  ;;       :timestamp (db/get-file-last-modified-at (state/get-current-repo) path)})
   (when dir
     (let [repo (config/get-local-repo dir)
           {:keys [mtime]} stat]

+ 7 - 2
src/main/frontend/handler/page.cljs

@@ -312,10 +312,15 @@
       (when-let [file (d/entity (d/db conn) [:file/path old-path])]
         (d/transact! conn [{:db/id (:db/id file)
                             :file/path new-path}])))
+
     (->
      (p/let [_ (fs/rename! repo
-                           (str (config/get-repo-dir repo) "/" old-path)
-                           (str (config/get-repo-dir repo) "/" new-path))
+                           (if (util/electron?)
+                             old-path
+                             (str (config/get-repo-dir repo) "/" old-path))
+                           (if (util/electron?)
+                             new-path
+                             (str (config/get-repo-dir repo) "/" new-path)))
              _ (when-not (config/local-db? repo)
                  (git/rename repo old-path new-path))]
        (common-handler/check-changed-files-status)