mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
implementing snapshots
This commit is contained in:
@@ -5,7 +5,9 @@ export type Alert = {
|
||||
text: string,
|
||||
icon: string,
|
||||
ms: number,
|
||||
id: number
|
||||
id: number,
|
||||
remaining: number,
|
||||
transitionStyle: string
|
||||
}
|
||||
|
||||
const alerts = ref<Alert[]>([]);
|
||||
@@ -18,11 +20,18 @@ const idPool = {
|
||||
}
|
||||
|
||||
function createAlert(title: string, text: string, icon: string, ms: number) {
|
||||
const alert: Alert = { title, text, icon, ms, id: idPool.getId() }
|
||||
const alert = reactive<Alert>({
|
||||
title, text, icon, ms, id: idPool.getId(), remaining: ms,
|
||||
transitionStyle: 'transition: all 250ms linear;'
|
||||
});
|
||||
alerts.value.push(alert);
|
||||
setTimeout(() => {
|
||||
closeAlert(alert.id);
|
||||
}, ms)
|
||||
const timeout = setInterval(() => {
|
||||
alert.remaining -= 250;
|
||||
if (alert.remaining <= 0) {
|
||||
closeAlert(alert.id);
|
||||
clearInterval(timeout);
|
||||
}
|
||||
}, 250)
|
||||
}
|
||||
|
||||
function closeAlert(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user