mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Extension API to add toast message (#491)
* Extension API to add toast message * Update readme
This commit is contained in:
15
README.md
15
README.md
@@ -116,6 +116,21 @@ We will support custom icons later.
|
||||

|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>v1.2.27: Extension API to add toast message</summary>
|
||||
|
||||
Extensions can call the following API to add toast messages.
|
||||
|
||||
```js
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'info',
|
||||
summary: 'Loaded!',
|
||||
detail: 'Extension loaded!'
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
</details>
|
||||
|
||||
## Road Map
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SidebarTabExtension } from '@/types/extensionTypes'
|
||||
import { SidebarTabExtension, ToastManager } from '@/types/extensionTypes'
|
||||
import { defineStore } from 'pinia'
|
||||
import { useToastStore } from './toastStore'
|
||||
|
||||
interface WorkspaceState {
|
||||
spinner: boolean
|
||||
@@ -13,6 +14,11 @@ export const useWorkspaceStore = defineStore('workspace', {
|
||||
activeSidebarTab: null,
|
||||
sidebarTabs: []
|
||||
}),
|
||||
getters: {
|
||||
toast(): ToastManager {
|
||||
return useToastStore()
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
updateActiveSidebarTab(tabId: string) {
|
||||
this.activeSidebarTab = tabId
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ToastMessageOptions } from 'primevue/toast'
|
||||
import { Component } from 'vue'
|
||||
|
||||
export interface BaseSidebarTabExtension {
|
||||
@@ -24,8 +25,18 @@ export type SidebarTabExtension =
|
||||
| VueSidebarTabExtension
|
||||
| CustomSidebarTabExtension
|
||||
|
||||
export type ToastManager = {
|
||||
add(message: ToastMessageOptions): void
|
||||
remove(message: ToastMessageOptions): void
|
||||
removeAll(): void
|
||||
}
|
||||
|
||||
export interface ExtensionManager {
|
||||
// Sidebar tabs
|
||||
registerSidebarTab(tab: SidebarTabExtension): void
|
||||
unregisterSidebarTab(id: string): void
|
||||
getSidebarTabs(): SidebarTabExtension[]
|
||||
|
||||
// Toast
|
||||
toast: ToastManager
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user