From 0b20e145caa224a61a5955a2c8bc4fe6975ab000 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sat, 14 Mar 2020 15:57:16 +0800 Subject: [PATCH] feat: support set theme with querystring --- src/store/app.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/store/app.js b/src/store/app.js index da0d775..465a564 100644 --- a/src/store/app.js +++ b/src/store/app.js @@ -105,15 +105,20 @@ export function initialState() { s = { ...defaultState, ...s }; // TODO flat clashAPIConfig? - const configQuery = parseConfigQueryString(); - if (configQuery.hostname) { - s.clashAPIConfig.hostname = configQuery.hostname; + const query = parseConfigQueryString(); + if (query.hostname) { + s.clashAPIConfig.hostname = query.hostname; } - if (configQuery.port) { - s.clashAPIConfig.port = configQuery.port; + if (query.port) { + s.clashAPIConfig.port = query.port; } - if (configQuery.secret) { - s.clashAPIConfig.secret = configQuery.secret; + if (query.secret) { + s.clashAPIConfig.secret = query.secret; + } + if (query.theme) { + if (query.theme === 'dark' || query.theme === 'light') { + s.theme = query.theme; + } } // set initial theme setTheme(s.theme);