From 6ab91ded00fe0e4ef0c1b161ae0a00c05c52d9e3 Mon Sep 17 00:00:00 2001 From: TobiasTao <952530904@qq.com> Date: Sat, 4 Dec 2021 13:35:39 +0800 Subject: [PATCH] :bug: fix #44 --- src/mdEditor.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mdEditor.ts b/src/mdEditor.ts index ce172a0..a96998c 100644 --- a/src/mdEditor.ts +++ b/src/mdEditor.ts @@ -35,8 +35,6 @@ export class MarkdownEditorProvider implements vscode.CustomTextEditorProvider { let picgo: VSPicgo; - const mdFilepath = document.uri.fsPath; - let linkBase = webviewPanel.webview .asWebviewUri(document.uri) .toString(true) @@ -175,6 +173,9 @@ export class MarkdownEditorProvider implements vscode.CustomTextEditorProvider { case 'img': let imgName = e.imgName; const imgData = Buffer.from(e.file, 'binary'); + if (!fs.existsSync(imgStoreDir)) { + fs.mkdirSync(imgStoreDir, { recursive: true }); + } let imgStorePath = path.join(imgStoreDir, imgName); console.log('imgStorePath: ' + imgStorePath); fs.writeFile(imgStorePath, imgData, (err) => {