ADD: Error notifications
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
"tailwind-merge": "^2.2.1",
|
"tailwind-merge": "^2.2.1",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"vue-i18n": "^9.10.1",
|
"vue-i18n": "^9.10.1",
|
||||||
|
"vue-sonner": "^1.1.2",
|
||||||
"vuedraggable": "^4.1.0"
|
"vuedraggable": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
@@ -65,6 +65,9 @@ dependencies:
|
|||||||
vue-i18n:
|
vue-i18n:
|
||||||
specifier: ^9.10.1
|
specifier: ^9.10.1
|
||||||
version: 9.10.1(vue@3.4.21)
|
version: 9.10.1(vue@3.4.21)
|
||||||
|
vue-sonner:
|
||||||
|
specifier: ^1.1.2
|
||||||
|
version: 1.1.2
|
||||||
vuedraggable:
|
vuedraggable:
|
||||||
specifier: ^4.1.0
|
specifier: ^4.1.0
|
||||||
version: 4.1.0(vue@3.4.21)
|
version: 4.1.0(vue@3.4.21)
|
||||||
@@ -4414,6 +4417,10 @@ packages:
|
|||||||
vue: 3.4.21(typescript@5.3.3)
|
vue: 3.4.21(typescript@5.3.3)
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/vue-sonner@1.1.2:
|
||||||
|
resolution: {integrity: sha512-yg4f5s0a3oiiI7cNvO0Dajux1Y7s04lxww3vnQtnwQawJ3KqaKA9RIRMdI9wGTosRGIOwgYFniFRGl4+IuKPZw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/vue-template-compiler@2.7.16:
|
/vue-template-compiler@2.7.16:
|
||||||
resolution: {integrity: sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==}
|
resolution: {integrity: sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -3,11 +3,19 @@ import ProfileManager from '@renderer/components/profile/ProfileManager.vue'
|
|||||||
import DevicePreview from '@renderer/components/device/DevicePreview.vue'
|
import DevicePreview from '@renderer/components/device/DevicePreview.vue'
|
||||||
import ConfigPane from '@renderer/components/config/ConfigPane.vue'
|
import ConfigPane from '@renderer/components/config/ConfigPane.vue'
|
||||||
import Navbar from '@renderer/components/navbar/Navbar.vue'
|
import Navbar from '@renderer/components/navbar/Navbar.vue'
|
||||||
import { useDeviceStore, initializeDevices } from '@renderer/deviceStore'
|
import { useDeviceStore, initializeDevices, onDeviceError } from '@renderer/deviceStore'
|
||||||
|
import { Toaster } from '@renderer/components/ui/sonner'
|
||||||
|
import { toast } from 'vue-sonner'
|
||||||
|
|
||||||
const deviceStore = useDeviceStore()
|
const deviceStore = useDeviceStore()
|
||||||
initializeDevices()
|
initializeDevices()
|
||||||
|
|
||||||
|
onDeviceError((error) => {
|
||||||
|
toast('Error', {
|
||||||
|
description: error
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// const menuActions = {
|
// const menuActions = {
|
||||||
// connect: () => store.setConnected(!store.connected),
|
// connect: () => store.setConnected(!store.connected),
|
||||||
// orientation: () => store.cycleScreenOrientation(),
|
// orientation: () => store.cycleScreenOrientation(),
|
||||||
@@ -61,6 +69,7 @@ initializeDevices()
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
<Toaster />
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.slide-left-enter-active,
|
.slide-left-enter-active,
|
||||||
|
|||||||
22
src/renderer/src/components/ui/sonner/Sonner.vue
Normal file
22
src/renderer/src/components/ui/sonner/Sonner.vue
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { Toaster as Sonner, type ToasterProps } from 'vue-sonner'
|
||||||
|
|
||||||
|
const props = defineProps<ToasterProps>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Sonner
|
||||||
|
class="toaster group"
|
||||||
|
v-bind="props"
|
||||||
|
:toast-options="{
|
||||||
|
classes: {
|
||||||
|
toast: 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
|
||||||
|
description: 'group-[.toast]:text-muted-foreground',
|
||||||
|
actionButton:
|
||||||
|
'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
|
||||||
|
cancelButton:
|
||||||
|
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
|
||||||
|
},
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
1
src/renderer/src/components/ui/sonner/index.ts
Normal file
1
src/renderer/src/components/ui/sonner/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default as Toaster } from './Sonner.vue'
|
||||||
@@ -52,6 +52,8 @@ interface UpdateData {
|
|||||||
|
|
||||||
const { nanoIpc } = window
|
const { nanoIpc } = window
|
||||||
|
|
||||||
|
const errorCallbacks: ((error: string) => void)[] = []
|
||||||
|
|
||||||
export const useDeviceStore = defineStore('device', {
|
export const useDeviceStore = defineStore('device', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
attachedDeviceIds: [] as string[], // list of attached device ids
|
attachedDeviceIds: [] as string[], // list of attached device ids
|
||||||
@@ -281,6 +283,9 @@ export const initializeDevices = () => {
|
|||||||
// register event handlers
|
// register event handlers
|
||||||
nanoIpc.on((eventid, deviceid, dataString) => {
|
nanoIpc.on((eventid, deviceid, dataString) => {
|
||||||
console.log('Received event', eventid, deviceid, dataString)
|
console.log('Received event', eventid, deviceid, dataString)
|
||||||
|
if (eventid === 'error') {
|
||||||
|
errorCallbacks.forEach((callback) => callback(dataString))
|
||||||
|
}
|
||||||
if (eventid === 'device-attached') {
|
if (eventid === 'device-attached') {
|
||||||
deviceStore.attachDevice(deviceid)
|
deviceStore.attachDevice(deviceid)
|
||||||
if (deviceStore.attachedDeviceIds.length === 1) {
|
if (deviceStore.attachedDeviceIds.length === 1) {
|
||||||
@@ -348,6 +353,10 @@ export const initializeDevices = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const onDeviceError = (callback: (error: string) => void) => {
|
||||||
|
errorCallbacks.push(callback)
|
||||||
|
}
|
||||||
|
|
||||||
// // devices, device attachment, connection, and disconnection
|
// // devices, device attachment, connection, and disconnection
|
||||||
// init_devices(ids) {
|
// init_devices(ids) {
|
||||||
// console.log('Initializing devices: ', ids)
|
// console.log('Initializing devices: ', ids)
|
||||||
|
|||||||
Reference in New Issue
Block a user