From b4f4c71f85587c6d5165e10ea7fe9f17eb918c1b Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Fri, 20 Oct 2023 13:50:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E4=BC=9A=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/optional/shortcuts.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/optional/shortcuts.js b/src/services/optional/shortcuts.js index aa9a6ba3..5a5c6959 100644 --- a/src/services/optional/shortcuts.js +++ b/src/services/optional/shortcuts.js @@ -76,8 +76,11 @@ const methods = { }; store.watch( - () => store.getters['data/computedSettings'], - (computedSettings) => { + () => ({ + computedSettings: store.getters['data/computedSettings'], + isCurrentEditable: store.getters['content/isCurrentEditable'], + }), + ({ computedSettings, isCurrentEditable }) => { Mousetrap.reset(); Object.entries(computedSettings.shortcuts).forEach(([key, shortcut]) => { @@ -90,7 +93,7 @@ store.watch( if (Object.prototype.hasOwnProperty.call(methods, method)) { try { // editor is editable or 一些非编辑模式下支持的快捷键 - if (store.getters['content/isCurrentEditable'] || noEditableShortcutMethods.indexOf(method) !== -1) { + if (isCurrentEditable || noEditableShortcutMethods.indexOf(method) !== -1) { Mousetrap.bind(`${key}`, () => !methods[method].apply(null, params)); } } catch (e) { @@ -99,7 +102,8 @@ store.watch( } } }); - }, { + }, + { immediate: true, }, );