快捷键会失效的问题修复

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.watch(
() => store.getters['data/computedSettings'], () => ({
(computedSettings) => { computedSettings: store.getters['data/computedSettings'],
isCurrentEditable: store.getters['content/isCurrentEditable'],
}),
({ computedSettings, isCurrentEditable }) => {
Mousetrap.reset(); Mousetrap.reset();
Object.entries(computedSettings.shortcuts).forEach(([key, shortcut]) => { Object.entries(computedSettings.shortcuts).forEach(([key, shortcut]) => {
@ -90,7 +93,7 @@ store.watch(
if (Object.prototype.hasOwnProperty.call(methods, method)) { if (Object.prototype.hasOwnProperty.call(methods, method)) {
try { try {
// editor is editable or 一些非编辑模式下支持的快捷键 // 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)); Mousetrap.bind(`${key}`, () => !methods[method].apply(null, params));
} }
} catch (e) { } catch (e) {
@ -99,7 +102,8 @@ store.watch(
} }
} }
}); });
}, { },
{
immediate: true, immediate: true,
}, },
); );