diff --git a/docs/src/guide/essentials/settings.md b/docs/src/guide/essentials/settings.md index 013bde76..36221a8e 100644 --- a/docs/src/guide/essentials/settings.md +++ b/docs/src/guide/essentials/settings.md @@ -189,6 +189,7 @@ const defaultPreferences: Preferences = { locale: 'zh-CN', loginExpiredMode: 'modal', name: 'Vben Admin', + preferencesButtonPosition: 'fixed', watermark: false, }, breadcrumb: { @@ -319,6 +320,8 @@ interface AppPreferences { loginExpiredMode: LoginExpiredModeType; /** 应用名 */ name: string; + /** 偏好设置按钮位置 */ + preferencesButtonPosition: PreferencesButtonPositionType; /** * @zh_CN 是否开启水印 */ diff --git a/packages/@core/base/icons/src/lucide.ts b/packages/@core/base/icons/src/lucide.ts index 0e059f38..6c6eeb9e 100644 --- a/packages/@core/base/icons/src/lucide.ts +++ b/packages/@core/base/icons/src/lucide.ts @@ -38,7 +38,7 @@ export { RotateCw, Search, SearchX, - Settings2, + Settings, Sun, SunMoon, SwatchBook, diff --git a/packages/@core/base/typings/src/app.d.ts b/packages/@core/base/typings/src/app.d.ts index 0db306dd..15fffb28 100644 --- a/packages/@core/base/typings/src/app.d.ts +++ b/packages/@core/base/typings/src/app.d.ts @@ -7,6 +7,13 @@ type LayoutType = type ThemeModeType = 'auto' | 'dark' | 'light'; +/** + * 偏好设置按钮位置 + * fixed 固定在右侧 + * header 顶栏 + */ +type PreferencesButtonPositionType = 'fixed' | 'header'; + type BuiltinThemeType = | 'custom' | 'deep-blue' @@ -92,6 +99,7 @@ export type { LoginExpiredModeType, NavigationStyleType, PageTransitionType, + PreferencesButtonPositionType, TabsStyleType, ThemeModeType, }; diff --git a/packages/@core/preferences/src/config.ts b/packages/@core/preferences/src/config.ts index 99e3a3a0..6a024353 100644 --- a/packages/@core/preferences/src/config.ts +++ b/packages/@core/preferences/src/config.ts @@ -19,6 +19,7 @@ const defaultPreferences: Preferences = { locale: 'zh-CN', loginExpiredMode: 'modal', name: 'Vben Admin', + preferencesButtonPosition: 'fixed', watermark: false, }, breadcrumb: { diff --git a/packages/@core/preferences/src/types.ts b/packages/@core/preferences/src/types.ts index 71137166..989a6e34 100644 --- a/packages/@core/preferences/src/types.ts +++ b/packages/@core/preferences/src/types.ts @@ -10,6 +10,7 @@ import type { LoginExpiredModeType, NavigationStyleType, PageTransitionType, + PreferencesButtonPositionType, TabsStyleType, ThemeModeType, } from '@vben-core/typings'; @@ -49,6 +50,8 @@ interface AppPreferences { loginExpiredMode: LoginExpiredModeType; /** 应用名 */ name: string; + /** 偏好设置按钮位置 */ + preferencesButtonPosition: PreferencesButtonPositionType; /** * @zh_CN 是否开启水印 */ diff --git a/packages/effects/layouts/src/basic/header/header.vue b/packages/effects/layouts/src/basic/header/header.vue index c829dfea..46cec6f7 100644 --- a/packages/effects/layouts/src/basic/header/header.vue +++ b/packages/effects/layouts/src/basic/header/header.vue @@ -5,7 +5,12 @@ import { preferences, usePreferences } from '@vben/preferences'; import { useAccessStore } from '@vben/stores'; import { VbenFullScreen } from '@vben-core/shadcn-ui'; -import { GlobalSearch, LanguageToggle, ThemeToggle } from '../../widgets'; +import { + GlobalSearch, + LanguageToggle, + PreferencesButton, + ThemeToggle, +} from '../../widgets'; interface Props { /** @@ -26,34 +31,44 @@ const accessStore = useAccessStore(); const { globalSearchShortcutKey } = usePreferences(); const slots = useSlots(); const rightSlots = computed(() => { - const list = [{ index: 30, name: 'user-dropdown' }]; + const list = [{ index: 100, name: 'user-dropdown' }]; if (preferences.widget.globalSearch) { list.push({ index: 5, name: 'global-search', }); } - if (preferences.widget.themeToggle) { + + if ( + preferences.app.enablePreferences && + preferences.app.preferencesButtonPosition === 'header' + ) { list.push({ index: 10, + name: 'preferences', + }); + } + if (preferences.widget.themeToggle) { + list.push({ + index: 15, name: 'theme-toggle', }); } if (preferences.widget.languageToggle) { list.push({ - index: 15, + index: 20, name: 'language-toggle', }); } if (preferences.widget.fullscreen) { list.push({ - index: 20, + index: 25, name: 'fullscreen', }); } if (preferences.widget.notification) { list.push({ - index: 25, + index: 30, name: 'notification', }); } @@ -66,6 +81,7 @@ const rightSlots = computed(() => { }); return list.sort((a, b) => a.index - b.index); }); + const leftSlots = computed(() => { const list: any[] = []; @@ -108,8 +124,12 @@ const leftSlots = computed(() => { class="mr-4" /> + +