feat: add shortcut keys preferencs

This commit is contained in:
vben
2024-06-16 13:43:33 +08:00
parent 5d829a6d9a
commit 222c73963d
38 changed files with 1449 additions and 887 deletions

View File

@@ -45,7 +45,12 @@ const defaultPreferences: Preferences = {
split: true,
styleType: 'rounded',
},
shortcutKeys: { enable: true },
shortcutKeys: {
enable: true,
globalLogout: true,
globalPreferences: true,
globalSearch: true,
},
sidebar: {
collapsed: false,
collapsedShowTitle: true,

View File

@@ -112,6 +112,12 @@ interface SidebarPreferences {
interface ShortcutKeyPreferences {
/** 是否启用快捷键-全局 */
enable: boolean;
/** 是否启用全局注销快捷键 */
globalLogout: boolean;
/** 是否启用全局偏好设置快捷键 */
globalPreferences: boolean;
/** 是否启用全局搜索快捷键 */
globalSearch: boolean;
}
interface TabbarPreferences {

View File

@@ -16,6 +16,8 @@ function usePreferences() {
const appPreferences = computed(() => preferences.app);
const shortcutKeysPreferences = computed(() => preferences.shortcutKeys);
/**
* @zh_CN 判断是否为暗黑模式
* @param preferences - 当前偏好设置对象,它的主题值将被用来判断是否为暗黑模式。
@@ -107,11 +109,38 @@ function usePreferences() {
return appPreferences.value.authPageLayout === 'panel-center';
});
/**
* @zh_CN 是否启用全局搜索快捷键
*/
const globalSearchShortcutKey = computed(() => {
const { enable, globalSearch } = shortcutKeysPreferences.value;
return enable && globalSearch;
});
/**
* @zh_CN 是否启用全局注销快捷键
*/
const globalLogoutShortcutKey = computed(() => {
const { enable, globalLogout } = shortcutKeysPreferences.value;
return enable && globalLogout;
});
/**
* @zh_CN 是否启用全局偏好设置快捷键
*/
const globalPreferencesShortcutKey = computed(() => {
const { enable, globalPreferences } = shortcutKeysPreferences.value;
return enable && globalPreferences;
});
return {
authPanelCenter,
authPanelLeft,
authPanelRight,
diffPreference,
globalLogoutShortcutKey,
globalPreferencesShortcutKey,
globalSearchShortcutKey,
isDark,
isFullContent,
isHeaderNav,

View File

@@ -40,7 +40,7 @@
},
"dependencies": {
"@ctrl/tinycolor": "4.1.0",
"@vue/shared": "^3.4.27",
"@vue/shared": "^3.4.29",
"dayjs": "^1.11.11",
"defu": "^6.1.4",
"nprogress": "^0.2.0"