diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index cfed0175..c5465eff 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -45,6 +45,7 @@ const CSS_FILES = [ `${appPath}/node_modules/codemirror/lib/codemirror.css`, `${appPath}/node_modules/react-image-carousel/lib/css/main.min.css` ] +const win = global.process.platform === 'win32' function buildStyle ( fontFamily, @@ -677,7 +678,9 @@ export default class MarkdownPreview extends React.Component { GetCodeThemeLink (name) { const theme = consts.THEMES.find(theme => theme.name === name) - return theme ? theme.path : `${appPath}/node_modules/codemirror/theme/elegant.css` + return theme + ? (win ? theme.path : `../${theme.path}`) + : `${appPath}/node_modules/codemirror/theme/elegant.css` } rewriteIframe () { diff --git a/browser/lib/consts.js b/browser/lib/consts.js index 9c993055..eeff397b 100644 --- a/browser/lib/consts.js +++ b/browser/lib/consts.js @@ -7,9 +7,12 @@ const CODEMIRROR_THEME_PATH = 'node_modules/codemirror/theme' const CODEMIRROR_EXTRA_THEME_PATH = 'extra_scripts/codemirror/theme' const isProduction = process.env.NODE_ENV === 'production' +const exePath = path.dirname(app.getPath('exe')) +const appPath = path.join(exePath, 'resources', 'app') + const paths = [ - isProduction ? path.join(app.getAppPath(), CODEMIRROR_THEME_PATH) : path.resolve(CODEMIRROR_THEME_PATH), - isProduction ? path.join(app.getAppPath(), CODEMIRROR_EXTRA_THEME_PATH) : path.resolve(CODEMIRROR_EXTRA_THEME_PATH) + isProduction ? path.join(appPath, CODEMIRROR_THEME_PATH) : path.resolve(CODEMIRROR_THEME_PATH), + isProduction ? path.join(appPath, CODEMIRROR_EXTRA_THEME_PATH) : path.resolve(CODEMIRROR_EXTRA_THEME_PATH) ] const themes = paths diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index d3f91ac4..4a44f148 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -142,7 +142,7 @@ function get () { const theme = consts.THEMES.find(theme => theme.name === config.editor.theme) if (theme) { - editorTheme.setAttribute('href', theme.path) + editorTheme.setAttribute('href', win ? theme.path : `../${theme.path}`) } else { config.editor.theme = 'default' } @@ -190,7 +190,7 @@ function set (updates) { const newTheme = consts.THEMES.find(theme => theme.name === newConfig.editor.theme) if (newTheme) { - editorTheme.setAttribute('href', newTheme.path) + editorTheme.setAttribute('href', win ? newTheme.path : `../${newTheme.path}`) } ipcRenderer.send('config-renew', { diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 5993a165..29071a8f 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -14,6 +14,7 @@ import { getLanguages } from 'browser/lib/Languages' import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily' const OSX = global.process.platform === 'darwin' +const win = global.process.platform === 'win32' const electron = require('electron') const ipc = electron.ipcRenderer @@ -135,7 +136,7 @@ class UiTab extends React.Component { const theme = consts.THEMES.find(theme => theme.name === newCodemirrorTheme) if (theme) { - checkHighLight.setAttribute('href', theme.path) + checkHighLight.setAttribute('href', win ? theme.path : `../${theme.path}`) } }