mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00
parent
82d82e6ac3
commit
c902f6b76b
@ -180,7 +180,7 @@ export const getImageInfo = src => {
|
||||
const imageExtension = EXT_REG.test(src)
|
||||
const isUrl = URL_REG.test(src)
|
||||
if (imageExtension) {
|
||||
if (isUrl || !window.__dirname) {
|
||||
if (isUrl || !window.DIRNAME) {
|
||||
return {
|
||||
isUnknownType: false,
|
||||
src
|
||||
@ -188,7 +188,7 @@ export const getImageInfo = src => {
|
||||
} else {
|
||||
return {
|
||||
isUnknownType: false,
|
||||
src: 'file://' + path.resolve(window.__dirname, src)
|
||||
src: 'file://' + path.resolve(window.DIRNAME, src)
|
||||
}
|
||||
}
|
||||
} else if (isUrl && !imageExtension) {
|
||||
|
@ -6,7 +6,6 @@ import { getOptionsFromState, getSingleFileState, getBlankFileState } from './he
|
||||
import notice from '../services/notification'
|
||||
|
||||
const toc = require('markdown-toc')
|
||||
|
||||
const state = {
|
||||
lineEnding: 'lf',
|
||||
currentFile: {},
|
||||
@ -28,7 +27,8 @@ const mutations = {
|
||||
SET_CURRENT_FILE (state, currentFile) {
|
||||
const oldCurrentFile = state.currentFile
|
||||
if (!oldCurrentFile.id || oldCurrentFile.id !== currentFile.id) {
|
||||
const { markdown, cursor, history } = currentFile
|
||||
const { markdown, cursor, history, pathname } = currentFile
|
||||
window.DIRNAME = pathname ? path.dirname(pathname) : ''
|
||||
// set state first, then emit file changed event
|
||||
state.currentFile = currentFile
|
||||
bus.$emit('file-changed', { markdown, cursor, renderCursor: true, history })
|
||||
@ -53,8 +53,8 @@ const mutations = {
|
||||
},
|
||||
SET_PATHNAME (state, file) {
|
||||
const { filename, pathname, id } = file
|
||||
if (id === state.currentFile.id) {
|
||||
window.__dirname = path.dirname(pathname)
|
||||
if (id === state.currentFile.id && pathname) {
|
||||
window.DIRNAME = path.dirname(pathname)
|
||||
}
|
||||
|
||||
const targetFile = state.tabs.filter(f => f.id === id)[0]
|
||||
|
Loading…
Reference in New Issue
Block a user