diff --git a/packages/@vben-core/shared/iconify/src/material.ts b/packages/@vben-core/shared/iconify/src/material.ts index acc444e5..d36cf69c 100644 --- a/packages/@vben-core/shared/iconify/src/material.ts +++ b/packages/@vben-core/shared/iconify/src/material.ts @@ -7,6 +7,8 @@ export const IcRoundKeyboardArrowDown = createIcon( ); export const IcRoundChevronRight = createIcon('ic:round-chevron-right'); + +export const IcRoundKeyboard = createIcon('ic:round-keyboard'); // export const IcRoundMenuOpen = createIcon('ic:round-menu-open'); export const IcRoundMenu = createIcon('ic:round-menu'); diff --git a/packages/@vben-core/shared/typings/src/preference.ts b/packages/@vben-core/shared/typings/src/preference.ts index 777c31cd..5d8d25d2 100644 --- a/packages/@vben-core/shared/typings/src/preference.ts +++ b/packages/@vben-core/shared/typings/src/preference.ts @@ -91,6 +91,8 @@ interface Preference { pageTransitionEnable: boolean; /** 是否开启半深色菜单(只在theme='light'时生效) */ semiDarkMenu: boolean; + /** 是否启用快捷键 */ + shortcutKeys: boolean; /** 是否显示偏好设置 */ showPreference: boolean; /** 侧边栏是否折叠 */ diff --git a/packages/business/common-ui/src/global-search/global-search.vue b/packages/business/common-ui/src/global-search/global-search.vue index 1724b78c..d2a9275e 100644 --- a/packages/business/common-ui/src/global-search/global-search.vue +++ b/packages/business/common-ui/src/global-search/global-search.vue @@ -21,7 +21,7 @@ import { isWindowsOs } from '@vben-core/toolkit'; import { $t } from '@vben/locales'; import { useMagicKeys, useToggle, whenever } from '@vueuse/core'; -import { onMounted, ref } from 'vue'; +import { ref } from 'vue'; import SearchPanel from './search-panel.vue'; @@ -29,9 +29,13 @@ defineOptions({ name: 'GlobalSearch', }); -withDefaults(defineProps<{ menus: MenuRecordRaw[] }>(), { - menus: () => [], -}); +const props = withDefaults( + defineProps<{ enableShortcutKey?: boolean; menus: MenuRecordRaw[] }>(), + { + enableShortcutKey: true, + menus: () => [], + }, +); const [open, toggleOpen] = useToggle(); const keyword = ref(''); @@ -41,13 +45,15 @@ function handleClose() { keyword.value = ''; } -onMounted(() => { +if (props.enableShortcutKey) { const keys = useMagicKeys(); const cmd = isWindowsOs() ? keys['ctrl+k'] : keys['cmd+k']; whenever(cmd, () => { - open.value = true; + if (props.enableShortcutKey) { + open.value = true; + } }); -}); +} diff --git a/packages/business/common-ui/src/preference/preference-widget.vue b/packages/business/common-ui/src/preference/preference-widget.vue index d04b23b7..19d11073 100644 --- a/packages/business/common-ui/src/preference/preference-widget.vue +++ b/packages/business/common-ui/src/preference/preference-widget.vue @@ -54,9 +54,11 @@ function updateLocale(value: string) { :locale="preference.locale" :navigation-accordion="preference.navigationAccordion" :navigation-style="preference.navigationStyle" + :shortcut-keys="preference.shortcutKeys" :navigation-split="preference.navigationSplit" :side-collapse-show-title="preference.sideCollapseShowTitle" :page-transition-enable="preference.pageTransitionEnable" + @update:shortcut-keys="(value) => handleUpdate('shortcutKeys', value)" @update:navigation-style="(value) => handleUpdate('navigationStyle', value)" @update:navigation-accordion=" (value) => handleUpdate('navigationAccordion', value) diff --git a/packages/business/common-ui/src/preference/preference.vue b/packages/business/common-ui/src/preference/preference.vue index 91d3d6b0..0cfc3463 100644 --- a/packages/business/common-ui/src/preference/preference.vue +++ b/packages/business/common-ui/src/preference/preference.vue @@ -62,6 +62,7 @@ const pageTransitionEnable = defineModel('pageTransitionEnable'); const layout = defineModel('layout'); const contentCompact = defineModel('contentCompact'); const sideVisible = defineModel('sideVisible'); +const shortcutKeys = defineModel('shortcutKeys'); const tabsVisible = defineModel('tabsVisible'); const tabsIcon = defineModel('tabsIcon'); // const logoVisible = defineModel('logoVisible'); @@ -95,6 +96,10 @@ const tabs = computed((): SegmentedItem[] => { label: $t('preference.general'), value: 'general', }, + // { + // label: $t('preference.shortcut-key'), + // value: 'shortcutKey', + // }, ]; }); @@ -233,6 +238,24 @@ function handleReset() { + + + + + + +