Просмотр исходного кода

improve(custom.css): support import current graph assets file

charlie 3 лет назад
Родитель
Сommit
24595cc4a9
2 измененных файлов с 11 добавлено и 1 удалено
  1. 9 0
      src/main/frontend/config.cljs
  2. 2 1
      src/main/frontend/handler/ui.cljs

+ 9 - 0
src/main/frontend/config.cljs

@@ -373,6 +373,15 @@
      (get-file-path repo
                     (str app-name "/" export-css-file)))))
 
+(defn expand-relative-assets-path
+  ;; ../assets/xxx -> {assets|file}://{current-graph-root-path}/xxx
+  [source]
+  (when-let [protocol (and (string? source)
+                           (not (string/blank? source))
+                           (if (util/electron?) "assets" "file"))]
+
+    (string/replace
+     source "../assets" (util/format "%s://%s/assets" protocol (get-repo-dir (state/get-current-repo))))))
 
 (defn get-custom-js-path
   ([]

+ 2 - 1
src/main/frontend/handler/ui.cljs

@@ -125,7 +125,8 @@
   []
   (when-let [style (or
                     (state/get-custom-css-link)
-                    (db-model/get-custom-css)
+                    (some-> (db-model/get-custom-css)
+                            (config/expand-relative-assets-path))
                     ;; (state/get-custom-css-link)
 )]
     (util/add-style! style)))