1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

use default theme if theme doesn't exist

This commit is contained in:
Dick Choi
2016-10-04 11:07:21 +09:00
parent 90b490c28b
commit 92fd7ac09c
3 changed files with 20 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ const { remote, ipcRenderer } = require('electron')
const { app, Menu } = remote const { app, Menu } = remote
const path = require('path') const path = require('path')
const store = require('./store') const store = require('./store')
const consts = require('browser/lib/consts')
nodeIpc.config.id = 'finder' nodeIpc.config.id = 'finder'
nodeIpc.config.retry = 1500 nodeIpc.config.retry = 1500
@@ -94,6 +95,11 @@ nodeIpc.connectTo(
editorTheme.setAttribute('rel', 'stylesheet') editorTheme.setAttribute('rel', 'stylesheet')
document.head.appendChild(editorTheme) document.head.appendChild(editorTheme)
} }
config.editor.theme = consts.THEMES.some((theme) => theme === config.editor.theme)
? config.editor.theme
: 'default'
if (config.editor.theme !== 'default') { if (config.editor.theme !== 'default') {
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css') editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css')
} }

View File

@@ -30,7 +30,7 @@ const consts = {
'Dodger Blue', 'Dodger Blue',
'Violet Eggplant' 'Violet Eggplant'
], ],
THEMES: themes THEMES: ['default'].concat(themes)
} }
module.exports = consts module.exports = consts

View File

@@ -3,6 +3,7 @@ import _ from 'lodash'
const OSX = global.process.platform === 'darwin' const OSX = global.process.platform === 'darwin'
const electron = require('electron') const electron = require('electron')
const { ipcRenderer } = electron const { ipcRenderer } = electron
const consts = require('browser/lib/consts')
let isInitialized = false let isInitialized = false
@@ -75,6 +76,11 @@ function get () {
editorTheme.setAttribute('rel', 'stylesheet') editorTheme.setAttribute('rel', 'stylesheet')
document.head.appendChild(editorTheme) document.head.appendChild(editorTheme)
} }
config.editor.theme = consts.THEMES.some((theme) => theme === config.editor.theme)
? config.editor.theme
: 'default'
if (config.editor.theme !== 'default') { if (config.editor.theme !== 'default') {
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css') editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css')
} }
@@ -102,7 +108,13 @@ function set (updates) {
editorTheme.setAttribute('rel', 'stylesheet') editorTheme.setAttribute('rel', 'stylesheet')
document.head.appendChild(editorTheme) document.head.appendChild(editorTheme)
} }
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + newConfig.editor.theme + '.css') let newTheme = consts.THEMES.some((theme) => theme === newConfig.editor.theme)
? newConfig.editor.theme
: 'default'
if (newTheme !== 'default') {
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + newTheme + '.css')
}
ipcRenderer.send('config-renew', { ipcRenderer.send('config-renew', {
config: get() config: get()