Skip to content

Commit a9b578e

Browse files
committed
feat: AquaMai 版本红点
1 parent d0311e5 commit a9b578e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • MaiChartManager/Front/src/components/Sidebar

MaiChartManager/Front/src/components/Sidebar/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { useVModel } from '@vueuse/core';
33
import { useI18n } from 'vue-i18n';
44
import RefreshAllButton from './RefreshAllButton';
55
import VersionInfo from '@/components/VersionInfo';
6+
import { shouldShowUpdate as aquaMaiHasUpdate } from '@/views/ModManager/shouldShowUpdateController';
67

78
export type SidebarItem = 'charts' | 'mods' | 'batch' | 'genres' | 'tools' | 'settings';
89

9-
const items: { key: SidebarItem; icon: string; labelKey: string }[] = [
10+
const items: { key: SidebarItem; icon: string; labelKey: string; badge?: () => boolean }[] = [
1011
{ key: 'charts', icon: 'i-mdi-music-note', labelKey: 'sidebar.charts' },
11-
{ key: 'mods', icon: 'i-mdi:puzzle', labelKey: 'sidebar.mods' },
12+
{ key: 'mods', icon: 'i-mdi:puzzle', labelKey: 'sidebar.mods', badge: () => aquaMaiHasUpdate.value },
1213
{ key: 'batch', icon: 'i-mdi-playlist-edit', labelKey: 'sidebar.batch' },
1314
{ key: 'genres', icon: 'i-mdi-tag-multiple', labelKey: 'sidebar.genres' },
1415
{ key: 'tools', icon: 'i-ri:tools-fill', labelKey: 'sidebar.tools' },
@@ -27,7 +28,7 @@ export default defineComponent({
2728
const active = useVModel(props, 'active', emit);
2829

2930

30-
const renderItem = (key: SidebarItem, icon: string, labelKey: string, desktop: boolean) => (
31+
const renderItem = (key: SidebarItem, icon: string, labelKey: string, desktop: boolean, badge?: boolean) => (
3132
<div
3233
key={key}
3334
class={[
@@ -47,6 +48,7 @@ export default defineComponent({
4748
<div class="absolute bottom-0 left-1.5 right-1.5 h-0.75 rounded-t-full bg-[var(--link-color)]" />
4849
)}
4950
<span class={[icon, 'text-6']} />
51+
{badge && <div class="absolute top-1 right-1 w-2 h-2 rounded-full bg-red-500 pointer-events-none" />}
5052
<span class={[
5153
'absolute px-3 py-1.5 rounded-lg bg-[oklch(0.7_0.13_var(--hue))] text-white text-sm whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-200 z-100',
5254
desktop ? 'left-full ml-2' : 'max-[439px]:hidden bottom-full mb-2 left-1/2 -translate-x-1/2',
@@ -58,7 +60,7 @@ export default defineComponent({
5860
<>
5961
{/* Desktop sidebar */}
6062
<div class="hidden md:flex w-16 flex-col items-center py-2 gap-1 h-100dvh shrink-0 border-r border-r-[oklch(0.9_0.02_var(--hue))] border-r-solid bg-[oklch(0.98_0.01_var(--hue))] z-20 relative cst">
61-
{items.map((item) => renderItem(item.key, item.icon, item.labelKey, true))}
63+
{items.map((item) => renderItem(item.key, item.icon, item.labelKey, true, item.badge?.()))}
6264
<div class="mt-auto" />
6365
{renderItem('settings', 'i-mdi-cog', 'sidebar.settings', true)}
6466
<RefreshAllButton />
@@ -73,7 +75,7 @@ export default defineComponent({
7375
'min-[440px]:justify-center',
7476
'bg-[oklch(0.98_0.01_var(--hue))] border-t border-t-[oklch(0.9_0.02_var(--hue))] border-t-solid',
7577
]}>
76-
{items.map((item) => renderItem(item.key, item.icon, item.labelKey, false))}
78+
{items.map((item) => renderItem(item.key, item.icon, item.labelKey, false, item.badge?.()))}
7779
{renderItem('settings', 'i-mdi-cog', 'sidebar.settings', false)}
7880
<RefreshAllButton />
7981
<VersionInfo />

0 commit comments

Comments
 (0)