From 923a5fa468d5dfde26852832dec4348255de2fdc Mon Sep 17 00:00:00 2001 From: purocean Date: Sun, 31 Oct 2021 12:32:06 +0800 Subject: [PATCH] =?UTF-8?q?upd:=20=E6=8F=92=E5=85=A5=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8C=E4=BB=93=E5=BA=93=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/plugins/editor-attachment.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/plugins/editor-attachment.ts b/src/renderer/plugins/editor-attachment.ts index 5d66c2fa..72bf4c7d 100644 --- a/src/renderer/plugins/editor-attachment.ts +++ b/src/renderer/plugins/editor-attachment.ts @@ -1,13 +1,15 @@ import dayjs from 'dayjs' import { insert, whenEditorReady } from '@fe/services/editor' import type { Plugin } from '@fe/context' -import store from '@fe/support/store' -import { encodeMarkdownLink } from '@fe/utils' import type { Doc } from '@fe/types' +import { encodeMarkdownLink } from '@fe/utils' import { dirname, isBelongTo, join, relative } from '@fe/utils/path' import { getActionHandler } from '@fe/core/action' +import store from '@fe/support/store' import { refreshTree } from '@fe/services/tree' import { upload } from '@fe/services/base' +import { isSameRepo } from '@fe/services/document' +import { useToast } from '@fe/support/ui/toast' async function uploadFile (file: any, asImage: boolean) { if (!store.state.currentFile) { @@ -41,6 +43,11 @@ function addAttachment (asImage = false) { function addDocument (doc: Doc) { const file = store.state.currentFile if (file) { + if (!isSameRepo(file, doc)) { + useToast().show('warning', '不能插入不同仓库的文档') + return + } + const cwd = dirname(file.path) const filePath = isBelongTo(cwd, doc.path) ? relative(cwd, doc.path)