mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
feat: add shortcut keys preferencs
This commit is contained in:
@@ -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,
|
||||
|
@@ -112,6 +112,12 @@ interface SidebarPreferences {
|
||||
interface ShortcutKeyPreferences {
|
||||
/** 是否启用快捷键-全局 */
|
||||
enable: boolean;
|
||||
/** 是否启用全局注销快捷键 */
|
||||
globalLogout: boolean;
|
||||
/** 是否启用全局偏好设置快捷键 */
|
||||
globalPreferences: boolean;
|
||||
/** 是否启用全局搜索快捷键 */
|
||||
globalSearch: boolean;
|
||||
}
|
||||
|
||||
interface TabbarPreferences {
|
||||
|
@@ -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,
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user