feat: 顶栏按钮支持位置选择(header/user-dropdown/none)

为顶栏所有部件按钮添加独立的位置配置,支持在顶栏、用户下拉菜单、不显示
三种选项间切换,每个按钮可独立设置。

- 新增 7 个位置偏好字段:globalSearchButtonPosition、
  themeToggleButtonPosition、languageToggleButtonPosition、
  fullscreenButtonPosition、notificationButtonPosition、
  refreshButtonPosition、timezoneButtonPosition
- 合并 lockScreenButtonPosition、logoutButtonPosition
- header.vue 按位置条件过滤按钮显示
- user-dropdown.vue 新增对应菜单项,支持在用户下拉菜单中显示
- 偏好设置界面仅保留位置选择器(不再需要独立的开关)
- 更新中英文国际化文案

Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
This commit is contained in:
金毛88
2026-07-18 22:46:31 +08:00
parent b71ebbd673
commit 0cd87c170f
15 changed files with 518 additions and 79 deletions

View File

@@ -122,7 +122,10 @@ type SlotItem = { index: number; name: string };
const rightSlots = computed(() => {
const list: Array<SlotItem> = [];
// 全局搜索
if (preferences.widget.globalSearch) {
if (
preferences.widget.globalSearch &&
preferences.widget.globalSearchButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE,
name: 'global-search',
@@ -137,50 +140,70 @@ const rightSlots = computed(() => {
}
// 主题、语言、时区等子功能由各自的 widget 开关独立控制,
// 不应跟随偏好设置按钮的显示与否(如 enablePreferences 为 false 或按钮位于其他位置时)
if (preferences.widget.themeToggle) {
if (
preferences.widget.themeToggle &&
preferences.widget.themeToggleButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE + 20,
name: 'theme-toggle',
});
}
if (preferences.widget.languageToggle) {
if (
preferences.widget.languageToggle &&
preferences.widget.languageToggleButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE + 30,
name: 'language-toggle',
});
}
if (preferences.widget.timezone) {
if (
preferences.widget.timezone &&
preferences.widget.timezoneButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE + 40,
name: 'timezone',
});
}
// 全屏
if (preferences.widget.fullscreen) {
if (
preferences.widget.fullscreen &&
preferences.widget.fullscreenButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE + 50,
name: 'fullscreen',
});
}
// 消息通知
if (preferences.widget.notification) {
if (
preferences.widget.notification &&
preferences.widget.notificationButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE + 60,
name: 'notification',
});
}
// 锁定屏幕
if (preferences.widget.lockScreen) {
// 锁定屏幕(仅在 header 位置显示)
if (
preferences.widget.lockScreen &&
preferences.widget.lockScreenButtonPosition === 'header'
) {
list.push({
index: REFERENCE_VALUE + 70,
name: 'lock-screen-btn',
});
}
// 退出登录
list.push({
index: REFERENCE_VALUE + 80,
name: 'logout-btn',
});
// 退出登录(仅在 header 位置显示)
if (preferences.widget.logoutButtonPosition === 'header') {
list.push({
index: REFERENCE_VALUE + 80,
name: 'logout-btn',
});
}
Object.keys(slots).forEach((key) => {
// 适配插槽名称例如第一个插槽名header-right-1
@@ -201,7 +224,10 @@ const rightSlots = computed(() => {
const leftSlots = computed(() => {
const list: Array<SlotItem> = [];
// 刷新
if (preferences.widget.refresh) {
if (
preferences.widget.refresh &&
preferences.widget.refreshButtonPosition === 'header'
) {
list.push({
index: 0,
name: 'refresh',