From 628af620bbfd22e8c363292615d0f00450015fc6 Mon Sep 17 00:00:00 2001 From: panda Date: Sun, 27 Mar 2022 16:40:58 +0800 Subject: [PATCH 1/2] 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; }) => { From 0ef4fa41ddde45eccfc88a3abc9a15573219e21a Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 27 Mar 2022 16:42:37 +0800 Subject: [PATCH 2/2] elastic: revert "use term op instead of match" (false positive) (#330) --- packages/elastic/script.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/elastic/script.ts b/packages/elastic/script.ts index 7b93a9061..0e269e476 100644 --- a/packages/elastic/script.ts +++ b/packages/elastic/script.ts @@ -49,7 +49,7 @@ global.Hydro.lib.problemSearch = async (domainId, q, opts) => { post_filter: { bool: { minimum_should_match: 1, - should: domainIds.map((i) => ({ term: { domainId: i } })), + should: domainIds.map((i) => ({ match: { domainId: i } })), }, }, }); @@ -64,7 +64,7 @@ export const description = 'Elastic problem search re-index'; export async function run({ domainId }, report) { try { - if (domainId) await client.deleteByQuery({ index: 'problem', query: { term: { domainId } } }); + if (domainId) await client.deleteByQuery({ index: 'problem', query: { match: { domainId } } }); else await client.deleteByQuery({ index: 'problem', query: { match_all: {} } }); } catch (e) { if (!e.message.includes('index_not_found_exception')) throw e;