mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: 快速打开添加到菜单
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { getCurrentAction } from '@fe/context/shortcut'
|
||||
import { switchDoc } from '@fe/context/document'
|
||||
import XMask from './Mask.vue'
|
||||
import QuickOpen from './QuickOpen.vue'
|
||||
@@ -19,17 +18,11 @@ export default defineComponent({
|
||||
const callback = ref<Function | null>(null)
|
||||
const withMarked = ref(true)
|
||||
|
||||
function keydownHandler (e: KeyboardEvent) {
|
||||
switch (getCurrentAction(e)) {
|
||||
case 'show-quick-open':
|
||||
callback.value = (f: any) => {
|
||||
switchDoc(f)
|
||||
callback.value = null
|
||||
}
|
||||
withMarked.value = true
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
break
|
||||
function showQuickOpen () {
|
||||
withMarked.value = true
|
||||
callback.value = (f: any) => {
|
||||
switchDoc(f)
|
||||
callback.value = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +43,13 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
registerAction('filter.show-quick-open', showQuickOpen)
|
||||
registerAction('filter.choose-document', chooseDocument)
|
||||
window.addEventListener('keydown', keydownHandler, true)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
removeAction('filter.show-quick-open')
|
||||
removeAction('filter.choose-document')
|
||||
window.removeEventListener('keydown', keydownHandler)
|
||||
})
|
||||
|
||||
const show = computed(() => !!callback.value)
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import { Plugin } from '@fe/context/plugin'
|
||||
import { Alt, getActionLabel, isAction } from '@fe/context/shortcut'
|
||||
import { Alt, CtrlCmd, getActionLabel, isAction } from '@fe/context/shortcut'
|
||||
import { FLAG_DISABLE_XTERM } from '@fe/support/global-args'
|
||||
import { toggleSide, toggleView, toggleXterm } from '@fe/context/layout'
|
||||
import { toggleWrap } from '@fe/context/editor'
|
||||
import { getAction } from '@fe/context/action'
|
||||
|
||||
export default {
|
||||
name: 'status-bar-view',
|
||||
register: ctx => {
|
||||
const actions = {
|
||||
'show-quick-open': {
|
||||
title: '快速跳转',
|
||||
action: () => getAction('filter.show-quick-open')(),
|
||||
shortcut: [CtrlCmd, 'p'],
|
||||
},
|
||||
'toggle-side': {
|
||||
title: '切换侧栏',
|
||||
action: toggleSide,
|
||||
|
||||
Reference in New Issue
Block a user