fix: 修复锁定屏幕和退出登录小部件,位置在 user-dropdown 时,使用快捷键唤出两个模态窗

This commit is contained in:
hiss
2026-07-23 14:44:32 +08:00
parent 294e9f2966
commit e6a23479ee
2 changed files with 23 additions and 11 deletions

View File

@@ -69,6 +69,24 @@ const {
const slots = useSlots();
const { refresh } = useRefresh();
const showLockInHeader = computed(
() =>
preferences.widget.lockScreen &&
preferences.widget.lockScreenButtonPosition === 'header',
);
const showLogoutInHeader = computed(
() => preferences.widget.logoutButtonPosition === 'header',
);
const enableLockScreenShortcutKey = computed(() => {
return showLockInHeader.value && globalLockScreenShortcutKey.value;
});
const enableLogoutShortcutKey = computed(() => {
return showLogoutInHeader.value && globalLogoutShortcutKey.value;
});
const [LockModal, lockModalApi] = useVbenModal({
connectedComponent: LockScreenModal,
});
@@ -104,7 +122,7 @@ if (preferences.shortcutKeys.enable) {
if (lockKey) {
whenever(lockKey, () => {
if (globalLockScreenShortcutKey?.value) {
if (enableLockScreenShortcutKey.value) {
handleOpenLock();
}
});
@@ -112,7 +130,7 @@ if (preferences.shortcutKeys.enable) {
if (logoutKey) {
whenever(logoutKey, () => {
if (globalLogoutShortcutKey?.value) {
if (enableLogoutShortcutKey.value) {
handleLogout();
}
});
@@ -242,13 +260,14 @@ function clearPreferencesAndLogout() {
<template>
<LockModal
v-if="preferences.widget.lockScreen"
v-if="showLockInHeader"
:avatar="avatar"
:text="text"
@submit="handleSubmitLock"
/>
<LogoutModal
v-if="showLogoutInHeader"
:cancel-text="$t('common.cancel')"
:confirm-text="$t('common.confirm')"
:fullscreen-button="false"

View File

@@ -212,13 +212,6 @@ const enableLockScreenShortcutKey = computed(() => {
return showLockInDropdown.value && globalLockScreenShortcutKey.value;
});
const enableShortcutKey = computed(() => {
return (
(showLockInDropdown.value || showLogoutInDropdown.value) &&
preferences.shortcutKeys.enable
);
});
function handleOpenLock() {
lockModalApi.open();
}
@@ -269,7 +262,7 @@ async function handleLocaleChange(event: Event, value: 'en-US' | 'zh-CN') {
openPopover.value = false;
}
if (enableShortcutKey.value) {
if (preferences.shortcutKeys.enable) {
const keys = useMagicKeys();
const logoutKey = keys['Alt+KeyQ'];
const lockKey = keys['Alt+KeyL'];