From cfb2f67991a5cd0e71a32e31b3988ff4656ba74d Mon Sep 17 00:00:00 2001 From: jiacai2050 Date: Sat, 12 Sep 2020 11:52:20 +0800 Subject: [PATCH] add darkmode / popup page --- cljs-src/.gitignore | 3 +- cljs-src/externs/darkreader.js | 5 + cljs-src/package.sh | 19 ++ cljs-src/project.clj | 194 ++++++++++-------- cljs-src/release.sh | 14 -- cljs-src/resources/_locales/en/messages.json | 5 + .../resources/_locales/zh_CN/messages.json | 5 + cljs-src/resources/config/db.edn | 6 +- cljs-src/resources/dev/background/init.js | 2 +- cljs-src/resources/dev/option/.gitignore | 1 - cljs-src/resources/dev/popup/index.html | 5 - cljs-src/resources/dev/{option => ui}/css | 0 cljs-src/resources/dev/{option => ui}/img | 0 .../dev/{option/init.js => ui/init-option.js} | 0 cljs-src/resources/dev/ui/init-popup.js | 2 + .../dev/{option/index.html => ui/option.html} | 12 +- cljs-src/resources/dev/ui/popup.html | 21 ++ cljs-src/resources/img/16-off.png | Bin 0 -> 1360 bytes cljs-src/resources/img/32-off.png | Bin 0 -> 2689 bytes cljs-src/resources/img/48-off.png | Bin 0 -> 5157 bytes cljs-src/resources/img/gooreplacer.ico | Bin 4286 -> 0 bytes cljs-src/resources/manifest.json | 19 +- cljs-src/resources/release/{option => ui}/css | 0 cljs-src/resources/release/{option => ui}/img | 0 .../{option/index.html => ui/option.html} | 7 +- cljs-src/resources/release/ui/popup.html | 16 ++ .../gooreplacer/{option => common}/db.cljs | 23 ++- cljs-src/src/gooreplacer/option/core.cljs | 34 +-- cljs-src/src/gooreplacer/option/io.cljs | 2 +- .../src/gooreplacer/option/local_rules.cljs | 2 +- .../src/gooreplacer/option/online_rules.cljs | 2 +- cljs-src/src/gooreplacer/option/setting.cljs | 43 ++++ cljs-src/src/gooreplacer/popup.cljs | 21 ++ 33 files changed, 299 insertions(+), 164 deletions(-) create mode 100644 cljs-src/externs/darkreader.js create mode 100755 cljs-src/package.sh delete mode 100755 cljs-src/release.sh delete mode 100644 cljs-src/resources/dev/option/.gitignore delete mode 100644 cljs-src/resources/dev/popup/index.html rename cljs-src/resources/dev/{option => ui}/css (100%) rename cljs-src/resources/dev/{option => ui}/img (100%) rename cljs-src/resources/dev/{option/init.js => ui/init-option.js} (100%) create mode 100644 cljs-src/resources/dev/ui/init-popup.js rename cljs-src/resources/dev/{option/index.html => ui/option.html} (53%) create mode 100644 cljs-src/resources/dev/ui/popup.html create mode 100644 cljs-src/resources/img/16-off.png create mode 100644 cljs-src/resources/img/32-off.png create mode 100644 cljs-src/resources/img/48-off.png delete mode 100644 cljs-src/resources/img/gooreplacer.ico rename cljs-src/resources/release/{option => ui}/css (100%) rename cljs-src/resources/release/{option => ui}/img (100%) rename cljs-src/resources/release/{option/index.html => ui/option.html} (59%) create mode 100644 cljs-src/resources/release/ui/popup.html rename cljs-src/src/gooreplacer/{option => common}/db.cljs (63%) create mode 100644 cljs-src/src/gooreplacer/option/setting.cljs create mode 100644 cljs-src/src/gooreplacer/popup.cljs diff --git a/cljs-src/.gitignore b/cljs-src/.gitignore index a7ec4a4..f5900d2 100644 --- a/cljs-src/.gitignore +++ b/cljs-src/.gitignore @@ -16,4 +16,5 @@ node_modules/ out/ package-lock.json resources/release/background/main.js -resources/release/option/main.js \ No newline at end of file +resources/release/ui/*js +resources/dev/ui/*js \ No newline at end of file diff --git a/cljs-src/externs/darkreader.js b/cljs-src/externs/darkreader.js new file mode 100644 index 0000000..16b22b5 --- /dev/null +++ b/cljs-src/externs/darkreader.js @@ -0,0 +1,5 @@ +var DarkReader = { + enable: function(){}, + disable: function(){}, + auto: function(){}, +} diff --git a/cljs-src/package.sh b/cljs-src/package.sh new file mode 100755 index 0000000..fee6861 --- /dev/null +++ b/cljs-src/package.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cd "$(cd `dirname $0`;pwd)" + +set -x + +rm resources/release/ui/option.js \ + resources/release/ui/popup.js \ + resources/release/background/main.js + + +lein with-profile release do clean, cljsbuild once option +lein with-profile release do clean, cljsbuild once background +lein with-profile release do clean, cljsbuild once popup +# clean compiled js before packaging +lein with-profile release clean + +cd resources/release +zip -x *.DS_Store -r ~/gooreplacer_`date +%s`.zip * diff --git a/cljs-src/project.clj b/cljs-src/project.clj index 5c87325..4a7b39e 100644 --- a/cljs-src/project.clj +++ b/cljs-src/project.clj @@ -1,101 +1,115 @@ (defproject gooreplacer "3.10.0" - :description "Modify, block URLs & Headers" - :url "https://github.com/jiacai2050/gooreplacer" - :license {:name "MIT" - :url "http://liujiacai.net/license/MIT.html?year=2015"} - :dependencies [[org.clojure/clojure "1.10.0"] - [org.clojure/clojurescript "1.10.597"] - [figwheel-sidecar "0.5.14"] - [org.clojure/core.match "0.3.0-alpha5"] - [org.clojure/data.json "0.2.7"] - [alandipert/storage-atom "2.0.1"] + :description "Modify, block URLs & Headers" + :url "https://github.com/jiacai2050/gooreplacer" + :license {:name "MIT" + :url "http://liujiacai.net/license/MIT.html?year=2015"} + :dependencies [[org.clojure/clojure "1.10.1"] + [org.clojure/clojurescript "1.10.773"] + [figwheel-sidecar "0.5.14"] + [org.clojure/core.match "1.0.0"] + [org.clojure/data.json "1.0.0"] + [alandipert/storage-atom "2.0.1"] - ;; ui - [antizer "0.3.0"] - [cljs-http "0.1.43"] - [org.clojure/core.async "0.3.443"] - [reagent "0.8.1"]] - :plugins [[lein-figwheel "0.5.14"] - [lein-cljsbuild "1.1.7"] - [lein-doo "0.1.8"]] - :profiles { - ;; https://docs.cider.mx/cider/0.23/basics/clojurescript.html#_piggieback - ;; cider will jack in piggieback automatically - ;; :dev {:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}} - :dev-option {:clean-targets ^{:protect false} [:target-path "resources/dev/option/js"] - :cljsbuild {:builds [{:id "dev" - :figwheel true - :source-paths ["src"] - :compiler {:output-to "resources/dev/option/js/main.js" - :source-map true - :asset-path "js" - :output-dir "resources/dev/option/js" - :optimizations :none - :main gooreplacer.option.core - :verbose true}}]} - :figwheel {:server-port 8080 - :http-server-root "dev/option" - :css-dirs ["resources/dev/option/css"] - :server-logfile ".figwheel_option.log" - :repl true}} - :dev-popup {:clean-targets ^{:protect false} [:target-path "resources/dev/popup/js"] + ;; ui + [antizer "0.3.0"] + [cljs-http "0.1.46"] + [org.clojure/core.async "1.3.610"] + [reagent "0.10.0"]] + :plugins [[lein-figwheel "0.5.14"] + [lein-cljsbuild "1.1.8"] + [lein-doo "0.1.8"]] + :profiles { + ;; https://docs.cider.mx/cider/0.23/basics/clojurescript.html#_piggieback + ;; cider will jack in piggieback automatically + ;; :dev {:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}} + :dev-option {:clean-targets ^{:protect false} [:target-path "resources/dev/ui/compiled-js/option"] :cljsbuild {:builds [{:id "dev" :figwheel true - :compiler {:output-to "resources/dev/popup/js/main.js" + :source-paths ["src"] + :compiler {:output-dir "resources/dev/ui/compiled-js/option" :source-map true :asset-path "js" - :output-dir "resources/dev/popup/js" + :output-to "resources/dev/ui/js/option.js" :optimizations :none - :main gooreplacer.popup.core + :main gooreplacer.option.core :verbose true}}]} - :figwheel {:server-port 8081 - :http-server-root "dev/option" - :css-dirs ["resources/dev/option/css"] - :server-logfile ".figwheel_popup.log" + :figwheel {:server-port 8080 + :http-server-root "dev/ui" + :css-dirs ["resources/dev/ui/css"] + :server-logfile ".figwheel_option.log" :repl true}} - :dev-bg {:clean-targets ^{:protect false} [:target-path "resources/dev/background/js"] - :figwheel {:server-port 8089 - :http-server-root "dev/background" - :server-logfile ".figwheel_bg.log" - :repl true} - :cljsbuild {:builds [{:id "dev" + :dev-popup {:clean-targets ^{:protect false} [:target-path "resources/dev/ui/compiled-js/popup"] + :cljsbuild {:builds [{:id "dev" + :figwheel true + :source-paths ["src"] + :compiler {:output-dir "resources/dev/ui/compiled-js/popup" + :source-map true + :asset-path "js" + :output-to "resources/dev/ui/js/pop.js" + :optimizations :none + :main gooreplacer.popup + :verbose true}}]} + :figwheel {:server-port 8090 + :http-server-root "dev/ui" + :css-dirs ["resources/dev/ui/css"] + :server-logfile ".figwheel_popup.log" + :repl true}} + :dev-bg {:clean-targets ^{:protect false} [:target-path "resources/dev/background/js"] + :figwheel {:server-port 8095 + :http-server-root "dev/background" + :server-logfile ".figwheel_bg.log" + :repl true} + :cljsbuild {:builds [{:id "dev" + :source-paths ["src"] + :figwheel true + :compiler {:output-to "resources/dev/background/js/main.js" + :source-map true + :output-dir "resources/dev/background/js" + :asset-path "js" + :main gooreplacer.background + :optimizations :none + :verbose true}}]}} + :release {:clean-targets ^{:protect false} [:target-path + "resources/release/ui/option-js" + "resources/release/ui/popup-js" + "resources/release/background/js"] + :cljsbuild {:builds [{:id "option" :source-paths ["src"] - :figwheel true - :compiler {:output-to "resources/dev/background/js/main.js" - :source-map true - :output-dir "resources/dev/background/js" - :asset-path "js" - :main gooreplacer.background - :optimizations :none - :verbose true}}]}} - :release {:clean-targets ^{:protect false} [:target-path - "resources/release/option/js" - "resources/release/background/js"] - :cljsbuild {:builds [{:id "option" - :compiler {:output-to "resources/release/option/main.js" - :output-dir "resources/release/option/js" - :externs ["externs/chrome_extensions.js" "externs/chrome.js"] - :optimizations :advanced - :main gooreplacer.option.core}} - {:id "background" - :compiler {:output-to "resources/release/background/main.js" - :output-dir "resources/release/background/js" - :externs ["externs/chrome_extensions.js" "externs/chrome.js"] - :optimizations :advanced - :main gooreplacer.background}}]}} - :test {:cljsbuild {:builds [{:id "test" - :compiler {:output-to "out/main.js" - :main gooreplacer.runner - :optimizations :none}}]} - :doo {:build "test"}}} + :compiler {:output-to "resources/release/ui/option.js" + :output-dir "resources/release/ui/option-js" + :externs ["externs/chrome_extensions.js" "externs/chrome.js" "externs/darkreader.js"] + :optimizations :advanced + :main gooreplacer.option.core}} + {:id "popup" + :source-paths ["src"] + :compiler {:output-to "resources/release/ui/popup.js" + :output-dir "resources/release/ui/popup-js" + :externs ["externs/chrome_extensions.js" "externs/chrome.js" "externs/darkreader.js"] + :optimizations :advanced + :main gooreplacer.popup}} + {:id "background" + :source-paths ["src"] + :compiler {:output-to "resources/release/background/main.js" + :output-dir "resources/release/background/js" + :externs ["externs/chrome_extensions.js" "externs/chrome.js"] + :optimizations :advanced + :main gooreplacer.background}}]}} + :test {:cljsbuild {:builds [{:id "test" + :compiler {:output-to "out/main.js" + :main gooreplacer.runner + :optimizations :none}}]} + :doo {:build "test"}}} - :aliases {"option" ["with-profile" "dev-option" "do" - ["clean"] - ["figwheel" "dev"]] - "bg" ["with-profile" "dev-bg" "do" - ["clean"] - ["figwheel" "dev"]] - "test-and-watch" ["with-profile" "test" "do" - ["clean"] - ;; First install phantom - ["doo" "phantom"]]}) + :aliases {"option" ["with-profile" "dev-option" "do" + ["clean"] + ["figwheel" "dev"]] + "popup"["with-profile" "dev-popup" "do" + ["clean"] + ["figwheel" "dev"]] + "bg" ["with-profile" "dev-bg" "do" + ["clean"] + ["figwheel" "dev"]] + "test-and-watch" ["with-profile" "test" "do" + ["clean"] + ;; First install phantom + ["doo" "phantom"]]}) diff --git a/cljs-src/release.sh b/cljs-src/release.sh deleted file mode 100755 index a5b1884..0000000 --- a/cljs-src/release.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -cd "$(cd `dirname $0`;pwd)" - -set -x -rm resources/release/option/main.js* -rm resources/release/background/main.js* - -lein with-profile release,ui-deps do clean, cljsbuild once option -lein with-profile release,bg-deps do clean, cljsbuild once background -lein with-profile release clean - -cd resources/release -zip -x *.DS_Store -r ~/gooreplacer_`date +%s`.zip * diff --git a/cljs-src/resources/_locales/en/messages.json b/cljs-src/resources/_locales/en/messages.json index 80710e9..4bb2084 100644 --- a/cljs-src/resources/_locales/en/messages.json +++ b/cljs-src/resources/_locales/en/messages.json @@ -191,5 +191,10 @@ } }, "titleGlobalSwitch": {"message" : "Master Switch"}, + "titleTheme": {"message" : "Theme"}, + "titleDark": {"message" : "Dark"}, + "titleLight": {"message" : "Light"}, + "titleAuto": {"message" : "Auto"}, + "titleConfigRule": {"message" : "Config Rules"}, "tabSetting": {"message" : "Settings" } } diff --git a/cljs-src/resources/_locales/zh_CN/messages.json b/cljs-src/resources/_locales/zh_CN/messages.json index 5970aed..a1658cf 100644 --- a/cljs-src/resources/_locales/zh_CN/messages.json +++ b/cljs-src/resources/_locales/zh_CN/messages.json @@ -191,5 +191,10 @@ } }, "titleGlobalSwitch": {"message" : "全局开关"}, + "titleTheme": {"message" : "主题"}, + "titleDark": {"message" : "黑"}, + "titleLight": {"message" : "白"}, + "titleAuto": {"message" : "跟随系统"}, + "titleConfigRule": {"message" : "配置规则"}, "tabSetting": {"message" : "设置" } } diff --git a/cljs-src/resources/config/db.edn b/cljs-src/resources/config/db.edn index c513ba2..7ea0384 100644 --- a/cljs-src/resources/config/db.edn +++ b/cljs-src/resources/config/db.edn @@ -17,6 +17,6 @@ {:name :request-headers :init-value []} {:name :response-headers - :init-value []}] - - + :init-value []} + {:name :theme + :init-value "auto"}] diff --git a/cljs-src/resources/dev/background/init.js b/cljs-src/resources/dev/background/init.js index dcebe91..9580a44 100644 --- a/cljs-src/resources/dev/background/init.js +++ b/cljs-src/resources/dev/background/init.js @@ -1,2 +1,2 @@ goog.require("figwheel.connect.build_dev"); -goog.require("gooreplacer.core"); +goog.require("gooreplacer.background"); diff --git a/cljs-src/resources/dev/option/.gitignore b/cljs-src/resources/dev/option/.gitignore deleted file mode 100644 index 7b4dcb5..0000000 --- a/cljs-src/resources/dev/option/.gitignore +++ /dev/null @@ -1 +0,0 @@ -js diff --git a/cljs-src/resources/dev/popup/index.html b/cljs-src/resources/dev/popup/index.html deleted file mode 100644 index 2a0b710..0000000 --- a/cljs-src/resources/dev/popup/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

Hello Extensions

- - diff --git a/cljs-src/resources/dev/option/css b/cljs-src/resources/dev/ui/css similarity index 100% rename from cljs-src/resources/dev/option/css rename to cljs-src/resources/dev/ui/css diff --git a/cljs-src/resources/dev/option/img b/cljs-src/resources/dev/ui/img similarity index 100% rename from cljs-src/resources/dev/option/img rename to cljs-src/resources/dev/ui/img diff --git a/cljs-src/resources/dev/option/init.js b/cljs-src/resources/dev/ui/init-option.js similarity index 100% rename from cljs-src/resources/dev/option/init.js rename to cljs-src/resources/dev/ui/init-option.js diff --git a/cljs-src/resources/dev/ui/init-popup.js b/cljs-src/resources/dev/ui/init-popup.js new file mode 100644 index 0000000..0fdd7e5 --- /dev/null +++ b/cljs-src/resources/dev/ui/init-popup.js @@ -0,0 +1,2 @@ +goog.require("figwheel.connect.build_dev"); +goog.require("gooreplacer.popup"); diff --git a/cljs-src/resources/dev/option/index.html b/cljs-src/resources/dev/ui/option.html similarity index 53% rename from cljs-src/resources/dev/option/index.html rename to cljs-src/resources/dev/ui/option.html index 2db6b38..a0b0a85 100644 --- a/cljs-src/resources/dev/option/index.html +++ b/cljs-src/resources/dev/ui/option.html @@ -1,21 +1,21 @@ - - + + - - - + + + Gooreplacer
- + diff --git a/cljs-src/resources/dev/ui/popup.html b/cljs-src/resources/dev/ui/popup.html new file mode 100644 index 0000000..6f342a6 --- /dev/null +++ b/cljs-src/resources/dev/ui/popup.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + Gooreplacer + + + + + + diff --git a/cljs-src/resources/img/16-off.png b/cljs-src/resources/img/16-off.png new file mode 100644 index 0000000000000000000000000000000000000000..394b13ec5ccb2703fd9494389b8d949577d79b8c GIT binary patch literal 1360 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|T2doC(|mmy zw18|523AHP24;{FAY@>aVqgWc85q16rQz%#Mh&PMCI*J~Oa>OHnkXO*0v4nJa0`PlBg3pY5xV%QuQiw3qZOUY$~jP%-qzHM1_jnoV;SI3R@+x3M(KRB&@Hb09I0xZL1XF8=&Bv zUzDm~s%N5Spk&9TprBw=l#*r@P?Wt5Z@Sn2DRmzV368|&p4rRy77T3YHG z80i}s=>k>g7FXt#Bv$C=6)QswftllyTAW;zSx}OhpQivaH!&%{w8U0P31kr*K-^i9 znTD__uNdkrpa=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zR*h?^&n<(48={^?`+QZeD_!i?ed{*Ug_C)kIFW1*GNRROZ$cQ~OFn19CyA)|JACd; z6r)DT+)x@Wt*Esh9(rbiPNr}Ex(bK+;YSgV{Fg&R)z$yKvd0qWu5dJ`3z?m~t~R~p zWdJ`Nmk2K`E-oh5PCkF}qH?cd)vt!rU7QCtGQak@i=ifWN|<vYPZ@tH!N2(>jHN zEB>1vI&pFM@kZmjg6&UBWYl~2A3_P`2K?6b1y|N*cqRD zSvH8qqWbzEEoIAcdsIg8&CZI<%LVkW^VgUxHRppn$?MiwELJd>%nOD(UN?{S*PMGc zLrG^Bl)p$?rK(3FzP!dxk$CAZ%gfu3Q&TggaGR{;YWIOWJRWoE#)^oKAqX1*B;{Ow z9b=%hu4&O>JeAr)b*5QNun2vU;&5;hD#31c>q1Ig2tY+vUy`tno7hQfNVOAn+tQRI60^vQOj%N7qBvAM_Qh!lY@-1nQ~#jX%6aR?=MGx z{ZR8Ui1v9X_C?&oQ$m^h{7VmtMD0h+(paWi!qg^4M|bVMsgYQD)i(a(>WFP|b-8o4 zdp&3EMC{IHXX5El{XvEs=7DJ2dPg{3Hluh9(ELdGQ*=t2w+uTqR_WG)4EuiYq5R5q z8&ac+*UN31xs%=8ohJLqjdm9+J}HELH#eNhe2vGxk>nTIDv(!oGng32EVWp0>pDWK zX~dp6AuW(NJRK2`ATgZ(SZMmW>7JCdYFk>1-q_J+_%u&{_oE9J-eirz23xC}_i;JK W!qEy(d;E_7!}PU{waPRc?*9jo&a5^7 literal 0 HcmV?d00001 diff --git a/cljs-src/resources/img/48-off.png b/cljs-src/resources/img/48-off.png new file mode 100644 index 0000000000000000000000000000000000000000..a03b393e7d79bd25217914d38a849e67985b648f GIT binary patch literal 5157 zcmY*dc|26@+dpH=PGgrnTVaM!mZ7l|gEX?s2$^g%*0JwImMkgzmMx53L=5$0-xJX? zvYTWtdoR!Ld7t0=-sf|j>w914`~6<`b^m$dj16@dXt`+t0ASG5)igQF(&s@lG=j!2m_`29&Q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+ + + Gooreplacer
- + diff --git a/cljs-src/resources/release/ui/popup.html b/cljs-src/resources/release/ui/popup.html new file mode 100644 index 0000000..c6fb8da --- /dev/null +++ b/cljs-src/resources/release/ui/popup.html @@ -0,0 +1,16 @@ + + + + + + + + + + Gooreplacer + + + + + + diff --git a/cljs-src/src/gooreplacer/option/db.cljs b/cljs-src/src/gooreplacer/common/db.cljs similarity index 63% rename from cljs-src/src/gooreplacer/option/db.cljs rename to cljs-src/src/gooreplacer/common/db.cljs index 021abeb..aac01c7 100644 --- a/cljs-src/src/gooreplacer/option/db.cljs +++ b/cljs-src/src/gooreplacer/common/db.cljs @@ -1,4 +1,4 @@ -(ns gooreplacer.option.db +(ns gooreplacer.common.db (:require [reagent.core :as r] [gooreplacer.common.i18n :as i18n] [gooreplacer.common.tool] @@ -40,3 +40,24 @@ "requestHeaders" i18n/title-req-headers "responseHeaders" i18n/title-resp-headers }) + +(def dark-key "dark") +(def light-key "light") +(def auto-key "auto") + +(defn config-darkmode [theme] + (condp = theme + dark-key (.enable js/DarkReader) + light-key (.disable js/DarkReader) + auto-key (.auto js/DarkReader))) + +(defn config-icon [enable] + (if enable + (.setIcon js/chrome.browserAction + (clj->js {:path {"32" "img/32.png" + "16" "img/16.png" + "48" "img/48.png"}})) + (.setIcon js/chrome.browserAction + (clj->js {:path {"32" "img/32-off.png" + "16" "img/16-off.png" + "48" "img/48-off.png"}})))) diff --git a/cljs-src/src/gooreplacer/option/core.cljs b/cljs-src/src/gooreplacer/option/core.cljs index bfc54b2..6628551 100644 --- a/cljs-src/src/gooreplacer/option/core.cljs +++ b/cljs-src/src/gooreplacer/option/core.cljs @@ -2,10 +2,11 @@ (:require [goog.dom :as gdom] [antizer.reagent :as ant] [reagent.core :as r] - [gooreplacer.option.db :as db] + [gooreplacer.common.db :as db] [gooreplacer.option.io :as io] [gooreplacer.common.i18n :as i18n] [gooreplacer.option.local-rules :as lr] + [gooreplacer.option.setting :refer [setting-body]] [gooreplacer.option.online-rules :refer [configure-online-form]])) (defn top-menu [] @@ -26,31 +27,8 @@ [ant/col [ant/button {:type "primary" :on-click #(.sendMessage js/chrome.runtime #js {"url" "https://github.com/jiacai2050/gooreplacer/tree/master/doc/guides.md"})} [ant/icon {:type "question"}] i18n/btn-help]]]]) -(defn setting-body [] - [ant/card - [ant/form {:layout "vertical"} - (let [conf @db/goo-conf] - (for [[title switch] [[i18n/title-global-switch :global-enabled?] - [i18n/tab-online-rule :online-enabled?] - [i18n/tab-redirect-url :redirect-enabled?] - [i18n/tab-cancel-url :cancel-enabled?] - [i18n/title-req-headers :req-headers-enabled?] - [i18n/title-resp-headers :res-headers-enabled?]]] - ^{:key title} - [ant/form-item {:label title} - [ant/switch {:checked-children "on" :un-checked-children "off" - :default-checked (switch conf) - :on-change (fn [checked] - (swap! db/goo-conf update switch not) - (println title checked))}]] - )) - ;; [ant/form-item {:label "Locale"} - ;; [ant/select {:style {:width "150px"} :default-value @db/locale - ;; :on-change #(do (reset! db/locale %) - ;; (ant/message-success %))} - ;; [ant/select-option {:value "en_US"} "English"] - ;; [ant/select-option {:value "zh_CN"} "简体中文"]]] - ]]) +(defn setting-tab [] + [ant/card [setting-body]]) (defn tabs [] [ant/tabs {:active-key @db/opened-tab :on-change #(reset! db/opened-tab %)} @@ -59,11 +37,13 @@ [i18n/tab-headers "header-tab" lr/header-rules-table] [i18n/tab-online-rule "online-tab" configure-online-form] [i18n/tab-sandbox "sanbox-tab" lr/sandbox] - [i18n/tab-setting "setting-tab" setting-body]]] + [i18n/tab-setting "setting-tab" setting-tab]]] ^{:key tab-key} [ant/tabs-tab-pane {:tab (r/as-element [:h4 tab-name])} [tab-ui]])]) (defn main-body [] + (db/config-darkmode @db/theme) + (db/config-icon (:global-enabled? @db/goo-conf)) [:div [top-menu] [ant/locale-provider {:locale (ant/locales db/locale)} diff --git a/cljs-src/src/gooreplacer/option/io.cljs b/cljs-src/src/gooreplacer/option/io.cljs index 1919ccc..039def1 100644 --- a/cljs-src/src/gooreplacer/option/io.cljs +++ b/cljs-src/src/gooreplacer/option/io.cljs @@ -1,6 +1,6 @@ (ns gooreplacer.option.io (:require [goog.dom :as gdom] - [gooreplacer.option.db :as db] + [gooreplacer.common.db :as db] [antizer.reagent :as ant] [gooreplacer.common.tool :as tool])) diff --git a/cljs-src/src/gooreplacer/option/local_rules.cljs b/cljs-src/src/gooreplacer/option/local_rules.cljs index ff7c3db..4422774 100644 --- a/cljs-src/src/gooreplacer/option/local_rules.cljs +++ b/cljs-src/src/gooreplacer/option/local_rules.cljs @@ -2,7 +2,7 @@ (:require [antizer.reagent :as ant] [clojure.string :as str] [reagent.core :as r] - [gooreplacer.option.db :as db] + [gooreplacer.common.db :as db] [gooreplacer.option.table :as table] [gooreplacer.common.tool :as tool] [gooreplacer.common.i18n :as i18n] diff --git a/cljs-src/src/gooreplacer/option/online_rules.cljs b/cljs-src/src/gooreplacer/option/online_rules.cljs index 35e1bb3..2eadf4f 100644 --- a/cljs-src/src/gooreplacer/option/online_rules.cljs +++ b/cljs-src/src/gooreplacer/option/online_rules.cljs @@ -1,7 +1,7 @@ (ns gooreplacer.option.online-rules (:require [antizer.reagent :as ant] [reagent.core :as r] - [gooreplacer.option.db :as db] + [gooreplacer.common.db :as db] [gooreplacer.common.tool :as tool] [gooreplacer.option.table :as table] [gooreplacer.common.i18n :as i18n] diff --git a/cljs-src/src/gooreplacer/option/setting.cljs b/cljs-src/src/gooreplacer/option/setting.cljs new file mode 100644 index 0000000..46e0c9f --- /dev/null +++ b/cljs-src/src/gooreplacer/option/setting.cljs @@ -0,0 +1,43 @@ +(ns gooreplacer.option.setting + (:require [antizer.reagent :as ant] + [gooreplacer.common.db :as db] + [gooreplacer.common.i18n :as i18n])) + +(defn setting-body [] + [ant/form {:layout "vertical"} + (let [conf @db/goo-conf] + (for [[title switch] [[i18n/title-global-switch :global-enabled?] + [i18n/tab-online-rule :online-enabled?] + [i18n/tab-redirect-url :redirect-enabled?] + [i18n/tab-cancel-url :cancel-enabled?] + [i18n/title-req-headers :req-headers-enabled?] + [i18n/title-resp-headers :res-headers-enabled?]]] + ^{:key title} + [ant/form-item {:label title} + [ant/switch {:checked-children "on" :un-checked-children "off" + :default-checked (switch conf) + :on-change (fn [checked] + (when (= switch :global-enabled?) + (db/config-icon checked)) + (swap! db/goo-conf update switch not) + ;; (println title checked) + )}]] + )) + [ant/form-item {:label i18n/title-theme} + [ant/select {:default-value @db/theme + :on-change (fn [theme] + (db/config-darkmode theme) + (reset! db/theme theme))} + (for [[title theme] [[i18n/title-dark db/dark-key] + [i18n/title-light db/light-key] + [i18n/title-auto db/auto-key]]] + ^{:key theme} + [ant/select-option title]) + ]] + ;; [ant/form-item {:label "Locale"} + ;; [ant/select {:style {:width "150px"} :default-value @db/locale + ;; :on-change #(do (reset! db/locale %) + ;; (ant/message-success %))} + ;; [ant/select-option {:value "en_US"} "English"] + ;; [ant/select-option {:value "zh_CN"} "简体中文"]]] + ]) diff --git a/cljs-src/src/gooreplacer/popup.cljs b/cljs-src/src/gooreplacer/popup.cljs new file mode 100644 index 0000000..2379c58 --- /dev/null +++ b/cljs-src/src/gooreplacer/popup.cljs @@ -0,0 +1,21 @@ +(ns gooreplacer.popup + (:require [goog.dom :as gdom] + [gooreplacer.common.db :as db] + [gooreplacer.common.i18n :as i18n] + [antizer.reagent :as ant] + [reagent.core :as r] + [gooreplacer.option.setting :refer [setting-body]])) + +(defn main-body [] + (db/config-darkmode @db/theme) + (db/config-icon (:global-enabled? @db/goo-conf)) + [ant/locale-provider {:locale (ant/locales db/locale)} + [ant/card + [:center + [ant/button {:type "primary" :on-click #(.openOptionsPage js/chrome.runtime)} i18n/title-config-rule]] + [:hr] + [setting-body]]]) + +(r/render + [main-body] + (gdom/getElement "popup-div"))