From 628af620bbfd22e8c363292615d0f00450015fc6 Mon Sep 17 00:00:00 2001 From: panda Date: Sun, 27 Mar 2022 16:40:58 +0800 Subject: [PATCH] ui: fix vditor upload in other pages (#329) --- packages/ui-default/components/editor/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ui-default/components/editor/index.ts b/packages/ui-default/components/editor/index.ts index 25f7dd101..001da120b 100644 --- a/packages/ui-default/components/editor/index.ts +++ b/packages/ui-default/components/editor/index.ts @@ -162,6 +162,7 @@ export default class Editor extends DOMAttachedObject { async initVditor() { const pagename = document.documentElement.getAttribute('data-page'); + const isProblemPage = ['problem_create', 'problem_edit'].includes(pagename); const isProblemEdit = pagename === 'problem_edit'; const { default: Vditor } = await import('vditor'); const { $dom } = this; @@ -209,7 +210,7 @@ export default class Editor extends DOMAttachedObject { }, }) .then(() => { - this.vditor.insertValue(`${wrapper.join(`file://${filename}`)} `); + this.vditor.insertValue(`${wrapper.join(`${isProblemPage ? 'file://' : `/file/${UserContext._id}/`}${filename}`)} `); this.vditor.vditor.tip.hide(); }) .catch((e: { message: string; }) => {