mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
refactor: 重命名 command
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<script lang="ts">
|
||||
import { useStore } from 'vuex'
|
||||
import { computed, defineComponent, onBeforeMount, onBeforeUnmount, ref, toRefs, watch } from 'vue'
|
||||
import { Alt, Ctrl } from '@fe/core/shortcut'
|
||||
import { Alt, Ctrl } from '@fe/core/command'
|
||||
import type { Components, Doc } from '@fe/types'
|
||||
import { useBus } from '@fe/core/bus'
|
||||
import { registerAction, removeAction } from '@fe/core/action'
|
||||
|
||||
@@ -10,7 +10,7 @@ import { switchDoc } from '@fe/services/document'
|
||||
import XMask from './Mask.vue'
|
||||
import { registerAction, removeAction } from '@fe/core/action'
|
||||
import QuickOpen from './QuickOpen.vue'
|
||||
import { CtrlCmd } from '@fe/core/shortcut'
|
||||
import { CtrlCmd } from '@fe/core/command'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'x-filter',
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as storage from '@fe/utils/storage'
|
||||
import * as utils from '@fe/utils/index'
|
||||
import * as plugin from '@fe/core/plugin'
|
||||
import * as action from '@fe/core/action'
|
||||
import * as shortcut from '@fe/core/shortcut'
|
||||
import * as command from '@fe/core/command'
|
||||
import { useBus } from '@fe/core/bus'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
import { useModal } from '@fe/support/ui/modal'
|
||||
@@ -30,7 +30,7 @@ const ctx = {
|
||||
store,
|
||||
action,
|
||||
doc,
|
||||
shortcut,
|
||||
command,
|
||||
tree,
|
||||
markdown,
|
||||
statusBar,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getLogger } from '@fe/utils'
|
||||
import { useBus } from '@fe/core/bus'
|
||||
import { BuildInActionName } from '@fe/types'
|
||||
import { registerCommand, removeCommand } from './shortcut'
|
||||
import { registerCommand, removeCommand } from './command'
|
||||
|
||||
const logger = getLogger('action')
|
||||
const bus = useBus()
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getLogger } from '@fe/utils'
|
||||
import { isMacOS } from '@fe/support/env'
|
||||
import { getActionHandler } from './action'
|
||||
|
||||
const logger = getLogger('shortcut')
|
||||
const logger = getLogger('command')
|
||||
|
||||
export const Escape = 'Escape'
|
||||
export const Ctrl = 'Ctrl'
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plugin } from '@fe/context'
|
||||
import { hasCtrlCmd } from '@fe/core/shortcut'
|
||||
import { hasCtrlCmd } from '@fe/core/command'
|
||||
import { copyText, encodeMarkdownLink } from '@fe/utils'
|
||||
import store from '@fe/support/store'
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export default {
|
||||
type: 'normal' as any,
|
||||
title: '前进',
|
||||
disabled: idx >= stack.length - 1,
|
||||
subTitle: ctx.shortcut.getKeysLabel(forwardId),
|
||||
subTitle: ctx.command.getKeysLabel(forwardId),
|
||||
onClick: () => ctx.action.getActionHandler(forwardId)()
|
||||
},
|
||||
{
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
type: 'normal' as any,
|
||||
title: '后退',
|
||||
disabled: idx <= 0,
|
||||
subTitle: ctx.shortcut.getKeysLabel(backId),
|
||||
subTitle: ctx.command.getKeysLabel(backId),
|
||||
onClick: () => ctx.action.getActionHandler(backId)()
|
||||
},
|
||||
].concat(list.filter(x => ![forwardId, backId].includes(x.id as BuildInActionName)) as any)
|
||||
@@ -74,13 +74,13 @@ export default {
|
||||
ctx.action.registerAction({
|
||||
name: backId,
|
||||
handler: () => go(-1),
|
||||
keys: [ctx.shortcut.Alt, ctx.shortcut.BracketLeft],
|
||||
keys: [ctx.command.Alt, ctx.command.BracketLeft],
|
||||
})
|
||||
|
||||
ctx.action.registerAction({
|
||||
name: forwardId,
|
||||
handler: () => go(1),
|
||||
keys: [ctx.shortcut.Alt, ctx.shortcut.BracketRight],
|
||||
keys: [ctx.command.Alt, ctx.command.BracketRight],
|
||||
})
|
||||
}
|
||||
} as Plugin
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
const codeInline = (fn: Function) => (tokens: any, idx: any, options: any, env: any, slf: any) => {
|
||||
if (tokens[idx].attrIndex('title') < 0) {
|
||||
tokens[idx].attrJoin('class', 'copy-inner-text')
|
||||
tokens[idx].attrPush(['title', ctx.shortcut.getKeyLabel('CtrlCmd') + ' + 单击复制'])
|
||||
tokens[idx].attrPush(['title', ctx.command.getKeyLabel('CtrlCmd') + ' + 单击复制'])
|
||||
}
|
||||
|
||||
return (fn)(tokens, idx, options, env, slf)
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getActionHandler } from '@fe/core/action'
|
||||
import * as api from '@fe/support/api'
|
||||
import { FLAG_DISABLE_XTERM } from '@fe/support/args'
|
||||
import SvgIcon from '@fe/components/SvgIcon.vue'
|
||||
import { CtrlCmd, getKeyLabel, matchKeys } from '@fe/core/shortcut'
|
||||
import { CtrlCmd, getKeyLabel, matchKeys } from '@fe/core/command'
|
||||
import { md5 } from '@fe/utils'
|
||||
|
||||
const cache: Record<string, string> = {}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import Markdown from 'markdown-it'
|
||||
import StateInline from 'markdown-it/lib/rules_inline/state_inline'
|
||||
import { getKeyLabel } from '@fe/core/shortcut'
|
||||
import { getKeyLabel } from '@fe/core/command'
|
||||
import { Plugin } from '@fe/context'
|
||||
|
||||
import { injectLineNumbers } from './markdown-source-line'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { showHelp } from '@fe/services/document'
|
||||
import { Plugin } from '@fe/context'
|
||||
import { Alt, getKeysLabel } from '@fe/core/shortcut'
|
||||
import { Alt, getKeysLabel } from '@fe/core/command'
|
||||
|
||||
export default {
|
||||
name: 'status-bar-help',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from '@fe/context'
|
||||
import { getActionHandler } from '@fe/core/action'
|
||||
import { getKeysLabel } from '@fe/core/shortcut'
|
||||
import { getKeysLabel } from '@fe/core/command'
|
||||
|
||||
export default {
|
||||
name: 'status-bar-navigation',
|
||||
|
||||
@@ -9,7 +9,7 @@ export default {
|
||||
menus['status-bar-presentation'] = {
|
||||
id: 'status-bar-presentation',
|
||||
position: 'right',
|
||||
tips: `预览 (${ctx.shortcut.getKeysLabel(action!.name)})`,
|
||||
tips: `预览 (${ctx.command.getKeysLabel(action!.name)})`,
|
||||
icon: 'presentation',
|
||||
onClick: () => ctx.view.enterPresent()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
menus['status-bar-terminal'] = {
|
||||
id: 'status-bar-terminal',
|
||||
position: 'right',
|
||||
tips: `切换终端 (${ctx.shortcut.getKeysLabel('layout.toggle-xterm')})`,
|
||||
tips: `切换终端 (${ctx.command.getKeysLabel('layout.toggle-xterm')})`,
|
||||
icon: 'terminal',
|
||||
onClick: () => ctx.action.getActionHandler('layout.toggle-xterm')()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Plugin } from '@fe/context'
|
||||
import { FLAG_DISABLE_XTERM } from '@fe/support/args'
|
||||
import { getActionHandler } from '@fe/core/action'
|
||||
import { getKeysLabel } from '@fe/core/shortcut'
|
||||
import { getKeysLabel } from '@fe/core/command'
|
||||
|
||||
export default {
|
||||
name: 'status-bar-view',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useModal } from '@fe/support/ui/modal'
|
||||
import { Plugin } from '@fe/context'
|
||||
import { hasCtrlCmd } from '@fe/core/shortcut'
|
||||
import { hasCtrlCmd } from '@fe/core/command'
|
||||
import { getActionHandler } from '@fe/core/action'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
import { getLineContent, replaceLine } from '@fe/services/editor'
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as api from '@fe/support/api'
|
||||
import { encodeMarkdownLink } from '@fe/utils'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
import store from '@fe/support/store'
|
||||
import { CtrlCmd, getKeysLabel, isCommand, LeftClick, Shift } from '@fe/core/shortcut'
|
||||
import { CtrlCmd, getKeysLabel, isCommand, LeftClick, Shift } from '@fe/core/command'
|
||||
import { replaceValue } from '@fe/services/editor'
|
||||
import { refreshTree } from '@fe/services/tree'
|
||||
import { upload } from '@fe/services/base'
|
||||
@@ -112,7 +112,7 @@ export default {
|
||||
handler: transformAll
|
||||
})
|
||||
|
||||
ctx.shortcut.registerCommand({
|
||||
ctx.command.registerCommand({
|
||||
id: actionClick,
|
||||
keys: [CtrlCmd, Shift, LeftClick],
|
||||
handler: null
|
||||
|
||||
@@ -4,7 +4,7 @@ import { isElectron } from '@fe/support/env'
|
||||
import { useBus } from '@fe/core/bus'
|
||||
import { getColorScheme } from './theme'
|
||||
import { registerAction } from '../core/action'
|
||||
import { Alt } from '../core/shortcut'
|
||||
import { Alt } from '../core/command'
|
||||
|
||||
const bus = useBus()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { nextTick } from 'vue'
|
||||
import store from '@fe/support/store'
|
||||
import { useBus } from '@fe/core/bus'
|
||||
import { getActionHandler, registerAction } from '../core/action'
|
||||
import { Alt } from '../core/shortcut'
|
||||
import { Alt } from '../core/command'
|
||||
|
||||
const bus = useBus()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useBus } from '@fe/core/bus'
|
||||
import { Escape } from '@fe/core/shortcut'
|
||||
import { Escape } from '@fe/core/command'
|
||||
import { getActionHandler, registerAction } from '@fe/core/action'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
import store from '@fe/support/store'
|
||||
|
||||
@@ -5,7 +5,7 @@ import store from '@fe/support/store'
|
||||
import * as storage from '@fe/utils/storage'
|
||||
import { basename } from '@fe/utils/path'
|
||||
import type { Doc, Repo } from '@fe/types'
|
||||
import { hasCtrlCmd } from '@fe/core/shortcut'
|
||||
import { hasCtrlCmd } from '@fe/core/command'
|
||||
import { showHelp, switchDoc, unmarkDoc } from '@fe/services/document'
|
||||
import { refreshTree } from '@fe/services/tree'
|
||||
import { getSelectionInfo, whenEditorReady } from '@fe/services/editor'
|
||||
|
||||
Reference in New Issue
Block a user