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