Skip to content

Commit ba6eb4f

Browse files
AWolf81Rokt33r
authored andcommitted
fix path Linux
1 parent 38fcee3 commit ba6eb4f

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

browser/components/MarkdownPreview.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const CSS_FILES = [
4545
`${appPath}/node_modules/codemirror/lib/codemirror.css`,
4646
`${appPath}/node_modules/react-image-carousel/lib/css/main.min.css`
4747
]
48+
const win = global.process.platform === 'win32'
4849

4950
function buildStyle (
5051
fontFamily,
@@ -677,7 +678,9 @@ export default class MarkdownPreview extends React.Component {
677678
GetCodeThemeLink (name) {
678679
const theme = consts.THEMES.find(theme => theme.name === name)
679680

680-
return theme ? theme.path : `${appPath}/node_modules/codemirror/theme/elegant.css`
681+
return theme
682+
? (win ? theme.path : `../${theme.path}`)
683+
: `${appPath}/node_modules/codemirror/theme/elegant.css`
681684
}
682685

683686
rewriteIframe () {

browser/lib/consts.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ const CODEMIRROR_THEME_PATH = 'node_modules/codemirror/theme'
77
const CODEMIRROR_EXTRA_THEME_PATH = 'extra_scripts/codemirror/theme'
88

99
const isProduction = process.env.NODE_ENV === 'production'
10+
const exePath = path.dirname(app.getPath('exe'))
11+
const appPath = path.join(exePath, 'resources', 'app')
12+
1013
const paths = [
11-
isProduction ? path.join(app.getAppPath(), CODEMIRROR_THEME_PATH) : path.resolve(CODEMIRROR_THEME_PATH),
12-
isProduction ? path.join(app.getAppPath(), CODEMIRROR_EXTRA_THEME_PATH) : path.resolve(CODEMIRROR_EXTRA_THEME_PATH)
14+
isProduction ? path.join(appPath, CODEMIRROR_THEME_PATH) : path.resolve(CODEMIRROR_THEME_PATH),
15+
isProduction ? path.join(appPath, CODEMIRROR_EXTRA_THEME_PATH) : path.resolve(CODEMIRROR_EXTRA_THEME_PATH)
1316
]
1417

1518
const themes = paths

browser/main/lib/ConfigManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function get () {
142142
const theme = consts.THEMES.find(theme => theme.name === config.editor.theme)
143143

144144
if (theme) {
145-
editorTheme.setAttribute('href', theme.path)
145+
editorTheme.setAttribute('href', win ? theme.path : `../${theme.path}`)
146146
} else {
147147
config.editor.theme = 'default'
148148
}
@@ -190,7 +190,7 @@ function set (updates) {
190190
const newTheme = consts.THEMES.find(theme => theme.name === newConfig.editor.theme)
191191

192192
if (newTheme) {
193-
editorTheme.setAttribute('href', newTheme.path)
193+
editorTheme.setAttribute('href', win ? newTheme.path : `../${newTheme.path}`)
194194
}
195195

196196
ipcRenderer.send('config-renew', {

browser/main/modals/PreferencesModal/UiTab.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getLanguages } from 'browser/lib/Languages'
1414
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
1515

1616
const OSX = global.process.platform === 'darwin'
17+
const win = global.process.platform === 'win32'
1718

1819
const electron = require('electron')
1920
const ipc = electron.ipcRenderer
@@ -135,7 +136,7 @@ class UiTab extends React.Component {
135136
const theme = consts.THEMES.find(theme => theme.name === newCodemirrorTheme)
136137

137138
if (theme) {
138-
checkHighLight.setAttribute('href', theme.path)
139+
checkHighLight.setAttribute('href', win ? theme.path : `../${theme.path}`)
139140
}
140141
}
141142

0 commit comments

Comments
 (0)