快捷键会失效的问题修复

This commit is contained in:
xiaoqi.cxq 2023-10-20 13:50:33 +08:00
parent 39167fb193
commit b4f4c71f85

View File

@ -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,
},
);