调整抓取图片到本地的逻辑

This commit is contained in:
purocean
2019-05-03 19:59:56 +08:00
parent d3632e1b94
commit a50b2273b6
4 changed files with 22 additions and 7 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
'@vue/standard'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
+1
View File
@@ -23,6 +23,7 @@
"markdown-it-katex": "^2.0.3",
"markdown-it-multimd-table": "^3.1.3",
"markdown-it-task-lists": "^2.1.1",
"mime-types": "^2.1.24",
"normalize.css": "^8.0.1",
"socket.io-client": "^2.2.0",
"vue": "^2.6.10",
+10 -6
View File
@@ -38,6 +38,7 @@
import 'github-markdown-css/github-markdown.css'
import 'highlight.js/styles/atom-one-dark.css'
import _ from 'lodash'
import mime from 'mime-types'
import Markdown from 'markdown-it'
import TaskLists from 'markdown-it-task-lists'
import katex from 'markdown-it-katex'
@@ -209,12 +210,15 @@ export default {
img.src.startsWith('http://') ||
img.src.startsWith('https://')
) {
const ximg = document.createElement('img')
ximg.crossOrigin = 'anonymous'
ximg.src = `api/proxy?url=${encodeURI(img.src)}`
ximg.onload = () => {
transform(ximg)
}
window.fetch(`api/proxy?url=${encodeURI(img.src)}`).then(r => {
r.blob().then(blob => {
const imgFile = new File([blob], 'file.' + mime.extension(r.headers.get('content-type')))
file.upload(this.fileRepo, this.filePath, imgFile, result => {
this.$bus.emit('tree-refresh')
this.$bus.emit('editor-replace-value', img.src, result.relativePath)
})
})
})
}
return
+10
View File
@@ -4546,6 +4546,10 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"
mime-db@1.40.0:
version "1.40.0"
resolved "https://registry.npm.taobao.org/mime-db/download/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32"
"mime-db@>= 1.38.0 < 2":
version "1.39.0"
resolved "http://registry.npm.taobao.org/mime-db/download/mime-db-1.39.0.tgz#f95a20275742f7d2ad0429acfe40f4233543780e"
@@ -4560,6 +4564,12 @@ mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.19:
dependencies:
mime-db "~1.38.0"
mime-types@^2.1.24:
version "2.1.24"
resolved "https://registry.npm.taobao.org/mime-types/download/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81"
dependencies:
mime-db "1.40.0"
mime@1.4.1:
version "1.4.1"
resolved "http://registry.npm.taobao.org/mime/download/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6"