mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 12:29:19 +08:00
update: 升级vben5.5.9到5.7.0
This commit is contained in:
@@ -6,7 +6,7 @@ import type { AnyFunction } from '@vben/types';
|
||||
import { computed, useTemplateRef, watch } from 'vue';
|
||||
|
||||
import { useHoverToggle } from '@vben/hooks';
|
||||
import { LockKeyhole, LogOut } from '@vben/icons';
|
||||
import { LockKeyhole, LogOut, Settings } from '@vben/icons';
|
||||
import { $t } from '@vben/locales';
|
||||
import { preferences, usePreferences } from '@vben/preferences';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
import { useMagicKeys, whenever } from '@vueuse/core';
|
||||
|
||||
import { LockScreenModal } from '../lock-screen';
|
||||
import { Preferences } from '../preferences';
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
@@ -82,10 +83,13 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
hoverDelay: 500,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{ logout: [] }>();
|
||||
const emit = defineEmits<{ clearPreferencesAndLogout: []; logout: [] }>();
|
||||
|
||||
const { globalLockScreenShortcutKey, globalLogoutShortcutKey } =
|
||||
usePreferences();
|
||||
const {
|
||||
globalLockScreenShortcutKey,
|
||||
globalLogoutShortcutKey,
|
||||
preferencesButtonPosition,
|
||||
} = usePreferences();
|
||||
const accessStore = useAccessStore();
|
||||
const [LockModal, lockModalApi] = useVbenModal({
|
||||
connectedComponent: LockScreenModal,
|
||||
@@ -98,6 +102,7 @@ const [LogoutModal, logoutModalApi] = useVbenModal({
|
||||
|
||||
const refTrigger = useTemplateRef('refTrigger');
|
||||
const refContent = useTemplateRef('refContent');
|
||||
const refPreferences = useTemplateRef('refPreferences');
|
||||
const [openPopover, hoverWatcher] = useHoverToggle(
|
||||
[refTrigger, refContent],
|
||||
() => props.hoverDelay,
|
||||
@@ -151,19 +156,31 @@ function handleSubmitLogout() {
|
||||
logoutModalApi.close();
|
||||
}
|
||||
|
||||
// 设置 - 打开偏好设置抽屉
|
||||
function handleOpenSettings() {
|
||||
refPreferences.value?.open();
|
||||
}
|
||||
|
||||
if (enableShortcutKey.value) {
|
||||
const keys = useMagicKeys();
|
||||
whenever(keys['Alt+KeyQ']!, () => {
|
||||
if (enableLogoutShortcutKey.value) {
|
||||
handleLogout();
|
||||
}
|
||||
});
|
||||
const logoutKey = keys['Alt+KeyQ'];
|
||||
const lockKey = keys['Alt+KeyL'];
|
||||
|
||||
whenever(keys['Alt+KeyL']!, () => {
|
||||
if (enableLockScreenShortcutKey.value) {
|
||||
handleOpenLock();
|
||||
}
|
||||
});
|
||||
if (logoutKey) {
|
||||
whenever(logoutKey, () => {
|
||||
if (enableLogoutShortcutKey.value) {
|
||||
handleLogout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (lockKey) {
|
||||
whenever(lockKey, () => {
|
||||
if (enableLockScreenShortcutKey.value) {
|
||||
handleOpenLock();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -188,15 +205,22 @@ if (enableShortcutKey.value) {
|
||||
{{ $t('ui.widgets.logoutTip') }}
|
||||
</LogoutModal>
|
||||
|
||||
<Preferences
|
||||
v-if="preferencesButtonPosition.userDropdown"
|
||||
ref="refPreferences"
|
||||
:show-button="false"
|
||||
@clear-preferences-and-logout="emit('clearPreferencesAndLogout')"
|
||||
/>
|
||||
|
||||
<DropdownMenu v-model:open="openPopover">
|
||||
<DropdownMenuTrigger ref="refTrigger" :disabled="props.trigger === 'hover'">
|
||||
<div class="hover:bg-accent ml-1 mr-2 cursor-pointer rounded-full p-1.5">
|
||||
<div class="hover:text-accent-foreground flex-center">
|
||||
<div class="mr-2 ml-1 cursor-pointer rounded-full p-1.5 hover:bg-accent">
|
||||
<div class="flex-center hover:text-accent-foreground">
|
||||
<VbenAvatar :alt="text" :src="avatar" class="size-8" dot />
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent class="mr-2 min-w-[240px] p-0 pb-1">
|
||||
<DropdownMenuContent class="mr-2 min-w-60 p-0 pb-1">
|
||||
<div ref="refContent">
|
||||
<DropdownMenuLabel class="flex items-center p-3">
|
||||
<VbenAvatar
|
||||
@@ -209,7 +233,7 @@ if (enableShortcutKey.value) {
|
||||
<div class="ml-2 w-full">
|
||||
<div
|
||||
v-if="tagText || text || $slots.tagText"
|
||||
class="text-foreground mb-1 flex items-center text-sm font-medium"
|
||||
class="mb-1 flex items-center text-sm font-medium text-foreground"
|
||||
>
|
||||
{{ text }}
|
||||
<slot name="tagText">
|
||||
@@ -218,9 +242,7 @@ if (enableShortcutKey.value) {
|
||||
</Badge>
|
||||
</slot>
|
||||
</div>
|
||||
<div
|
||||
class="text-muted-foreground whitespace-pre-line text-xs font-normal"
|
||||
>
|
||||
<div class="text-xs font-normal text-muted-foreground">
|
||||
{{ description }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -236,6 +258,14 @@ if (enableShortcutKey.value) {
|
||||
{{ menu.text }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
v-if="preferencesButtonPosition.userDropdown"
|
||||
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8"
|
||||
@click="handleOpenSettings"
|
||||
>
|
||||
<Settings class="mr-2 size-4" />
|
||||
{{ $t('preferences.title') }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
v-if="preferences.widget.lockScreen"
|
||||
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8"
|
||||
|
||||
Reference in New Issue
Block a user