Skip to content

Commit

Permalink
markdown下载外链图片
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiWenda committed Aug 19, 2024
1 parent 692d090 commit 8bb9550
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ async function startExpress(args) {
const filename = picUrl.split('/').pop().replace(/[^\w]/g, '')
const distinctFileName = genRandomFileName(filename)
downloadImage(picUrl, path.join(gitHome, IMAGES_FOLDER, distinctFileName)).then(() => {
res.send({data: {originalURL: picUrl, url: `http://localhost:${port}/api/${IMAGES_FOLDER}/${distinctFileName}`}})
res.send({msg: '', code: 0, data: {originalURL: picUrl, url: `http://localhost:${port}/api/${IMAGES_FOLDER}/${distinctFileName}`}})
}).catch(() => {
res.send({data: {originalURL: picUrl, url: picUrl}})
res.send({msg: '', code: 0, data: {originalURL: picUrl, url: picUrl}})
})
})
// app.post('/api/ocr_image', multer().single('file'), async function(req, res) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function LayoutComponent(props: {session: Session, config: Config, pluginManager
if (modalName === 'md') {
setTimeout(() => {
const vditor = new Vditor('vditor', {
mode: 'sv',
upload: {
linkToImgUrl: API_BASE_URL + '/download_image',
handler: (files: File[]) => new Promise<null>(resolve => {
uploadImage(files[0],
props.session.clientStore.getClientSetting('curDocId'),
Expand All @@ -156,7 +156,7 @@ function LayoutComponent(props: {session: Session, config: Config, pluginManager
height: window.innerHeight - 360,
toolbar: ['quote', '|', 'headings', 'bold', 'italic', 'strike', 'inline-code', '|',
'list', 'ordered-list', 'check' , '|', 'link', 'upload', 'table', 'code', '|',
'insert-before', 'insert-after', 'undo', 'redo'],
'insert-before', 'insert-after', 'undo', 'redo', '|', 'edit-mode'],
after: () => {
vditor.setValue(data.md || '');
setVd(vditor);
Expand Down

0 comments on commit 8bb9550

Please sign in to comment.