|
55 | 55 | v-bind="props.action" |
56 | 56 | :href="item.url" |
57 | 57 | target="_blank" |
| 58 | + :class="typeof item.class === 'function' ? item.class() : item.class" |
| 59 | + @mousedown=" |
| 60 | + isZoomCommand(item) ? handleZoomMouseDown(item, $event) : undefined |
| 61 | + " |
| 62 | + @click="isZoomCommand(item) ? handleZoomClick($event) : undefined" |
58 | 63 | > |
59 | | - <span v-if="item.icon" class="p-menubar-item-icon" :class="item.icon" /> |
| 64 | + <i |
| 65 | + v-if="hasActiveStateSiblings(item)" |
| 66 | + class="p-menubar-item-icon pi pi-check text-sm" |
| 67 | + :class="{ invisible: !item.comfyCommand?.active?.() }" |
| 68 | + /> |
| 69 | + <span |
| 70 | + v-else-if=" |
| 71 | + item.icon && item.comfyCommand?.id !== 'Comfy.NewBlankWorkflow' |
| 72 | + " |
| 73 | + class="p-menubar-item-icon" |
| 74 | + :class="item.icon" |
| 75 | + /> |
60 | 76 | <span class="p-menubar-item-label text-nowrap">{{ item.label }}</span> |
| 77 | + <i |
| 78 | + v-if="item.comfyCommand?.id === 'Comfy.NewBlankWorkflow'" |
| 79 | + class="ml-auto" |
| 80 | + :class="item.icon" |
| 81 | + /> |
61 | 82 | <span |
62 | 83 | v-if="item?.comfyCommand?.keybinding" |
63 | 84 | class="ml-auto border border-surface rounded text-muted text-xs text-nowrap p-1 keybinding-tag" |
@@ -94,6 +115,7 @@ import { useSettingStore } from '@/stores/settingStore' |
94 | 115 | import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore' |
95 | 116 | import { showNativeSystemMenu } from '@/utils/envUtil' |
96 | 117 | import { normalizeI18nKey } from '@/utils/formatUtil' |
| 118 | +import { whileMouseDown } from '@/utils/mouseDownUtil' |
97 | 119 |
|
98 | 120 | const colorPaletteStore = useColorPaletteStore() |
99 | 121 | const menuItemsStore = useMenuItemStore() |
@@ -163,16 +185,22 @@ const extraMenuItems: MenuItem[] = [ |
163 | 185 | }, |
164 | 186 | { separator: true }, |
165 | 187 | { |
166 | | - key: 'manage-extensions', |
167 | | - label: t('menu.manageExtensions'), |
168 | | - icon: 'mdi mdi-puzzle-outline', |
169 | | - command: showManageExtensions |
| 188 | + key: 'browse-templates', |
| 189 | + label: t('menuLabels.Browse Templates'), |
| 190 | + icon: 'pi pi-folder-open', |
| 191 | + command: () => commandStore.execute('Comfy.BrowseTemplates') |
170 | 192 | }, |
171 | 193 | { |
172 | 194 | key: 'settings', |
173 | 195 | label: t('g.settings'), |
174 | 196 | icon: 'mdi mdi-cog-outline', |
175 | 197 | command: () => showSettings() |
| 198 | + }, |
| 199 | + { |
| 200 | + key: 'manage-extensions', |
| 201 | + label: t('menu.manageExtensions'), |
| 202 | + icon: 'mdi mdi-puzzle-outline', |
| 203 | + command: showManageExtensions |
176 | 204 | } |
177 | 205 | ] |
178 | 206 |
|
@@ -237,6 +265,36 @@ const onMenuShow = () => { |
237 | 265 | } |
238 | 266 | }) |
239 | 267 | } |
| 268 | +
|
| 269 | +const isZoomCommand = (item: MenuItem) => { |
| 270 | + return ( |
| 271 | + item.comfyCommand?.id === 'Comfy.Canvas.ZoomIn' || |
| 272 | + item.comfyCommand?.id === 'Comfy.Canvas.ZoomOut' |
| 273 | + ) |
| 274 | +} |
| 275 | +
|
| 276 | +const handleZoomMouseDown = (item: MenuItem, event: MouseEvent) => { |
| 277 | + if (item.comfyCommand) { |
| 278 | + whileMouseDown( |
| 279 | + event, |
| 280 | + async () => { |
| 281 | + await commandStore.execute(item.comfyCommand!.id) |
| 282 | + }, |
| 283 | + 50 |
| 284 | + ) |
| 285 | + } |
| 286 | +} |
| 287 | +
|
| 288 | +const handleZoomClick = (event: MouseEvent) => { |
| 289 | + event.preventDefault() |
| 290 | + event.stopPropagation() |
| 291 | + // Prevent the menu from closing for zoom commands |
| 292 | + return false |
| 293 | +} |
| 294 | +
|
| 295 | +const hasActiveStateSiblings = (item: MenuItem): boolean => { |
| 296 | + return menuItemsStore.menuItemHasActiveStateChildren[item.parentPath] |
| 297 | +} |
240 | 298 | </script> |
241 | 299 |
|
242 | 300 | <style scoped> |
|
0 commit comments