summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaishan <[email protected]>2018-12-29 13:09:42 +0800
committerHaishan <[email protected]>2018-12-29 13:09:42 +0800
commit5c4a7da7191a68f2c8d909b93e153c4cb13b8eef (patch)
tree20e9a963bc0002ce1272ff00325c6249a460745e /src
parent4be0aca6c1fba6854a49d9286c932d39556aa270 (diff)
feat: support parse port and secret in query string
Diffstat (limited to 'src')
-rw-r--r--src/components/Root.module.scss2
-rw-r--r--src/ducks/app.js19
2 files changed, 20 insertions, 1 deletions
diff --git a/src/components/Root.module.scss b/src/components/Root.module.scss
index 2ca2546..4c3653b 100644
--- a/src/components/Root.module.scss
+++ b/src/components/Root.module.scss
@@ -13,7 +13,7 @@
.content {
flex-grow: 1;
- overflow: scroll;
+ overflow: auto;
// background: #202020;
// $w: 7px;
diff --git a/src/ducks/app.js b/src/ducks/app.js
index 36bdd29..db32e17 100644
--- a/src/ducks/app.js
+++ b/src/ducks/app.js
@@ -60,11 +60,30 @@ const defaultState = {
theme: 'dark'
};
+function parseConfigQueryString() {
+ const { search } = location;
+ const collector = {};
+ if (typeof search !== 'string' || search === '') return collector;
+ const qs = search.replace(/^\?/, '').split('&');
+ for (let i = 0; i < qs.length; i++) {
+ const [k, v] = qs[i].split('=');
+ collector[k] = encodeURIComponent(v);
+ }
+ return collector;
+}
+
function getInitialState() {
let s = loadState(StorageKey);
if (!s) s = defaultState;
// TODO flat clashAPIConfig?
+ const configQuery = parseConfigQueryString();
+ if (configQuery.port) {
+ s.clashAPIConfig.port = configQuery.port;
+ }
+ if (configQuery.secret) {
+ s.clashAPIConfig.secret = configQuery.secret;
+ }
// set initial theme
setTheme(s.theme);
return s;