update
This commit is contained in:
50
src/stores/dialog.ts
Normal file
50
src/stores/dialog.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
export const useDialogStore = defineStore('dialog', () => {
|
||||
const onConfirm = ref<Function>()
|
||||
const onCancel = ref<Function>()
|
||||
const confirmText = ref('')
|
||||
const cancelText = ref('')
|
||||
const open = ref(false)
|
||||
const title = ref('')
|
||||
const content = ref('')
|
||||
const type = ref('normal')
|
||||
const showCancelButton = ref(true)
|
||||
const dismissOnAction = ref(true)
|
||||
|
||||
const timer = ref<any>()
|
||||
watch(open, (value) => {
|
||||
if (!value) {
|
||||
// check if timer is set
|
||||
if (timer.value) {
|
||||
clearTimeout(timer.value)
|
||||
}
|
||||
|
||||
timer.value = setTimeout(() => {
|
||||
onConfirm.value = () => { }
|
||||
onCancel.value = () => { }
|
||||
dismissOnAction.value = true
|
||||
showCancelButton.value = true
|
||||
}, 2000)
|
||||
} else {
|
||||
if (timer.value) {
|
||||
clearTimeout(timer.value)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
showCancelButton,
|
||||
dismissOnAction,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
title,
|
||||
content,
|
||||
type,
|
||||
open,
|
||||
confirmText,
|
||||
cancelText,
|
||||
}
|
||||
})
|
@@ -2,11 +2,9 @@ import { ref, computed } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import {
|
||||
BoltIcon,
|
||||
Cog6ToothIcon,
|
||||
ComputerDesktopIcon,
|
||||
DocumentDuplicateIcon,
|
||||
DocumentTextIcon,
|
||||
FolderArrowDownIcon,
|
||||
FolderOpenIcon,
|
||||
ShieldCheckIcon,
|
||||
} from '@heroicons/vue/24/outline'
|
||||
@@ -252,8 +250,12 @@ export const useMenuStore = defineStore('menu', () => {
|
||||
],
|
||||
},
|
||||
]
|
||||
const sidebarOpen = ref(false)
|
||||
const toggleSidebar = () => (sidebarOpen.value = !sidebarOpen.value)
|
||||
|
||||
|
||||
// expose everything
|
||||
return { navigation }
|
||||
return {
|
||||
navigation,
|
||||
toggleSidebar,
|
||||
sidebarOpen
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user