From 82b4b75bb720a10189f33de16d54ca7bc57547d1 Mon Sep 17 00:00:00 2001 From: LeezQ Date: Fri, 12 Aug 2022 16:29:36 +0800 Subject: [PATCH] fix: multi event bind #241 (#255) --- .../pages/app/[appid]/cloudfunction/[id].vue | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/web/src/pages/app/[appid]/cloudfunction/[id].vue b/packages/web/src/pages/app/[appid]/cloudfunction/[id].vue index 51c670e9795..58486ae3293 100644 --- a/packages/web/src/pages/app/[appid]/cloudfunction/[id].vue +++ b/packages/web/src/pages/app/[appid]/cloudfunction/[id].vue @@ -100,16 +100,19 @@ async function updateFunc(showTip = true) { } async function launch() { - const r = await compileFunctionCode(func._id, { - code: value, - }).finally(() => { - loading = false - }) - if (loading) return loading = true + + const r = await compileFunctionCode(func._id, { + code: value, + }).finally( + () => { + loading = false + }, + ) + const param = parseInvokeParam(invokeParams) const res = await launchFunction(r.data, param, debug_token).finally( () => { @@ -318,13 +321,28 @@ onMounted(async () => { nextTick(() => { updateEditorHeight() - document.removeEventListener('keydown', bindShortKey, false) - document.addEventListener('keydown', bindShortKey, false) window.addEventListener('resize', debounce(() => { updateEditorHeight() })) }) }) + +onBeforeUnmount(() => { + document.removeEventListener('keydown', bindShortKey, false) +}) + +onUnmounted(() => { + document.removeEventListener('keydown', bindShortKey, false) +}) + +onActivated(() => { + document.removeEventListener('keydown', bindShortKey, false) + document.addEventListener('keydown', bindShortKey, false) +}) + +onDeactivated(() => { + document.removeEventListener('keydown', bindShortKey, false) +})