Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ function formatDisplay(display: string) {
}
}

function toastMessage(
message: string,
type?: 'normal' | 'error' | 'warning' | undefined
) {
const piniaMessage = '🍍 ' + message

if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') {
__VUE_DEVTOOLS_TOAST__(piniaMessage, type)
} else if (type === 'error') {
console.error(piniaMessage)
} else if (type === 'warning') {
console.warn(piniaMessage)
} else {
console.log(piniaMessage)
}
}

let isAlreadyInstalled: boolean | undefined

export function addDevtools(app: App, store: GenericStore) {
Expand Down Expand Up @@ -116,18 +133,15 @@ export function addDevtools(app: App, store: GenericStore) {
options: formatStoreForInspectorState(store),
}
} else {
__VUE_DEVTOOLS_TOAST__(
`🍍 store "${payload.nodeId}" not found`,
'error'
)
toastMessage(`store "${payload.nodeId}" not found`, 'error')
}
}
})

// trigger an update so it can display new registered stores
// @ts-ignore
api.notifyComponentUpdate()
__VUE_DEVTOOLS_TOAST__(`🍍 "${store.$id}" store installed`)
toastMessage(`"${store.$id}" store installed`)
}
)
}
Expand Down