File tree Expand file tree Collapse file tree 6 files changed +71
-6
lines changed Expand file tree Collapse file tree 6 files changed +71
-6
lines changed Original file line number Diff line number Diff line change 22 <ProgressSpinner v-if =" isLoading" class =" spinner" ></ProgressSpinner >
33 <BlockUI full-screen :blocked =" isLoading" />
44 <GlobalDialog />
5+ <GlobalToast />
56 <GraphCanvas />
67</template >
78
@@ -24,6 +25,7 @@ import { useI18n } from 'vue-i18n'
2425import { useWorkspaceStore } from ' ./stores/workspaceStateStore'
2526import NodeLibrarySidebarTab from ' ./components/sidebar/tabs/NodeLibrarySidebarTab.vue'
2627import GlobalDialog from ' ./components/dialog/GlobalDialog.vue'
28+ import GlobalToast from ' ./components/toast/GlobalToast.vue'
2729import { api } from ' ./scripts/api'
2830import { StatusWsMessageStatus } from ' ./types/apiTypes'
2931import { useQueuePendingTaskCountStore } from ' ./stores/queueStore'
Original file line number Diff line number Diff line change 3636 </div >
3737 </template >
3838 </SideBarTabTemplate >
39- <Toast />
4039 <ConfirmPopup />
4140 <ContextMenu ref =" menu" :model =" menuItems" />
4241</template >
4342
4443<script setup lang="ts">
4544import Button from ' primevue/button'
4645import ConfirmPopup from ' primevue/confirmpopup'
47- import Toast from ' primevue/toast'
4846import ContextMenu from ' primevue/contextmenu'
4947import TaskItem from ' ./queue/TaskItem.vue'
5048import SideBarTabTemplate from ' ./SidebarTabTemplate.vue'
Original file line number Diff line number Diff line change 1+ <template >
2+ <Toast />
3+ </template >
4+
5+ <script setup lang="ts">
6+ import { useToastStore } from ' @/stores/toastStore'
7+ import Toast from ' primevue/toast'
8+ import { useToast } from ' primevue/usetoast'
9+ import { watch } from ' vue'
10+
11+ const toast = useToast ()
12+ const toastStore = useToastStore ()
13+
14+ watch (
15+ () => toastStore .messages ,
16+ (newMessages ) => {
17+ if (newMessages .length === 0 ) {
18+ return
19+ }
20+
21+ newMessages .forEach ((message ) => {
22+ toast .add (message )
23+ })
24+ toastStore .removeAll ()
25+ },
26+ { deep: true }
27+ )
28+ </script >
Original file line number Diff line number Diff line change 11import { app } from '../../scripts/app'
22import { api } from '../../scripts/api'
3+ import { useToastStore } from '@/stores/toastStore'
34
45app . registerExtension ( {
56 name : 'Comfy.Keybinds' ,
67 init ( ) {
7- const keybindListener = function ( event ) {
8+ const keybindListener = async function ( event ) {
89 const modifierPressed = event . ctrlKey || event . metaKey
910
1011 // Queue prompt using (ctrl or command) + enter
1112 if ( modifierPressed && event . key === 'Enter' ) {
1213 // Cancel current prompt using (ctrl or command) + alt + enter
1314 if ( event . altKey ) {
14- api . interrupt ( )
15+ await api . interrupt ( )
16+ useToastStore ( ) . add ( {
17+ severity : 'info' ,
18+ summary : 'Interrupted' ,
19+ detail : 'Execution has been interrupted' ,
20+ life : 1000
21+ } )
1522 return
1623 }
1724 // Queue prompt as first for generation using (ctrl or command) + shift + enter
Original file line number Diff line number Diff line change 11import { StatusWsMessageStatus } from '@/types/apiTypes'
22import { api } from '../../api'
33import { ComfyButton } from '../components/button'
4+ import { useToastStore } from '@/stores/toastStore'
45
56export function getInterruptButton ( visibility : string ) {
67 const btn = new ComfyButton ( {
78 icon : 'close' ,
89 tooltip : 'Cancel current generation' ,
910 enabled : false ,
10- action : ( ) => {
11- api . interrupt ( )
11+ action : async ( ) => {
12+ await api . interrupt ( )
13+ useToastStore ( ) . add ( {
14+ severity : 'info' ,
15+ summary : 'Interrupted' ,
16+ detail : 'Execution has been interrupted' ,
17+ life : 1000
18+ } )
1219 } ,
1320 classList : [ 'comfyui-button' , 'comfyui-interrupt-button' , visibility ]
1421 } )
Original file line number Diff line number Diff line change 1+ // Within Vue component context, you can directly call useToast().add()
2+ // instead of going through the store.
3+ // The store is useful when you need to call it from outside the Vue component context.
4+ import { defineStore } from 'pinia'
5+ import type { ToastMessageOptions } from 'primevue/toast'
6+
7+ export const useToastStore = defineStore ( 'toast' , {
8+ state : ( ) => ( {
9+ messages : [ ] as ToastMessageOptions [ ]
10+ } ) ,
11+
12+ actions : {
13+ add ( message : ToastMessageOptions ) {
14+ this . messages = [ ...this . messages , message ]
15+ } ,
16+ remove ( message : ToastMessageOptions ) {
17+ this . messages = this . messages . filter ( ( msg ) => msg !== message )
18+ } ,
19+ removeAll ( ) {
20+ this . messages = [ ]
21+ }
22+ }
23+ } )
You can’t perform that action at this time.
0 commit comments