|
|
@ -8,6 +8,7 @@ import { computed, ref, useTemplateRef, watch } from 'vue'; |
|
|
import { SUPPORT_LANGUAGES } from '@vben/constants'; |
|
|
import { SUPPORT_LANGUAGES } from '@vben/constants'; |
|
|
import { useHoverToggle, useRefresh } from '@vben/hooks'; |
|
|
import { useHoverToggle, useRefresh } from '@vben/hooks'; |
|
|
import { |
|
|
import { |
|
|
|
|
|
createIconifyIcon, |
|
|
Languages, |
|
|
Languages, |
|
|
LockKeyhole, |
|
|
LockKeyhole, |
|
|
LogOut, |
|
|
LogOut, |
|
|
@ -40,7 +41,7 @@ import { |
|
|
VbenIconButton, |
|
|
VbenIconButton, |
|
|
} from '@vben-core/shadcn-ui'; |
|
|
} from '@vben-core/shadcn-ui'; |
|
|
|
|
|
|
|
|
import { useMagicKeys, whenever } from '@vueuse/core'; |
|
|
import { useFullscreen, useMagicKeys, whenever } from '@vueuse/core'; |
|
|
|
|
|
|
|
|
import { GlobalSearch } from '../global-search'; |
|
|
import { GlobalSearch } from '../global-search'; |
|
|
import { LockScreenModal } from '../lock-screen'; |
|
|
import { LockScreenModal } from '../lock-screen'; |
|
|
@ -101,9 +102,11 @@ const { |
|
|
globalLogoutShortcutKey, |
|
|
globalLogoutShortcutKey, |
|
|
globalLockScreenShortcutKey, |
|
|
globalLockScreenShortcutKey, |
|
|
globalSearchShortcutKey, |
|
|
globalSearchShortcutKey, |
|
|
|
|
|
isDark, |
|
|
preferencesButtonPosition, |
|
|
preferencesButtonPosition, |
|
|
} = usePreferences(); |
|
|
} = usePreferences(); |
|
|
const { refresh } = useRefresh(); |
|
|
const { refresh } = useRefresh(); |
|
|
|
|
|
const { toggle: toggleFullscreen } = useFullscreen(); |
|
|
const accessStore = useAccessStore(); |
|
|
const accessStore = useAccessStore(); |
|
|
const [LockModal, lockModalApi] = useVbenModal({ |
|
|
const [LockModal, lockModalApi] = useVbenModal({ |
|
|
connectedComponent: LockScreenModal, |
|
|
connectedComponent: LockScreenModal, |
|
|
@ -118,6 +121,10 @@ const refTrigger = useTemplateRef('refTrigger'); |
|
|
const refContent = useTemplateRef('refContent'); |
|
|
const refContent = useTemplateRef('refContent'); |
|
|
const refPreferences = useTemplateRef('refPreferences'); |
|
|
const refPreferences = useTemplateRef('refPreferences'); |
|
|
const refGlobalSearch = useTemplateRef('refGlobalSearch'); |
|
|
const refGlobalSearch = useTemplateRef('refGlobalSearch'); |
|
|
|
|
|
const refTimezone = useTemplateRef('refTimezone'); |
|
|
|
|
|
const refNotification = useTemplateRef('refNotification'); |
|
|
|
|
|
|
|
|
|
|
|
const TimezoneIcon = createIconifyIcon('fluent-mdl2:world-clock'); |
|
|
const [openPopover, hoverWatcher] = useHoverToggle( |
|
|
const [openPopover, hoverWatcher] = useHoverToggle( |
|
|
[refTrigger, refContent], |
|
|
[refTrigger, refContent], |
|
|
() => props.hoverDelay, |
|
|
() => props.hoverDelay, |
|
|
@ -254,6 +261,28 @@ function handleGlobalSearch() { |
|
|
refGlobalSearch.value?.open(); |
|
|
refGlobalSearch.value?.open(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 主题切换 |
|
|
|
|
|
function handleThemeToggleSelect(event?: Event) { |
|
|
|
|
|
event?.preventDefault(); |
|
|
|
|
|
updatePreferences({ theme: { mode: isDark.value ? 'light' : 'dark' } }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 时区 |
|
|
|
|
|
function handleTimezoneSelect() { |
|
|
|
|
|
refTimezone.value?.open(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 全屏切换 |
|
|
|
|
|
function handleFullscreenSelect() { |
|
|
|
|
|
toggleFullscreen(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 通知 |
|
|
|
|
|
function handleNotificationSelect(event?: Event) { |
|
|
|
|
|
event?.preventDefault(); |
|
|
|
|
|
refNotification.value?.toggle(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 语言切换 - 阻止 Radix 默认关闭外层 dropdown,就地展开/收起 locale 列表 |
|
|
// 语言切换 - 阻止 Radix 默认关闭外层 dropdown,就地展开/收起 locale 列表 |
|
|
const showLanguageList = ref(false); |
|
|
const showLanguageList = ref(false); |
|
|
function handleLanguageToggleSelect(event?: Event) { |
|
|
function handleLanguageToggleSelect(event?: Event) { |
|
|
@ -329,6 +358,12 @@ if (enableShortcutKey.value) { |
|
|
:show-button="false" |
|
|
:show-button="false" |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<TimezoneButton |
|
|
|
|
|
v-if="showTimezoneInDropdown" |
|
|
|
|
|
ref="refTimezone" |
|
|
|
|
|
:show-button="false" |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<DropdownMenu v-model:open="openPopover" :modal="false"> |
|
|
<DropdownMenu v-model:open="openPopover" :modal="false"> |
|
|
<DropdownMenuTrigger ref="refTrigger" :disabled="props.trigger === 'hover'"> |
|
|
<DropdownMenuTrigger ref="refTrigger" :disabled="props.trigger === 'hover'"> |
|
|
<div class="mr-2 ml-1 cursor-pointer rounded-full p-1.5 hover:bg-accent"> |
|
|
<div class="mr-2 ml-1 cursor-pointer rounded-full p-1.5 hover:bg-accent"> |
|
|
@ -435,6 +470,7 @@ if (enableShortcutKey.value) { |
|
|
<DropdownMenuItem |
|
|
<DropdownMenuItem |
|
|
v-if="showThemeToggleInDropdown" |
|
|
v-if="showThemeToggleInDropdown" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
|
|
|
@select="handleThemeToggleSelect" |
|
|
> |
|
|
> |
|
|
<ThemeToggle class="mr-2" /> |
|
|
<ThemeToggle class="mr-2" /> |
|
|
{{ $t('preferences.theme.title') }} |
|
|
{{ $t('preferences.theme.title') }} |
|
|
@ -468,22 +504,27 @@ if (enableShortcutKey.value) { |
|
|
<DropdownMenuItem |
|
|
<DropdownMenuItem |
|
|
v-if="showTimezoneInDropdown" |
|
|
v-if="showTimezoneInDropdown" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
|
|
|
@select="handleTimezoneSelect" |
|
|
> |
|
|
> |
|
|
<TimezoneButton class="mr-2" /> |
|
|
<VbenIconButton class="mr-2" @click="handleTimezoneSelect"> |
|
|
|
|
|
<TimezoneIcon class="size-4" /> |
|
|
|
|
|
</VbenIconButton> |
|
|
{{ $t('ui.widgets.timezone.setTimezone') }} |
|
|
{{ $t('ui.widgets.timezone.setTimezone') }} |
|
|
</DropdownMenuItem> |
|
|
</DropdownMenuItem> |
|
|
<DropdownMenuItem |
|
|
<DropdownMenuItem |
|
|
v-if="showFullscreenInDropdown" |
|
|
v-if="showFullscreenInDropdown" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
|
|
|
@select="handleFullscreenSelect" |
|
|
> |
|
|
> |
|
|
<VbenFullScreen class="mr-2" /> |
|
|
<VbenFullScreen class="mr-2" @click.stop /> |
|
|
{{ $t('preferences.widget.fullscreen') }} |
|
|
{{ $t('preferences.widget.fullscreen') }} |
|
|
</DropdownMenuItem> |
|
|
</DropdownMenuItem> |
|
|
<DropdownMenuItem |
|
|
<DropdownMenuItem |
|
|
v-if="showNotificationInDropdown" |
|
|
v-if="showNotificationInDropdown" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8" |
|
|
|
|
|
@select="handleNotificationSelect" |
|
|
> |
|
|
> |
|
|
<Notification class="mr-2" /> |
|
|
<Notification ref="refNotification" class="mr-2" /> |
|
|
{{ $t('preferences.widget.notification') }} |
|
|
{{ $t('preferences.widget.notification') }} |
|
|
</DropdownMenuItem> |
|
|
</DropdownMenuItem> |
|
|
<DropdownMenuItem |
|
|
<DropdownMenuItem |
|
|
|