feat(脑图): 快捷键功能补全&显示调整

This commit is contained in:
baiqi 2024-09-13 14:36:41 +08:00 committed by Craftsman
parent 9eaa143d54
commit 3bb88dfc90
5 changed files with 16 additions and 10 deletions

View File

@ -13,7 +13,7 @@
:can-show-enter-node="canShowEnterNode" :can-show-enter-node="canShowEnterNode"
:can-show-more-menu-node-operation="false" :can-show-more-menu-node-operation="false"
:more-menu-other-operation-list="canShowFloatMenu ? moreMenuOtherOperationList : []" :more-menu-other-operation-list="canShowFloatMenu ? moreMenuOtherOperationList : []"
:shortcut-list="['expand']" :shortcut-list="['expand', 'enter']"
disabled disabled
@node-select="handleNodeSelect" @node-select="handleNodeSelect"
@node-unselect="handleNodeUnselect" @node-unselect="handleNodeUnselect"
@ -94,7 +94,7 @@
/> />
</div> </div>
</template> </template>
<template #shortCutList> <!-- <template #shortCutList>
<div class="ms-minder-shortcut-trigger-listitem"> <div class="ms-minder-shortcut-trigger-listitem">
<div>{{ t('common.pass') }}</div> <div>{{ t('common.pass') }}</div>
<div class="ms-minder-shortcut-trigger-listitem-icon ms-minder-shortcut-trigger-listitem-icon-auto"> P </div> <div class="ms-minder-shortcut-trigger-listitem-icon ms-minder-shortcut-trigger-listitem-icon-auto"> P </div>
@ -103,7 +103,7 @@
<div>{{ t('common.unPass') }}</div> <div>{{ t('common.unPass') }}</div>
<div class="ms-minder-shortcut-trigger-listitem-icon ms-minder-shortcut-trigger-listitem-icon-auto"> R </div> <div class="ms-minder-shortcut-trigger-listitem-icon ms-minder-shortcut-trigger-listitem-icon-auto"> R </div>
</div> </div>
</template> </template> -->
</MsMinderEditor> </MsMinderEditor>
</div> </div>
</template> </template>

View File

@ -13,7 +13,7 @@
:can-show-enter-node="canShowEnterNode" :can-show-enter-node="canShowEnterNode"
:can-show-more-menu-node-operation="false" :can-show-more-menu-node-operation="false"
:more-menu-other-operation-list="canShowFloatMenu && hasOperationPermission ? moreMenuOtherOperationList : []" :more-menu-other-operation-list="canShowFloatMenu && hasOperationPermission ? moreMenuOtherOperationList : []"
:shortcut-list="['expand']" :shortcut-list="['expand', 'enter']"
disabled disabled
@node-batch-select="handleNodeBatchSelect" @node-batch-select="handleNodeBatchSelect"
@node-select="handleNodeSelect" @node-select="handleNodeSelect"

View File

@ -16,10 +16,12 @@ type ShortcutKey =
| 'addChildCase' | 'addChildCase'
| 'addChildModule' | 'addChildModule'
| 'addSiblingModule' | 'addSiblingModule'
| 'addSiblingCase'; | 'addSiblingCase'
| 'reviewPass'
| 'reviewReject';
// 快捷键事件映射combinationShortcuts中定义了组合键事件key为组合键value为事件名称 // 快捷键事件映射combinationShortcuts中定义了组合键事件key为组合键value为事件名称
type Shortcuts = { type Shortcuts = {
[key in ShortcutKey]?: () => void; [key in ShortcutKey]?: (event: KeyboardEvent) => void;
}; };
export default function useShortCut(shortcuts: Shortcuts, options: MinderOperationProps) { export default function useShortCut(shortcuts: Shortcuts, options: MinderOperationProps) {
@ -49,7 +51,7 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
// z: 'undo', // 撤销 TODO:暂时不上撤销和重做 // z: 'undo', // 撤销 TODO:暂时不上撤销和重做
// y: 'redo', // 重做 // y: 'redo', // 重做
enter: 'enter', // 进入节点 enter: 'enter', // 进入节点
save: 'save', // 保存 s: 'save', // 保存
}; };
// 定义单键事件 // 定义单键事件
const singleShortcuts: { [key: string]: ShortcutKey } = { const singleShortcuts: { [key: string]: ShortcutKey } = {
@ -63,6 +65,8 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
s: 'executeToSuccess', // 执行结果为成功 s: 'executeToSuccess', // 执行结果为成功
b: 'executeToBlocked', // 执行结果为阻塞 b: 'executeToBlocked', // 执行结果为阻塞
e: 'executeToError', // 执行结果为失败 e: 'executeToError', // 执行结果为失败
p: 'reviewPass', // 评审结果为通过
r: 'reviewReject', // 评审结果为失败
m: 'addSiblingModule', // 添加同级模块 m: 'addSiblingModule', // 添加同级模块
c: 'addSiblingCase', // 添加同级用例 c: 'addSiblingCase', // 添加同级用例
}; };
@ -72,6 +76,7 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
}; };
let action; let action;
if (isCtrlOrCmd && combinationShortcuts[key]) { if (isCtrlOrCmd && combinationShortcuts[key]) {
// 执行组合键事件 // 执行组合键事件
action = combinationShortcuts[key]; action = combinationShortcuts[key];
@ -86,7 +91,7 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
action = businessShortcuts[key]; action = businessShortcuts[key];
} }
if (action && shortcuts[action]) { if (action && shortcuts[action]) {
shortcuts[action]!(); shortcuts[action]!(event);
} }
}; };

View File

@ -143,7 +143,8 @@
minderStore.dispatchEvent(MinderEventName.ENTER_NODE, undefined, undefined, undefined, [selectedNodes[0]]); minderStore.dispatchEvent(MinderEventName.ENTER_NODE, undefined, undefined, undefined, [selectedNodes[0]]);
} }
}, },
save: () => { save: (event: KeyboardEvent) => {
event.preventDefault();
minderStore.dispatchEvent(MinderEventName.SAVE_MINDER); minderStore.dispatchEvent(MinderEventName.SAVE_MINDER);
}, },
delete: () => { delete: () => {

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="px-[16px]"> <div class="px-[16px]">
<div class="flex items-center justify-between"> <div class="mb-[8px] flex items-center justify-between">
<a-radio-group v-model:model-value="showType" type="button" class="file-show-type" @change="changeShowType"> <a-radio-group v-model:model-value="showType" type="button" class="file-show-type" @change="changeShowType">
<a-radio value="All">{{ t('report.all') }}</a-radio> <a-radio value="All">{{ t('report.all') }}</a-radio>
<a-radio value="INDEPENDENT">{{ t('report.independent') }}</a-radio> <a-radio value="INDEPENDENT">{{ t('report.independent') }}</a-radio>