mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Code Style Improvements
This commit is contained in:
@@ -17,7 +17,7 @@ import store from 'browser/main/store'
|
|||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
import { getLocales } from 'browser/lib/Languages'
|
import { getLocales } from 'browser/lib/Languages'
|
||||||
import applyShortcuts from 'browser/main/lib/shortcutManager'
|
import applyShortcuts from 'browser/main/lib/shortcutManager'
|
||||||
import theme from 'browser/main/lib/ThemeManager'
|
import {chooseTheme, applyTheme} from 'browser/main/lib/ThemeManager'
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { remote } = electron
|
const { remote } = electron
|
||||||
@@ -142,11 +142,11 @@ class Main extends React.Component {
|
|||||||
const { dispatch, config } = this.props
|
const { dispatch, config } = this.props
|
||||||
|
|
||||||
this.refreshTheme = setInterval(() => {
|
this.refreshTheme = setInterval(() => {
|
||||||
theme.choose(ConfigManager.get().ui)
|
chooseTheme(ConfigManager.get().ui)
|
||||||
}, 5 * 1000)
|
}, 5 * 1000)
|
||||||
|
|
||||||
theme.choose(config.ui)
|
chooseTheme(config.ui)
|
||||||
theme.apply(config.ui.theme)
|
applyTheme(config.ui.theme)
|
||||||
|
|
||||||
if (getLocales().indexOf(config.ui.language) !== -1) {
|
if (getLocales().indexOf(config.ui.language) !== -1) {
|
||||||
i18n.setLocale(config.ui.language)
|
i18n.setLocale(config.ui.language)
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import _ from 'lodash'
|
|||||||
import RcParser from 'browser/lib/RcParser'
|
import RcParser from 'browser/lib/RcParser'
|
||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
import ee from 'browser/main/lib/eventEmitter'
|
import ee from 'browser/main/lib/eventEmitter'
|
||||||
import theme from 'browser/main/lib/ThemeManager'
|
import {chooseTheme, applyTheme} from 'browser/main/lib/ThemeManager'
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
const win = global.process.platform === 'win32'
|
const win = global.process.platform === 'win32'
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
@@ -151,8 +150,8 @@ function set (updates) {
|
|||||||
if (!validate(newConfig)) throw new Error('INVALID CONFIG')
|
if (!validate(newConfig)) throw new Error('INVALID CONFIG')
|
||||||
_save(newConfig)
|
_save(newConfig)
|
||||||
|
|
||||||
theme.choose(newConfig.ui)
|
chooseTheme(newConfig.ui)
|
||||||
theme.apply(newConfig.ui.theme)
|
applyTheme(newConfig.ui.theme)
|
||||||
|
|
||||||
i18n.setLocale(newConfig.ui.language)
|
i18n.setLocale(newConfig.ui.language)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
function choose (ui) {
|
const chooseTheme = (ui) => {
|
||||||
console.log(ui.enableScheduleTheme)
|
|
||||||
if (!ui.enableScheduleTheme) {
|
if (!ui.enableScheduleTheme) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -10,31 +9,25 @@ function choose (ui) {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
const minutes = now.getHours() * 60 + now.getMinutes()
|
const minutes = now.getHours() * 60 + now.getMinutes()
|
||||||
|
|
||||||
console.log(ui.scheduleStart, minutes, ui.scheduleEnd)
|
const isEndAfterStart = end > start
|
||||||
|
const isBetweenStartAndEnd = minutes >= start && minutes <= end
|
||||||
|
const isBetweenEndAndStart = (minutes >= start || minutes <= end)
|
||||||
|
|
||||||
if ((end > start && minutes >= start && minutes <= end) ||
|
if ((isEndAfterStart && isBetweenStartAndEnd) || (!isEndAfterStart && isBetweenEndAndStart)) {
|
||||||
(start > end && (minutes >= start || minutes <= end))) {
|
|
||||||
console.log('SC', ui.theme, ui.scheduledTheme)
|
|
||||||
if (ui.theme !== ui.scheduledTheme) {
|
if (ui.theme !== ui.scheduledTheme) {
|
||||||
ui.defaultTheme = ui.theme
|
ui.defaultTheme = ui.theme
|
||||||
ui.theme = ui.scheduledTheme
|
ui.theme = ui.scheduledTheme
|
||||||
apply(ui.theme)
|
applyTheme(ui.theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(ui.defaultTheme, ui.theme)
|
|
||||||
} else {
|
} else {
|
||||||
console.log('TH', ui.theme, ui.defaultTheme)
|
|
||||||
if (ui.theme !== ui.defaultTheme) {
|
if (ui.theme !== ui.defaultTheme) {
|
||||||
ui.theme = ui.defaultTheme
|
ui.theme = ui.defaultTheme
|
||||||
apply(ui.theme)
|
applyTheme(ui.theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(ui.theme)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function apply (theme) {
|
const applyTheme = (theme) => {
|
||||||
console.log('Apply ', theme)
|
|
||||||
const supportedThemes = ['dark', 'white', 'solarized-dark', 'monokai', 'dracula']
|
const supportedThemes = ['dark', 'white', 'solarized-dark', 'monokai', 'dracula']
|
||||||
if (supportedThemes.indexOf(theme) !== -1) {
|
if (supportedThemes.indexOf(theme) !== -1) {
|
||||||
document.body.setAttribute('data-theme', theme)
|
document.body.setAttribute('data-theme', theme)
|
||||||
@@ -43,7 +36,7 @@ function apply (theme) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
module.exports = {
|
||||||
choose,
|
chooseTheme,
|
||||||
apply
|
applyTheme
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user