fix: relative images are not loaded after closing a tab (#810)

This commit is contained in:
Felix Häusler 2019-03-25 15:57:18 +01:00 committed by Ran Luo
parent c6def5a726
commit 94066706f5
2 changed files with 9 additions and 4 deletions

View File

@ -78,7 +78,7 @@ This update **fixes a XSS security vulnerability** when exporting a document.
- Emojis don't work properly (#769) - Emojis don't work properly (#769)
- Fixed multiple parser issues (update marked.js to v0.6.1) - Fixed multiple parser issues (update marked.js to v0.6.1)
- Fixed [...] is displayed in gray and orange (#432) - Fixed [...] is displayed in gray and orange (#432)
- Fixed an issue that relative images are not loaded after closing a tab
### 0.13.65 ### 0.13.65

View File

@ -44,7 +44,8 @@ const mutations = {
const fileState = state.tabs[index] || state.tabs[index - 1] || {} const fileState = state.tabs[index] || state.tabs[index - 1] || {}
state.currentFile = fileState state.currentFile = fileState
if (typeof fileState.markdown === 'string') { if (typeof fileState.markdown === 'string') {
const { markdown, cursor, history } = fileState const { markdown, cursor, history, pathname } = fileState
window.DIRNAME = pathname ? path.dirname(pathname) : ''
bus.$emit('file-changed', { markdown, cursor, renderCursor: true, history }) bus.$emit('file-changed', { markdown, cursor, renderCursor: true, history })
} }
} }
@ -112,12 +113,16 @@ const mutations = {
arr.forEach(id => { arr.forEach(id => {
const index = state.tabs.findIndex(f => f.id === id) const index = state.tabs.findIndex(f => f.id === id)
state.tabs.splice(index, 1) state.tabs.splice(index, 1)
if (state.currentFile.id === id) state.currentFile = {} if (state.currentFile.id === id) {
state.currentFile = {}
window.DIRNAME = ''
}
}) })
if (!state.currentFile.id && state.tabs.length) { if (!state.currentFile.id && state.tabs.length) {
state.currentFile = state.tabs[0] state.currentFile = state.tabs[0]
if (typeof state.currentFile.markdown === 'string') { if (typeof state.currentFile.markdown === 'string') {
const { markdown, cursor, history } = state.currentFile const { markdown, cursor, history, pathname } = state.currentFile
window.DIRNAME = pathname ? path.dirname(pathname) : ''
bus.$emit('file-changed', { markdown, cursor, renderCursor: true, history }) bus.$emit('file-changed', { markdown, cursor, renderCursor: true, history })
} }
} }