feat(dock): add option to separate back to top and refresh buttons

- Implement new setting to split back to top and refresh buttons
- Update localization files with new setting description
- Modify Dock component to support separated buttons
- Add configuration option in settings panel
- Set default to separated buttons in storage settings
This commit is contained in:
Hakadao
2025-02-23 19:35:36 +08:00
parent 78c654e877
commit da16f7ff51
7 changed files with 79 additions and 24 deletions

View File

@@ -175,6 +175,7 @@ settings:
dock_item_use_original_bili_web_page: 使用原版 Bilibili 网页
disable_dock_glowing_effect: 关闭 Dock 栏发光效果
disable_light_dark_mode_switcher: 禁用亮/暗色模式切换按钮
back_to_top_and_refresh_buttons_are_separated: 分离回到顶部和刷新按钮
sidebar_position: 侧边栏位置
auto_hide_sidebar: 自动隐藏侧边栏

View File

@@ -175,6 +175,7 @@ settings:
dock_item_use_original_bili_web_page: 使用原版 Bilibili 網頁
disable_dock_glowing_effect: 關閉 Dock 發光效果
disable_light_dark_mode_switcher: 關閉淺/深色模式切換按鈕
back_to_top_and_refresh_buttons_are_separated: 分離回到頂部和重新整理按鈕
sidebar_position: 側邊欄位置
auto_hide_sidebar: 自動隱藏側邊欄

View File

@@ -177,6 +177,7 @@ settings:
dock_item_use_original_bili_web_page: Use the original Bilibili web page
disable_dock_glowing_effect: Disable the dock glowing effect
disable_light_dark_mode_switcher: Disable light/dark mode switcher
back_to_top_and_refresh_buttons_are_separated: Separate Back to Top and Refresh Buttons
sidebar_position: Sidebar position
auto_hide_sidebar: Automatically hide the sidebar

View File

@@ -173,6 +173,7 @@ settings:
dock_item_use_original_bili_web_page: 用返原本嘅 Bilibili 網頁
disable_dock_glowing_effect: 熄咗 Dock 發光效果去
disable_light_dark_mode_switcher: 閂咗淺 / 深色主題切換粒掣去
back_to_top_and_refresh_buttons_are_separated: 分離返到最篤同重新整理掣
sidebar_position: 側邊欄位置
auto_hide_sidebar: 自動收埋側邊欄

View File

@@ -156,11 +156,20 @@ function openDockItemInNewTab(dockItem: DockItem) {
openLinkToNewTab(`https://www.bilibili.com/?page=${dockItem.page}`)
}
function handleBackToTopOrRefresh() {
if (reachTop.value)
emit('refresh')
else
function handleBackToTopOrRefresh(action: 'backToTop' | 'refresh' | 'auto' = 'auto') {
if (action === 'backToTop') {
emit('backToTop')
}
else if (action === 'refresh') {
emit('backToTop')
emit('refresh')
}
else {
if (reachTop.value)
emit('refresh')
else
emit('backToTop')
}
}
function isDockItemActivated(dockItem: DockItem): boolean {
@@ -328,27 +337,63 @@ const dockTransformStyle = computed((): { transform: string, transformOrigin: st
</Tooltip>
</div>
<button
<!-- Back to top & refresh buttons -->
<div
v-if="showBackToTopOrRefreshButton"
class="back-to-top-or-refresh-btn"
:class="{
inactive: hoveringDockItem.themeMode && isDark,
}"
@click="handleBackToTopOrRefresh"
pos="absolute bottom-0"
transform="translate-y-100%"
flex="~ col gap-2"
>
<Transition name="fade">
<Icon
v-if="reachTop"
icon="line-md:rotate-270"
shrink-0 rotate-90 absolute text-2xl
/>
<Icon
v-else
icon="line-md:arrow-small-up"
shrink-0 absolute text-2xl
/>
</Transition>
</button>
<template
v-if="settings.backToTopAndRefreshButtonsAreSeparated"
>
<template v-for="key in 2" :key="key">
<Transition name="fade">
<button
v-if="key === 1 || key === 2 && !reachTop"
class="back-to-top-or-refresh-btn"
:class="{
inactive: hoveringDockItem.themeMode && isDark,
}"
@click="handleBackToTopOrRefresh(key === 1 ? 'refresh' : 'backToTop')"
>
<Icon
v-if="key === 1"
icon="line-md:rotate-270"
shrink-0 rotate-90 absolute text-2xl
/>
<Icon
v-else
icon="line-md:arrow-small-up"
shrink-0 absolute text-2xl
/>
</button>
</Transition>
</template>
</template>
<template v-else>
<button
class="back-to-top-or-refresh-btn"
:class="{
inactive: hoveringDockItem.themeMode && isDark,
}"
@click="handleBackToTopOrRefresh('auto')"
>
<Transition name="fade">
<Icon
v-if="reachTop"
icon="line-md:rotate-270"
shrink-0 rotate-90 absolute text-2xl
/>
<Icon
v-else
icon="line-md:arrow-small-up"
shrink-0 absolute text-2xl
/>
</Transition>
</button>
</template>
</div>
</div>
</aside>
</template>
@@ -435,7 +480,6 @@ const dockTransformStyle = computed((): { transform: string, transformOrigin: st
}
.back-to-top-or-refresh-btn {
--uno: "absolute lg:bottom--45px bottom--35px";
--uno: "transform active:important-scale-90 hover:scale-110";
--uno: "lg:w-45px w-35px lg:h-45px h-35px";
--uno: "grid place-items-center";

View File

@@ -200,6 +200,9 @@ function handleToggleDockItem(dockItem: any) {
<SettingsItem :title="$t('settings.disable_light_dark_mode_switcher')">
<Radio v-model="settings.disableLightDarkModeSwitcherOnDock" />
</SettingsItem>
<SettingsItem :title="$t('settings.back_to_top_and_refresh_buttons_are_separated')">
<Radio v-model="settings.backToTopAndRefreshButtonsAreSeparated" />
</SettingsItem>
</SettingsItemGroup>
<SettingsItemGroup :title="$t('settings.group_sidebar')" :desc="$t('settings.group_sidebar_desc')">
<SettingsItem :title="$t('settings.sidebar_position')">

View File

@@ -51,6 +51,8 @@ export interface Settings {
dockItemsConfig: { page: AppPage, visible: boolean, openInNewTab: boolean, useOriginalBiliPage: boolean }[]
disableDockGlowingEffect: boolean
disableLightDarkModeSwitcherOnDock: boolean
backToTopAndRefreshButtonsAreSeparated: boolean
sidebarPosition: 'left' | 'right'
autoHideSidebar: boolean
@@ -152,6 +154,8 @@ export const originalSettings: Settings = {
dockItemsConfig: [],
disableDockGlowingEffect: false,
disableLightDarkModeSwitcherOnDock: false,
backToTopAndRefreshButtonsAreSeparated: true,
sidebarPosition: 'right',
autoHideSidebar: false,