feat: 偏好设置按钮,支持在右上角用户的下拉框中展示;偏好设置中支持设置时区(多一个入口); (#7931)

* feat: 偏好设置按钮支持显示在用户下拉窗中的特性

* feat: 时区设置功能支持在偏好设置列表进行配置

* feat: 偏好设置按钮支持显示在用户下拉窗中的特性 - 完善示例代码

* feat: 时区设置功能支持在偏好设置列表进行配置

* feat: 时区设置功能支持在偏好设置列表进行配置-单元测试报错问题

* feat: 时区设置功能支持在偏好设置列表进行配置-修改代码QC问题

---------

Co-authored-by: PanFu <panfu@zhihuaai.com>
This commit is contained in:
PanFu
2026-05-20 17:24:53 +08:00
committed by GitHub
parent 769c970e08
commit 2a84b590b5
18 changed files with 121 additions and 20 deletions

View File

@@ -10,12 +10,17 @@ type LayoutType =
type ThemeModeType = 'auto' | 'dark' | 'light';
/**
* 偏好设置按钮位置
* 按钮位置
* user-dropdown 用户的下拉弹出框中
* fixed 固定在右侧
* header 顶栏
* auto 自动
*/
type PreferencesButtonPositionType = 'auto' | 'fixed' | 'header';
type PreferencesButtonPositionType =
| 'auto'
| 'fixed'
| 'header'
| 'user-dropdown';
type BuiltinThemeType =
| 'custom'

View File

@@ -30,6 +30,7 @@ exports[`defaultPreferences immutability test > should not modify the config obj
"loginExpiredMode": "page",
"name": "Vben Admin",
"preferencesButtonPosition": "auto",
"timezone": "Asia/Shanghai",
"watermark": false,
"watermarkContent": "",
"zIndex": 200,

View File

@@ -30,6 +30,7 @@ const defaultPreferences: Preferences = {
loginExpiredMode: 'page',
name: 'Vben Admin',
preferencesButtonPosition: 'auto',
timezone: 'Asia/Shanghai',
watermark: false,
watermarkContent: '',
zIndex: 200,

View File

@@ -155,6 +155,10 @@ interface AppPreferences {
name: string;
/** 偏好设置按钮位置 */
preferencesButtonPosition: PreferencesButtonPositionType;
/**
* @zh_CN 应用时区
*/
timezone: string;
/**
* @zh_CN 是否开启水印
*/

View File

@@ -195,12 +195,12 @@ function usePreferences() {
*/
const preferencesButtonPosition = computed(() => {
const { enablePreferences, preferencesButtonPosition } = preferences.app;
// 如果没有启用偏好设置按钮
if (!enablePreferences) {
return {
fixed: false,
header: false,
userDropdown: false,
};
}
@@ -211,12 +211,15 @@ function usePreferences() {
const contentIsMaximize = headerHidden && sidebarHidden;
const isHeaderPosition = preferencesButtonPosition === 'header';
const isUserDropdownPosition =
preferencesButtonPosition === 'user-dropdown';
// 如果设置了固定位置
if (preferencesButtonPosition !== 'auto') {
return {
fixed: preferencesButtonPosition === 'fixed',
header: isHeaderPosition,
userDropdown: isUserDropdownPosition,
};
}
@@ -230,6 +233,7 @@ function usePreferences() {
return {
fixed,
header: !fixed,
userDropdown: !fixed && isUserDropdownPosition,
};
});