From 230c3bb5b2d1d9badfd05fa862aeeccb071d564f Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 8 Jan 2023 18:05:02 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=BD=D0=B0=D0=B4=20=D0=BD?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D1=8B=D0=BC=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC?= =?UTF-8?q?=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/SettingsPage/ViewTab/Mode/Mode.vue | 7 +++ client/store/modules/reader.js | 45 ++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/client/components/Reader/SettingsPage/ViewTab/Mode/Mode.vue b/client/components/Reader/SettingsPage/ViewTab/Mode/Mode.vue index 8b7b5a07..377afaf1 100644 --- a/client/components/Reader/SettingsPage/ViewTab/Mode/Mode.vue +++ b/client/components/Reader/SettingsPage/ViewTab/Mode/Mode.vue @@ -5,6 +5,13 @@ Режим +
+
+
+ +
+
+
diff --git a/client/store/modules/reader.js b/client/store/modules/reader.js index 3b9e3cc4..f26b8ebb 100644 --- a/client/store/modules/reader.js +++ b/client/store/modules/reader.js @@ -157,6 +157,10 @@ const settingDefaults = { statusBarColorAlpha: 0.4, statusBarClickOpen: true, + nightMode: false, //ночной режим + dayColorSets: {}, + nightColorSets: {}, + scrollingDelay: 3000,// замедление, ms scrollingType: 'ease-in-out', //linear, ease, ease-in, ease-out, ease-in-out @@ -218,6 +222,8 @@ const diffExclude = []; for (const hotKey of hotKeys) diffExclude.push(`userHotKeys/${hotKey.name}`); diffExclude.push('userWallpapers'); +diffExclude.push('dayColorSets'); +diffExclude.push('nightColorSets'); function addDefaultsToSettings(settings) { const diff = utils.getObjDiff(settings, settingDefaults, {exclude: diffExclude}); @@ -228,6 +234,33 @@ function addDefaultsToSettings(settings) { return false; } +const colorSetsList = [ + 'textColor', + 'backgroundColor', + 'wallpaper', + 'statusBarColorAsText', + 'statusBarColor', + 'statusBarColorAlpha', + 'dualDivColorAsText', + 'dualDivColor', + 'dualDivColorAlpha', +]; + +function saveColorSets(nightMode, settings) { + const target = (nightMode ? settings.nightColorSets : settings.dayColorSets); + for (const prop of colorSetsList) { + target[prop] = settings[prop]; + } +} + +function restoreColorSets(nightMode, settings) { + const source = (nightMode ? settings.nightColorSets : settings.dayColorSets); + for (const prop of colorSetsList) { + if (utils.hasProp(source, prop)) + settings[prop] = source[prop]; + } +} + function getLibsDefaults(mode = 'reader') { const result = { startLink: '', @@ -333,12 +366,14 @@ const mutations = { }, setSettings(state, value) { const newSettings = Object.assign({}, state.settings, value); - const added = addDefaultsToSettings(newSettings); - if (added) { - state.settings = added; - } else { - state.settings = newSettings; + //переключение режима день-ночь + const prevNightMode = state.settings.nightMode; + if (utils.hasProp(value, 'nightMode') && prevNightMode != value.nightMode) { + saveColorSets(prevNightMode, newSettings); + restoreColorSets(newSettings.nightMode, newSettings); } + + state.settings = newSettings; }, setSettingsRev(state, value) { state.settingsRev = Object.assign({}, state.settingsRev, value);