|
1 | 1 | <script setup lang="ts"> |
2 | | -import type { DropdownMenuItem } from "@nuxt/ui"; |
3 | | -import type { LangType } from "~/types"; |
4 | | -
|
5 | 2 | import Profile from "~/components/SideBar/profile.vue"; |
6 | 3 |
|
7 | | -const { t, locales, locale } = useI18n(); |
8 | | -const { openSettings } = useSettingsWindow(); |
9 | | -const { themeDropdownItems } = useThemeOptions(); |
10 | | -const { setLang } = useSettingManager(); |
11 | | -const localePath = useLocalePath(); |
| 4 | +const { t } = useI18n(); |
| 5 | +const { activeWorkspaceMode } = useWorkspaceMode(); |
| 6 | +const { activeTab: rightPanelTab, open: rightPanelOpen, toggle: toggleRightPanel } = useRightPanel(); |
| 7 | +const { open: aiPanelOpen, toggleAi } = useAiPanel(); |
| 8 | +const showRightPanelButton = computed(() => activeWorkspaceMode.value !== "files"); |
| 9 | +const aiButtonLabel = computed(() => t(aiPanelOpen.value ? "RightPanel.AIClose" : "RightPanel.AIOpen")); |
12 | 10 |
|
13 | | -const commonButtonProps = { |
14 | | - size: "sm" as const, |
15 | | - color: "neutral" as const |
| 11 | +const handleToggleAi = () => { |
| 12 | + toggleAi(rightPanelOpen.value && rightPanelTab.value === "sftp" ? "sftp" : "workspace"); |
16 | 13 | }; |
17 | | -
|
18 | | -const { open: rightPanelOpen, toggle: toggleRightPanel } = useRightPanel(); |
19 | | -
|
20 | | -const languageItems = computed<DropdownMenuItem[]>(() => |
21 | | - ((locales.value as Array<{ code?: string; name?: string } | string>) || []).map((item) => { |
22 | | - const code = typeof item === "string" ? item : item.code || ""; |
23 | | - const label = typeof item === "string" ? item : item.name || code; |
24 | | -
|
25 | | - return { |
26 | | - label, |
27 | | - type: "checkbox", |
28 | | - checked: locale.value === code, |
29 | | - onUpdateChecked: (checked: boolean) => { |
30 | | - if (checked && code) setLang(code as LangType); |
31 | | - } |
32 | | - }; |
33 | | - }) |
34 | | -); |
35 | | -
|
36 | | -const toolItems = computed<DropdownMenuItem[]>(() => [ |
37 | | - { |
38 | | - label: t("Menu.Player"), |
39 | | - icon: "lucide:clapperboard", |
40 | | - to: localePath("videoplayer") |
41 | | - }, |
42 | | - { |
43 | | - label: t("Menu.Transcode"), |
44 | | - icon: "lucide:repeat-2", |
45 | | - to: localePath({ path: "/transcode" }) |
46 | | - } |
47 | | -]); |
48 | | -
|
49 | | -const appMenuItems = computed<DropdownMenuItem[]>(() => [ |
50 | | - { |
51 | | - label: t("Common.Language"), |
52 | | - icon: "i-lucide-languages", |
53 | | - children: languageItems.value |
54 | | - }, |
55 | | - ...(isDesktopRuntime() |
56 | | - ? [ |
57 | | - { |
58 | | - label: t("Menu.MyTools"), |
59 | | - icon: "i-lucide-wrench", |
60 | | - children: toolItems.value |
61 | | - } satisfies DropdownMenuItem |
62 | | - ] |
63 | | - : []), |
64 | | - { |
65 | | - label: t("Common.SwitchTheme"), |
66 | | - icon: "i-lucide-palette", |
67 | | - children: themeDropdownItems.value |
68 | | - }, |
69 | | - { type: "separator" }, |
70 | | - { |
71 | | - label: t("Common.Preferences"), |
72 | | - icon: "i-lucide-settings", |
73 | | - onSelect: () => void openSettings() |
74 | | - }, |
75 | | - { |
76 | | - label: t("DesktopMenu.About"), |
77 | | - icon: "i-lucide-info", |
78 | | - onSelect: () => void openSettings("/setting/about") |
79 | | - } |
80 | | -]); |
81 | 14 | </script> |
82 | 15 |
|
83 | 16 | <template> |
84 | 17 | <section class="flex items-center h-full"> |
85 | 18 | <div class="flex items-center gap-1 px-2"> |
86 | | - <UDropdownMenu |
87 | | - :items="appMenuItems" |
88 | | - size="sm" |
89 | | - :content="{ align: 'end', side: 'bottom', sideOffset: 6 }" |
90 | | - :ui="{ |
91 | | - item: '!items-center leading-none', |
92 | | - itemLeadingIcon: 'size-4 shrink-0 block leading-none', |
93 | | - itemTrailingIcon: '!size-4 shrink-0 block leading-none', |
94 | | - itemLabel: 'block truncate text-start leading-none', |
95 | | - itemWrapper: 'min-w-0 flex-1 justify-start text-start' |
96 | | - }" |
97 | | - > |
98 | | - <UTooltip arrow :text="t('Common.AppMenu')"> |
99 | | - <UButton |
100 | | - icon="i-lucide-settings" |
101 | | - :aria-label="t('Common.AppMenu')" |
102 | | - v-bind="commonButtonProps" |
103 | | - variant="ghost" |
104 | | - :ui="{ leadingIcon: 'size-4' }" |
105 | | - /> |
106 | | - </UTooltip> |
107 | | - </UDropdownMenu> |
| 19 | + <UTooltip arrow :text="aiButtonLabel"> |
| 20 | + <UButton |
| 21 | + icon="i-lucide-sparkles" |
| 22 | + :aria-label="aiButtonLabel" |
| 23 | + :aria-pressed="aiPanelOpen" |
| 24 | + size="sm" |
| 25 | + color="primary" |
| 26 | + :variant="aiPanelOpen ? 'soft' : 'ghost'" |
| 27 | + :ui="{ leadingIcon: 'size-4' }" |
| 28 | + @click="handleToggleAi" |
| 29 | + /> |
| 30 | + </UTooltip> |
108 | 31 |
|
109 | 32 | <Profile placement="topbar" /> |
110 | 33 |
|
111 | | - <UTooltip arrow :text="rightPanelOpen ? t('RightPanel.Close') : t('RightPanel.Open')"> |
| 34 | + <UTooltip v-if="showRightPanelButton" arrow :text="rightPanelOpen ? t('RightPanel.Close') : t('RightPanel.Open')"> |
112 | 35 | <UButton |
113 | 36 | :icon="rightPanelOpen ? 'i-lucide-panel-right-close' : 'i-lucide-panel-right'" |
114 | 37 | :aria-label="rightPanelOpen ? t('RightPanel.Close') : t('RightPanel.Open')" |
115 | 38 | :aria-pressed="rightPanelOpen" |
116 | | - v-bind="commonButtonProps" |
| 39 | + size="sm" |
| 40 | + color="neutral" |
117 | 41 | :variant="rightPanelOpen ? 'soft' : 'ghost'" |
| 42 | + :ui="{ leadingIcon: 'size-4' }" |
118 | 43 | @click="toggleRightPanel" |
119 | 44 | /> |
120 | 45 | </UTooltip> |
|
0 commit comments